Apache, MySQL and PHP Installation and Configuration Chapter 1 Apache Installation and...

11
Apache, MySQL and PHP Apache, MySQL and PHP Installation and Installation and Configuration Configuration Chapter 1 Chapter 1 Apache Installation and Apache Installation and Configuration Configuration

Transcript of Apache, MySQL and PHP Installation and Configuration Chapter 1 Apache Installation and...

Page 1: Apache, MySQL and PHP Installation and Configuration Chapter 1 Apache Installation and Configuration.

Apache, MySQL and PHP Installation Apache, MySQL and PHP Installation and Configurationand Configuration

Chapter 1Chapter 1Apache Installation and Apache Installation and

ConfigurationConfiguration

Page 2: Apache, MySQL and PHP Installation and Configuration Chapter 1 Apache Installation and Configuration.

Apache InstallationApache 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 administrator’s e-mail address•Apache users

Page 3: Apache, MySQL and PHP Installation and Configuration Chapter 1 Apache Installation and Configuration.

Apache InstallationApache 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.

Page 4: Apache, MySQL and PHP Installation and Configuration Chapter 1 Apache Installation and Configuration.

Apache InstallationApache 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 it’s built. For a complete list of configuration options, run ./configure -help.

tar –xzf httpd-2.0.52.tar.gzcd httpd-2.0.52

./configure \--prefix=/usr/local/apache2 \--enable-so \--enable-mods-shared=max \--enable-modules=most

Page 5: Apache, MySQL and PHP Installation and Configuration Chapter 1 Apache Installation and Configuration.

Apache InstallationApache InstallationInstalling 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

Page 6: Apache, MySQL and PHP Installation and Configuration Chapter 1 Apache Installation and Configuration.

Apache ConfigurationApache Configuration

Testing Installation :

•Open browser and type :

•If installation was successful you will see this thing :

•If it’s 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

Page 7: Apache, MySQL and PHP Installation and Configuration Chapter 1 Apache Installation and Configuration.

ConfigurationConfiguration

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 .tgzAddType image/x-icon .ico

AddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phps

Page 8: Apache, MySQL and PHP Installation and Configuration Chapter 1 Apache Installation and Configuration.

ConfigurationConfiguration

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.soLoadModule actions_module modules/mod_actions.so...

LoadModule php5_module “c:/php/sapi/php5apache2.dll”

Page 9: Apache, MySQL and PHP Installation and Configuration Chapter 1 Apache Installation and Configuration.

ConfigurationConfigurationDocument 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 structureTo 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”

Page 10: Apache, MySQL and PHP Installation and Configuration Chapter 1 Apache Installation and Configuration.

ConfigurationConfigurationDocument 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 something’s 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.#<Directory “C:/Program Files/Apache Group/Apache2/htdocs”>

<Directory “C:/Program Files/Apache Group/Apache2/test”>

Page 11: Apache, MySQL and PHP Installation and Configuration Chapter 1 Apache Installation and Configuration.

ReferencesReferences

References :

1.Anonymous.(n.d.). Apache HTTP Server Documentation Version 2.2. Retrieved from http://httpd.apache.org/docs/2.2/.2.Achour, M., Betz, F. (n.d.), PHP Manual. Retrieved from http://www.php.net/download-docs.php.3.Anonymous. (n.d.). MySQL Reference Manual. Retrieved from http://downloads.mysql.com/docs/. 4.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.