Start and configuring Apache
March 11th, 2008 // 11:48 am @ Arad Gharagozli
{jcomments on}It’s fun to have a server at your home PC or let say your personal computer, well some of you may ask why I need a personal host? well obviously having a host server at home is not something reliable and fast but well at least it’s there and you can use it when you need it as a File hosting server, Host your own domain or website, Host your own email service and or even just a test machine. in this Tutorial I want to start a server that is capable of reading .PHP files, storing and retrieving files from MYSQL Database and is publicly available on WWW.
Ok let’s get started, so make sure you have all following items ready before we proced:
- APACHE web server Download Link (2.2 Ver.)
- PHP (ZIP Package) Download Link (I strongly recommend PHP 5.2.17 | VC x86 Thread Safe)
- MYSQL Download Link
- HeidiSQL(Free CP) Download Link
- First of all we need to install the APACHE file and on our system make sure to add APACHE as a service.
- I strongly suggest that you download the ZIP pack instead of the MSI, it’s easier to use, Now Unzip the PHP pack that you got and extract it into “C:\php” folder. It’s your call to find a directory for PHP but just to make sure we are in the same page and everything will go smoothly let’s go with “C:\php”.
- Same story with MYSQL and HeidiSQL, just install it on the computer, we not going to use them now tho.
- Check your task bar you should the APACHE’s feather in your Icon tray, click on and make sure it’s green, if it’s not click START and if it didn’t work verify you did everything right
- Open your browser and type “localhost” or “127.0.0.1” loop-back IP address, if you using Google Chrome, make sure it’s not taking your address as a search query
- You should see a page that reads “It works!”, Good you passed the step 1
- If you want to access your host root folder go to APACHE’s installation folder and find “htdocs” by default it should be here “C:\Program Files\Apache Software Foundation\Apache2.2” . (Path will be different in 64bit OS)
- Under Apache folder, open “CONF”, There should be a file called “HTTPD.CONF”, you can open it but don’t change anything yet, it’s the configuration file for APACHE, we are going to use it a lot.
- Click on the Feather in your Icon tray, then click Open Services; That is a good tool too, you can start or stop APACHEs services tehre
Setting up and configuring PHP,
PHP usually is the main reason that people start APACHE server and it’s important to setup the initial to avoid any issues.
1.Browse the PHP folder and make a local copy of “php.ini recommended”
2.Rename “php.ini recommended” to “php.ini”
3.Open “php.ini” with notepad and make following changes:
# To allow the <? tag. Otherwise, only <?php and <script> tags are recognized
to
short_open_tag = on
#Magic quotes for incoming GET/POST/Cookie data.
to
magic_quotes_gpc = on
#A number of older scripts assume that all data sent by a form will automatically have a PHP variable of the same name.
to
register_globals = on
#On a “live” website, you typically want errors in your script to be silently logged to a PHP error file.
to
display_errors = on
#If you are going to use session in your PHP script you will need this too
;session.save_path = “/tmp”
to
session.save_path = “c:\tmp”
4. Locate the config file for APACHE, “httpds.conf” and open wilth notepad to edit
Add following lines according to your APACHE version, after the LoadModule section (After the last LoadModule line in conf file)
- Ver 1.X :
LoadModule php5_module “c:/php/php5apache.dll”
- Ver 2.0.X
LoadModule php5_module “c:/php/php5apache2.dll”
- Ver 2.2.X
LoadModule php5_module “c:/php/php5apache2_2.dll”
NOTE: Make sure you are using “/” instead of “\” while addressing PHP’s folder
5. Now find “AddType” section and add this line after the last one
AddType application/x-httpd-php .php
6.And the final step is to indicate the “php.ini” location for APACHE, You need to add this line into conf file, to make suure it goes well add it to thevery last line of the file
PHPIniDir “c:/php”
7.Now is the time to reset APACHE server and test PHP functionality, so Save httpd.conf and restart APACHE
8.After resting if everything was fine you will see Apache starts again but if you made a mistake it will give you an error message like this
” Error: The requested operation has failed ”
There are several reason you may get this error I’ll point to couple of them here:
- Go back to step 4 and make sure you used the correct line and dll address according to your Apache version
- Make sure you have the stable version of PHP, as I mentioned at the beginning of my tutorial I strongly suggest ( PHP 5.2.17 | VC x86 Thread Safe ) it’s really important to have the right version since this is the most common issue.
- If you using installer remove it and use ZIP package
- Make sure your paths are accurate
- Right click on Apache and run it as Administrator
- At the end, always check the Log folder under Apache folder. There are always useful information that you can troubleshoot your server easier.
Now it’s the time to setup our MYSQL database, find the file “php.ini” again and open with notepad and make following changes:
Installing MYSQL is easy too, just open the wizard and follow the prompts if you using MYSQL for developing and or home purposes only you don’t have to change anything but if you setting up MYSQL for something more advanced I strongly recommend that you find more specific article, so just follow the installation and choose the password and finalize the processes.
1. Find following lines and remove the “;” from the beginning so PHP can read these extensions
;extension=php_msql.dll
;extension=php_mssql.dll
;extension=php_mysql.dll
;extension=php_mysqli.dll
- Hostname/IP: “localhost” or “127.0.0.1”
- Username: root
- Password: As you set before
- Port: 3306 (Unless you have changed it during the installation)
mercurial vapor
10 years ago
mercurial vapor…
Do you mind if I quote a few of your articles as long as I provide credit and sources back to your blog? My blog site is in the very same area of interest as yours and my visitors would genuinely benefit from a lot of the information you provide here. …
Arad Gharagozli
10 years ago
Of course not. I am glad it was interesting enough.