Step1: Apache installation and configuration
After all the steps of this tutorial, we'll be able to host our web site on our PC running Windows.
Download
VC9 x86 Thread Safe: php-5.3.6-Win32-VC9-x86 (zip format only) Apache Http Server 2.2.19/2.2.17
MySQL 5.1.50
Apache 2.2.19 (or 2.2.17) Install.
Run the Apache installer package, "httpd-2.2.19-win32-x86-no_ssl.msi" or "httpd-2.2.17-win32-x86-no_ssl.msi"
Click Next.
In the "Server Information" dialog box, enter
Network Domain: localhost
Server Name : localhost
Administrator's Email Address: admin@mycompany.com
Leave the default setting of for All Users, on Port 80, as a Service as it is.
Click "Next"
Note: The installer uses the information you enter to create a default Apache configuration file for you. You can always go back and manually change these values in your configuration file if you change your mind later.
When asked about the Setup Type, select "Typical" and click "Next".
In the Destination Folder dialog, allow the installer to install to the default folder. So, just click "Next"
Finally click the "Install" button to allow the installer to set up Apache.
When it is done, click the "Finish" button.
Once Installation is complete, verify the installation by clicking on the Apache Icon in the taskbar (far left), as shown below.
You can also verify your installation of Apache by opening http://localhost/ in your browser. Or you can just type in "localhost" for the URL.
Congratulations for a successful installation of Apache. We still have to configure Apache, but we will do it in the later steps.
Step 2: PHP 5.3.6 installation and configuration
Extract PHP package
Now it's time to install PHP5. Open the zip file & extract all your files to C:\php. Navigate to C:\php
Make php.ini file
Rename php.ini-development to php.ini
Edit the php.ini file
Edit 1
Find extension_dir = "./" and replace it with
extension_dir = "C:/php/ext"
Edit 2
We're going to uncomment by removing the ";" from the extension to activate it.
Here are the extensions to be uncommented.
Search for each one them and remove the semicolon ";"
;extension=php_gd2.dll
;extension=php_mbstring.dll
;extension=php_mysql.dll
;extension=php_mysqli.dll
The First extension enables the Image GD library of PHP.
The Second enables mbstring.
The Third and forth enables us to use MySQL database.
Save the php.ini file.
Setup PHP Environment
Let's setup the PATH environment variable.
Start->Control Panel->System->Advanced System Settings
then go to the Advanced tab, click on the Environmental Variables button,
then scroll down in system variables to find PATH,
Edit it Add C:\php;
Restart the System
You must reboot a windows system after setting the Path variable.
If you move on past that point without rebooting apache may have trouble finding your MySQL extensions.
Now we have PHP configured.
Let's move on to configuring Apache.
Step3: Configuring Apache
Go to C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\
You may need to turn off UAC for editing.
httpd.conf Editing
Edit 1:
Uncomment:
#LoadModule rewrite_module modules/mod_rewrite.so
=>
LoadModule rewrite_module modules/mod_rewrite.so
Edit 2:
Add the following below the previous edit
#PHP5
LoadModule php5_module "C:/php/php5apache2_2.dll"
PHPIniDir "C:/php"
Edit 3:
Search for
AddType application/x-gzip .gz .tgz
Add the following lines below it. These lines define a MIME (Multipurpose Internet Mail Extensions) type for files ending with a file extension of .php and .phps so they will be processed by the PHP parser on request.
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Edit 4:
Search for DirectoryIndex index.html
Replace it with
DirectoryIndex index.html index.php
Edit 5:
Uncomment:
#Include conf/extra/httpd-vhosts.conf
=>
Include conf/extra/httpd-vhosts.conf
Virtual Hosting Setup (optional )
You are about to make our server to host your domain for Apache Development project. You can name your own but here I am going to use apache.dev as a domain name. So, after we finished this step, we'll be able to type in our URL on the web browser:
http://www.apache.dev/,
then we get our home page from the http server installed on our machine.
But we need to setup the directory structure to realize the Virtual Hosting.
Directory Tree Setup
Make directories:
C:/server/www/apache.dev/public_html
httpd-vhosts.conf Editing
Open the file in:
C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\extra
Replace the contents with
<virtualhost *:80>
DocumentRoot "C:/server/www/apache.dev/public_html"
ServerName Apache.dev
ServerAlias www.apache.dev
<directory "C:/server/www/apache.dev/public_html">
AllowOverride All
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</directory>
</virtualhost>
Apache Webserver Restart
Let's restart Apache server and check if it restarted successfully.
.
Note: Configuring httpd-vhosts.conf is optional. You can place the php filesin httpdocs folder.
Testing PHP with Apache
In the previous step 3, we made directory structure, C:\server\www\apache.dev\public_html\. This is where you will be putting all your html and script files and our webserver will use those files.Let make a php file and name it index.php and put it inside the C:\server\www\apache.dev\public_html\ directory.
<?php phpinfo(); ?>
Then type http://localhost/index.php as URL for your browser. Then, you'll get the information about the PHP you've just installed.
Making Windows recognize http://www.apache.dev
This step is not necessary, but it's a nice feature to add. To make Windows recognize your domain on Apache webserver, we need to edit hosts file in C:\Windows\System32\drivers\etc directory.
Add the following two lines to the hosts file.
127.0.0.1 apache.dev
127.0.0.1 www.apache.dev
Then type in apache.dev or www.apache.dev as an URL, then you'll get the same php information as when you type in localhost as an URL.
No comments:
Post a Comment