Title: Apache, MySQL and PHP Installation and Configuration
1Apache, MySQL and PHP Installation and
Configuration
- Chapter 1
- Apache Installation and Configuration
2Apache Installation
- Installing with Windows
- Go to apache website, and download Apache HTTP
Server latest stable version. - Chose the Win 32 Binary (MSI Installer) link to
download. - Click the MSI file to initiate the installation
wizard for the Apache software. - Click Next. You will see the Server Information
screen. - Enter the following information
- Domain name For example, domainname.com
- Server name For example, server.domainname.com
- Net administrators e-mail address
- Apache users
3Apache Installation
- Installing with Windows
- Click Next to select a setup type. Typical
installation is recommended for beginners and
will suffice for most needs. Advanced users may
feel more comfortable choosing Custom setup. - Click Next. The Destination Folder screen
appears. - If you do not want your Apache files saved in the
default path, click Change and select an
alternate path then click Next. - Click Install to finish installation.
4Apache Installation
- Installing with Linux
- Go to apache website, and download Apache HTTP
Server latest stable version. - Grab the tarball, named something along the lines
of httpd-2.0.x.tar.gz. - Open a console window, and change the directory
(cd) to the folder where you downloaded the
tarball. - Next, extract the tarball, and change to the
directory it creates - Configure the source
-
- Using the --prefix switch tells the installer
where to put the Apache server after its built.
For a complete list of configuration options, run
./configure -help.
tar xzf httpd-2.0.52.tar.gz cd httpd-2.0.52
./configure \ --prefix/usr/local/apache2
\ --enable-so \ --enable-mods-sharedmax
\ --enable-modulesmost
5Apache Installation
- Installing with Linux
- Compile the source
- Install the server
- Note that you will need to be logged in as
superuser (root) to perform this step and the
following steps in the Apache installation. - Start the Apache daemon
- Add the command to start Apache to whatever boot
scripts you like, so the server starts every time
you reboot. For example
make
make install
/usr/local/apache2/bin/apachectl start
echo /usr/local/apache2/bin/apachectl start
6Apache Configuration
- Testing Installation
- Open browser and type
- If installation was successful you will see this
thing - If its not, you must check your error log by
opening error.log, you can find here by default
http//localhost
It Works !
echo /usr/local/apache2/bin/apachectl start
7Configuration
- Adding PHP
- In order for Apache to recognize a PHP file as
one that needs to be parsed with the PHP engine,
you need to first locate the following lines in
your httpd.conf file - Then add the following lines
-
AddType allows you to add to or override the
MIME configuration file mime.types for specific
file types. AddType application/x-tar
.tgz AddType image/x-icon .ico
AddType application/x-httpd-php .php AddType
application/x-httpd-php-source .phps
8Configuration
- Adding PHP
- Add the PHP module into your httpd.conf program
so that Apache can properly parse PHP. In your
script, locate the following lines that contain
Dynamic Shared Object (DSO) Support - Then add the following lines
- Make sure your path matches the location of this
file, as determined during your installation.
... LoadModule access_module modules/mod_access.so
LoadModule actions_module modules/mod_actions.so
...
LoadModule php5_module c/php/sapi/php5apache2.dl
l
9Configuration
- Document Root
- By default, the directory under which Apache
looks for files is c\program files\Apache
Group\Apache2\htdocs\. You can change this to
whatever is applicable for your directory
structure - To point Apache to the new directory, you must
change the document root in your httpd.conf file
by following these steps - Locate the section of the file that resembles
this text - Change the last line of this section to
- Notice that this uses forward slashes instead of
backslashes.
DocumentRoot The directory out of which you
will serve your documents. By default, all
requests are taken from this directory, but
symbolic links and aliases may be used to point
to other locations. DocumentRoot C/Program
Files/Apache Group/Apache2/htdocs
DocumentRoot C/Program Files/Apache
Group/Apache2/test
10Configuration
- Document Root
- Locate the section of the file that resembles
this text - Change the last line of this section to
- Save your file and restart Apache so it can
recognize the changes you made to the config
file. (Make sure you have created this directory
before restarting Apache or you will get an
Operation Failed! error.).
Note that from this point forward you must
specifically allow particular features to be
enabled - so if somethings not working as you
might expect, make sure that you have
specifically enabled it below. This
should be changed to whatever you set
DocumentRoot to. ltDirectory C/Program
Files/Apache Group/Apache2/htdocsgt
ltDirectory C/Program Files/Apache
Group/Apache2/testgt
11References
- References
- Anonymous.(n.d.). Apache HTTP Server
Documentation Version 2.2. Retrieved from
http//httpd.apache.org/docs/2.2/. - Achour, M., Betz, F. (n.d.), PHP Manual.
Retrieved from http//www.php.net/download-docs.ph
p. - Anonymous. (n.d.). MySQL Reference Manual.
Retrieved from http//downloads.mysql.com/docs/. - Naramore, E., Gerner, J., Le Scouarnec, Y.,
Stolz, J., Glass, M. K. (2005). Beginning PHP5,
Apache, and MySQL Web Development. Indianapolis,
IN Wiley Publishing, Inc.