Start and configuring Apache

Start and configuring Apache

March 11th, 2008 // 11:48 am @

{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:

 

  1. APACHE web server Download Link (2.2 Ver.)
  2. PHP (ZIP Package) Download Link (I strongly recommend PHP 5.2.17 | VC x86 Thread Safe)
  3. MYSQL   Download Link
  4. HeidiSQL(Free CP) Download Link
NOTE: Links above are directions to WINDOWS installation and binaries
NOTE: HeidiSQL is a FREE software that helps you administrate your MYSQL Back-end, you may use any program that you want
NOTE: Make sure the version of that software that you are downloading is stable (Google it not always latest ver is the best version)
OK, So now we have everything that we need to start this project, let me explain about how we will going to approach this target so it doesn’t make any confusion later;
  • 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.
Alright, so if you didn’t have any problem or error messages so far let’s continue to Part 1 and first step.

Setting up APACHE Serevr
APACHE is improving pretty much everyday and developers always trying to make it better, so usually when you install the APACHE installer it does everything for you so I’m just going to couple thing to make sure everything is up and running.
  1. 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
  2. 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
  3. You should see a page that reads “It works!”, Good you passed the step 1
Couple TIPs:
  • 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
Ok, We done this step too let’s go to the next step setting up PHP

 


 

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

short_open_tag = off
to
short_open_tag = on

 

#Magic quotes for incoming GET/POST/Cookie data.

magic_quotes_gpc = Off
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.

register_globals = Off
to
register_globals = on

 

#On a “live” website, you typically want errors in your script to be silently logged to a PHP error file.

display_errors = Off
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.
Ok, if you have everything ready and troubleshoot your error (if you had any) it’s time to move to the next step.

 

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

 

2. Restart the Apache one more time and it should be ready for MYSQL
3. Install HeidiMYSQL and open the program, set your credentials and click Open
  • 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)
Click Open you should see the pre-conf databases (Ex. mysql, performance_schema, information_schema)
Well I guess we are done if you finished this last step with success too I should congratulation and you have your Apache server with PHP and MYSQL connection up and running, Please do no hesitate to ask any question you might have in the comment box, and I’ll try to answer.
Arad

 


Category : Articles &Networks &Windows

2 Comments → “Start and configuring Apache”


  1. mercurial vapor

    4 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

      4 years ago

      Of course not. I am glad it was interesting enough.


On LinkedIn

LinkedIn

.

"I have no special talent.
I am only passionately
curious.
"
Albert Einstein

Subscribe Now