Configuring Apache, PHP and MySQL
There are many articles on the web detailing the installation of Apache, PHP and MySQL, so why another post adding to already muddled space. Rightly so, However, I faced lot of issues while going through the process of the installation of the said software. I also needed to setup some PHP extensions which was not clear in any of the tutorials. This is precisely the reason why this article finds its way into the web.
Now Coming to the task at hand, first I will detail the installation of these components all by yourself on windows system. After you are done with all the steps, I will tell you about two packages which I came across while going through the installation process. These packages will simplify all the effort needed above. If you are a developer/administrator, I strongly suggest you to go through the installation process and then look into these packages.
The software used and there versions are:
i) Apache HttpServer 2.0.59
ii) PHP 5.2.0
iii) MySQL 5.0.27
iv) phpMyAdmin 2.9.2
Apache: Get the windows installer for the specified version from Apache. Then you have an excellent tutorial "How to install apache on windows" at evaria. Please follow the steps as indicated at that post.
PHP: Get the "zip package"version from PHP(under windows binaries). I was not very happy using the windows installer version as it does not do what it say it will(if you are curious you can explore it, else mail me). Now we are back to evaria, go to this tutorial "How to install php5 on windows" and follow the steps as mentioned. However, instead of php5 as the directory create "c:\php" as the directory. Once the php configuration is done, configure the Apache web server as mentioned in the same tutorial.
All the while remember that you are using the directory path "c:\php" and the tutorial mentions it as "c:\php5". If you need to install any php extensions follow the steps provided over here at PHP installation of extensions on windows. Once this is done major part of the installation for a general user is done. I will discuss the other part at a later stage in the post.
MySQL: Get MySQL Community server version as mentioned above from here. We are back to evaria, go to the tutorial "How to install MySQL 5.0.x on windows" and follow the steps given over there. When you come to the third part "Getting PHP to work with MySQL" you will see the following paragraph.
"Unfortunately PHP5 removed built-in support for mySQL. So you´ll need to copy some files by hand. open the folder you unzipped your PHP to. Copy the libmysql.dll file (should be located like c:\php5\libmysql.dll ) into your Window´s System folder (usually C:\Windows\System32\ although might be c:\WinNT\System\ or something). "
Instead of doing as above, follow this last step in the same section.
" If you don´t want to move files outside your php5(in this case "c:\php") directory, you may also add the php5 directory to the PATH on Windows. Please read the following article on how to do this."
Rest of the steps in this stage are as mentioned in the tutorial.
phpMyAdmin: phpMyAdmin is a browser based support for php and mysql. Get alllanguages.zip
for the latest version from its download page. Once you get this extract the files to phpMyAdmin to httdocs in the Apache folder (c:\Apache2\httdocs). Open the browser and goto "http://localhost/phpMyAdmin" and you are ready to configure your MySQL database server.
In most cases it ends here, pretty straight forward after a few googles. However, in my case I also needed to enable soap extensions in php and install PEAR support for php. These seemingly innocuous things proved a thorn. At last I could nail it after more than half a day of effort.
php soap extensions: Check out the following pdf. It nicely describes way to install the soap extensions (You will feel, Oh! why did I not get this earlier?).
PEAR: PEAR stands for Php Extension and Application Repository. Installing PEAR is a tricky part. Most of the google searches will ask you to run go-pear.bat file in the php directory. Do run it and check why I say it is the tricky part. It just does not help. So what do you do? Follow me.
Under Getting Manager (Windows) in PEAR installation manual you will find the correct steps to install. In summary save the following link "http://go-pear.org/" as go-pear.php, into the php5 folder ("c:\php5"). Goto the command prompt and execute the following at the prompt "php.exe go-pear.php", follow the instructions that are displayed. After a few instructions you are done with PEAR installation. If you think it is done, no it's not. We have one more thing to do. Go to the file php.ini in "c:\php", search for include_path and add "c:\php\pear" as one of the paths.
In the introduction to this post I said I will be introducing you to two packages which does the above job in a very admirable fashion. These are wamp and Xampp. Please go through the websites for both of them to learn more about them. I tried out both and should my vote goes for Xampp. The issue with wamp is though it install the individual softwares, it is to the user to configure them, also it does not install pear. I just need to download Xampp for windows and download the installer version. Follow the installation steps and voila!! it does all the above things and much more in 1/nth time of what it took you in the first case.
Ah! Finally we are done with the installation of Apache, PHP with PEAR, MySQL, phpMyAdmin. Now go ahead and play.
Now Coming to the task at hand, first I will detail the installation of these components all by yourself on windows system. After you are done with all the steps, I will tell you about two packages which I came across while going through the installation process. These packages will simplify all the effort needed above. If you are a developer/administrator, I strongly suggest you to go through the installation process and then look into these packages.
The software used and there versions are:
i) Apache HttpServer 2.0.59
ii) PHP 5.2.0
iii) MySQL 5.0.27
iv) phpMyAdmin 2.9.2
Apache: Get the windows installer for the specified version from Apache. Then you have an excellent tutorial "How to install apache on windows" at evaria. Please follow the steps as indicated at that post.
PHP: Get the "zip package"version from PHP(under windows binaries). I was not very happy using the windows installer version as it does not do what it say it will(if you are curious you can explore it, else mail me). Now we are back to evaria, go to this tutorial "How to install php5 on windows" and follow the steps as mentioned. However, instead of php5 as the directory create "c:\php" as the directory. Once the php configuration is done, configure the Apache web server as mentioned in the same tutorial.
All the while remember that you are using the directory path "c:\php" and the tutorial mentions it as "c:\php5". If you need to install any php extensions follow the steps provided over here at PHP installation of extensions on windows. Once this is done major part of the installation for a general user is done. I will discuss the other part at a later stage in the post.
MySQL: Get MySQL Community server version as mentioned above from here. We are back to evaria, go to the tutorial "How to install MySQL 5.0.x on windows" and follow the steps given over there. When you come to the third part "Getting PHP to work with MySQL" you will see the following paragraph.
"Unfortunately PHP5 removed built-in support for mySQL. So you´ll need to copy some files by hand. open the folder you unzipped your PHP to. Copy the libmysql.dll file (should be located like c:\php5\libmysql.dll ) into your Window´s System folder (usually C:\Windows\System32\ although might be c:\WinNT\System\ or something). "
Instead of doing as above, follow this last step in the same section.
" If you don´t want to move files outside your php5(in this case "c:\php") directory, you may also add the php5 directory to the PATH on Windows. Please read the following article on how to do this."
Rest of the steps in this stage are as mentioned in the tutorial.
phpMyAdmin: phpMyAdmin is a browser based support for php and mysql. Get alllanguages.zip
for the latest version from its download page. Once you get this extract the files to phpMyAdmin to httdocs in the Apache folder (c:\Apache2\httdocs). Open the browser and goto "http://localhost/phpMyAdmin" and you are ready to configure your MySQL database server.
In most cases it ends here, pretty straight forward after a few googles. However, in my case I also needed to enable soap extensions in php and install PEAR support for php. These seemingly innocuous things proved a thorn. At last I could nail it after more than half a day of effort.
php soap extensions: Check out the following pdf. It nicely describes way to install the soap extensions (You will feel, Oh! why did I not get this earlier?).
PEAR: PEAR stands for Php Extension and Application Repository. Installing PEAR is a tricky part. Most of the google searches will ask you to run go-pear.bat file in the php directory. Do run it and check why I say it is the tricky part. It just does not help. So what do you do? Follow me.
Under Getting Manager (Windows) in PEAR installation manual you will find the correct steps to install. In summary save the following link "http://go-pear.org/" as go-pear.php, into the php5 folder ("c:\php5"). Goto the command prompt and execute the following at the prompt "php.exe go-pear.php", follow the instructions that are displayed. After a few instructions you are done with PEAR installation. If you think it is done, no it's not. We have one more thing to do. Go to the file php.ini in "c:\php", search for include_path and add "c:\php\pear" as one of the paths.
In the introduction to this post I said I will be introducing you to two packages which does the above job in a very admirable fashion. These are wamp and Xampp. Please go through the websites for both of them to learn more about them. I tried out both and should my vote goes for Xampp. The issue with wamp is though it install the individual softwares, it is to the user to configure them, also it does not install pear. I just need to download Xampp for windows and download the installer version. Follow the installation steps and voila!! it does all the above things and much more in 1/nth time of what it took you in the first case.
Ah! Finally we are done with the installation of Apache, PHP with PEAR, MySQL, phpMyAdmin. Now go ahead and play.
Read more!