How I Installed PHP 5_2_5 on Apache 2_0_48 on WinXP
On February 10th I received an email from my hosting company that they are upgrading PHP to version 5. They will upgrade PHP with suPHP support which will improve security.
This was good news, because I wanted to use Object Oriented PHP programing. Of course you can make classes and objects with PHP v4 but not whole object paradigm is supported and PHP v5 should improve that.
Then I started looking in my software collection for some v5 PHP and I found PHP 5.0.0b4. I didn't like it because it was very early version so I went to PHP.net and downloaded PHP 5.2.5.
Everything I know about installing and configuring PHP, MySQL and Apache I learned from SitePoint's Kevin Yank's book about PHP&MySQL. Also Kevin in that book said that PHP installer should be avoided if possible. I forgot that detail and of course downloaded installer version.
At that time I had installed PHP 4.3.4, MySQL 4.0.18 and Apache 1.3.23. I was thinking that best way is to have fresh installations of everything, so I deleted all installations.
Then I installed MySQL 4.0.18. There are installations steps in Kevin's book but I will write them here.
First you need to create my.cnf file in root of c drive. That file should contain this :
[mysqld]
basedir = PATH_TO_MYSQL_INSTALLATION_DIR/
datadir = PATH_TO_MYSQL_INSTALLATION_DIR/data
Then you need to install MySQL as system service, this can be done from command line: ( if you installed MySQL in C:\mysql )
C:\mysql\bin\>mysqld-nt --install
You will get this message if service was installed successfully.
Service successfully installed.
MySQL as service will be started after reboot, but you can start it manually like this :
C:\>net start mysql
If everything goes well you will get these messages :
The MySQL service is starting.
The MySQL service was started successfully.
After installation I configured MySQL, actually I set password for user ROOT and remove privileges that anonymous users have. This is done with these commands :
C:\mysql\bin\>mysql -u root mysql
mysql>UPDATE mysql.user SET Password=PASSWORD("new password") WHERE User="root";
Query OK, 2 rows affected (0.12 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql>FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.24 sec)
Then I installed Apache 1.3.23. Installation is quick and easy. Configuration is more complex but if you want to configure something to work like you want than you need to know more. Apache configuration is changed by editing httpd.conf file and then restarting Apache.
I wonted to change document root to D:\Web instead of Apache default setting C:\Program Files\Apache Group\Apache\htdocs. This is done by setting two things:
DocumentRoot "D:/Web"
and
<Directory "D:/Web">
Also I want to use mod_rewrite. To enable this you need to uncomment this line :
#LoadModule rewrite_module modules/mod_rewrite.so
and
AllowOverride must have All or Option value.
Then I installed PHP 5.2.5. When using installer you just follow wizard, and select which server you are using and then point to servers configuration directory so PHP could configure it self and server.
After installation of PHP my problems started. First Apache would not restart. I checked Apache configuration with Test Configuration tool and it said that PHPIniDir is not recognized. PHPIniDir is used to show Apache where php.ini file is placed, so there is no need to place php.ini in c:\Windows, like in older versions of PHP. But since Apache 1.3.23 could not read that directive I placed php.ini in c:\Windows but then Apache would not start. Nasty problem, wright?
Then I tried something else, I installed Apache 2.0.48, configured it like I wanted and installed PHP 5.2.5 again. Apache restarted and it was showing this
Apache/2.0.48 (Win32) PHP/5.2.5 Server at localhost Port 80 when I typed http://localhost in browser. It looked like every thing is OK, but it was not.
When I tried to open PHP pages I got blank browser screen and source was blank too. Then I checked if Apache was configured to process PHP files. This can be checked by looking at DirectoryIndex in httpd.conf file. DirectoryIndex must contain index.php. Also PHP installer adds these lines to the end of httpd.conf file
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
When I verified that PHP files are enabled I did not know why Apache won't process PHP pages.
I knew that alone I will not find solution so I posted my problem on SitePoint's Forum. While I was waiting for responses I tried one more thing. I mentioned that I have PHP 5.0.0b4 so I installed that version, and to my surprise everything worked well. MySQL extension and c.U.R.L extension and GD2 worked fine, but only to first restart and then MySQL extension was not found, but c.U.R.L worked fine!?
First few responses that I received point out that I should check configuration, especially path to php5apache2.dll that is needed to install PHP as Apache module. But path was correct and also dll version was correct.
In one response author pointed that for development it is easier to use WAMP. WAMP is short for Windows, Apache, MySQL and PHP. It is application that installs and configures Apache, MySQL and PHP on Windows and it is possible to use multiple versions and to switch between them on the fly. I actually started thinking that using WAMP is better solution, then installing and configuring everything separately.
Most help and support on SitePoint forum I got from DK, he is Mentor at SitePoint forums and Apache Guru for 2007. At first he did not believe me that all configuration was OK and that there were no errors in path or names of files. But I convince him that I done everything by the book (in this case Kevin Yank's book). And then he started thinking in different way, he asked me did I use installer or zipped files and gave me links to install manual on php.net for installation with installer.
There was described installation with php installer and everything that was written in that description I have done, but still no positive results. Also there were users contributions and I did read them but I noticed that most of them are related to installing PHP with IIS, so I thought that they can not help me, since I am trying to install php on Apache.
I was ready to give up and to use WAMP, but DK was not :)
He point me to two user contributions on that installation manual page. First one was about adding system variable PHRC with path to the install directory of php. I followed the instructions and do you know what happened? PHP files were processed.
You would think that my problems were over, but NOOOOO, now MySQL extension was not found. I checked with phpinfo() function and I saw that MySQL extension was not loaded. This one I solved myself. I simply reinstalled MySQL and since then every thing is working just fine.
I know that this post is long, but my troubles with installing PHP 5 were longer, I was working on this for 4 days, and installed and reinstalled everything for about 20 times.
What should I say after all this, only :
You learn something new every day
( or in my case : ..every 4 days :)
This was good news, because I wanted to use Object Oriented PHP programing. Of course you can make classes and objects with PHP v4 but not whole object paradigm is supported and PHP v5 should improve that.
Then I started looking in my software collection for some v5 PHP and I found PHP 5.0.0b4. I didn't like it because it was very early version so I went to PHP.net and downloaded PHP 5.2.5.
Everything I know about installing and configuring PHP, MySQL and Apache I learned from SitePoint's Kevin Yank's book about PHP&MySQL. Also Kevin in that book said that PHP installer should be avoided if possible. I forgot that detail and of course downloaded installer version.
At that time I had installed PHP 4.3.4, MySQL 4.0.18 and Apache 1.3.23. I was thinking that best way is to have fresh installations of everything, so I deleted all installations.
Then I installed MySQL 4.0.18. There are installations steps in Kevin's book but I will write them here.
First you need to create my.cnf file in root of c drive. That file should contain this :
[mysqld]
basedir = PATH_TO_MYSQL_INSTALLATION_DIR/
datadir = PATH_TO_MYSQL_INSTALLATION_DIR/data
Then you need to install MySQL as system service, this can be done from command line: ( if you installed MySQL in C:\mysql )
C:\mysql\bin\>mysqld-nt --install
You will get this message if service was installed successfully.
Service successfully installed.
MySQL as service will be started after reboot, but you can start it manually like this :
C:\>net start mysql
If everything goes well you will get these messages :
The MySQL service is starting.
The MySQL service was started successfully.
After installation I configured MySQL, actually I set password for user ROOT and remove privileges that anonymous users have. This is done with these commands :
C:\mysql\bin\>mysql -u root mysql
mysql>UPDATE mysql.user SET Password=PASSWORD("new password") WHERE User="root";
Query OK, 2 rows affected (0.12 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql>FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.24 sec)
Then I installed Apache 1.3.23. Installation is quick and easy. Configuration is more complex but if you want to configure something to work like you want than you need to know more. Apache configuration is changed by editing httpd.conf file and then restarting Apache.
I wonted to change document root to D:\Web instead of Apache default setting C:\Program Files\Apache Group\Apache\htdocs. This is done by setting two things:
DocumentRoot "D:/Web"
and
<Directory "D:/Web">
Also I want to use mod_rewrite. To enable this you need to uncomment this line :
#LoadModule rewrite_module modules/mod_rewrite.so
and
AllowOverride must have All or Option value.
Then I installed PHP 5.2.5. When using installer you just follow wizard, and select which server you are using and then point to servers configuration directory so PHP could configure it self and server.
After installation of PHP my problems started. First Apache would not restart. I checked Apache configuration with Test Configuration tool and it said that PHPIniDir is not recognized. PHPIniDir is used to show Apache where php.ini file is placed, so there is no need to place php.ini in c:\Windows, like in older versions of PHP. But since Apache 1.3.23 could not read that directive I placed php.ini in c:\Windows but then Apache would not start. Nasty problem, wright?
Then I tried something else, I installed Apache 2.0.48, configured it like I wanted and installed PHP 5.2.5 again. Apache restarted and it was showing this
Apache/2.0.48 (Win32) PHP/5.2.5 Server at localhost Port 80 when I typed http://localhost in browser. It looked like every thing is OK, but it was not.
When I tried to open PHP pages I got blank browser screen and source was blank too. Then I checked if Apache was configured to process PHP files. This can be checked by looking at DirectoryIndex in httpd.conf file. DirectoryIndex must contain index.php. Also PHP installer adds these lines to the end of httpd.conf file
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
When I verified that PHP files are enabled I did not know why Apache won't process PHP pages.
I knew that alone I will not find solution so I posted my problem on SitePoint's Forum. While I was waiting for responses I tried one more thing. I mentioned that I have PHP 5.0.0b4 so I installed that version, and to my surprise everything worked well. MySQL extension and c.U.R.L extension and GD2 worked fine, but only to first restart and then MySQL extension was not found, but c.U.R.L worked fine!?
First few responses that I received point out that I should check configuration, especially path to php5apache2.dll that is needed to install PHP as Apache module. But path was correct and also dll version was correct.
In one response author pointed that for development it is easier to use WAMP. WAMP is short for Windows, Apache, MySQL and PHP. It is application that installs and configures Apache, MySQL and PHP on Windows and it is possible to use multiple versions and to switch between them on the fly. I actually started thinking that using WAMP is better solution, then installing and configuring everything separately.
Most help and support on SitePoint forum I got from DK, he is Mentor at SitePoint forums and Apache Guru for 2007. At first he did not believe me that all configuration was OK and that there were no errors in path or names of files. But I convince him that I done everything by the book (in this case Kevin Yank's book). And then he started thinking in different way, he asked me did I use installer or zipped files and gave me links to install manual on php.net for installation with installer.
There was described installation with php installer and everything that was written in that description I have done, but still no positive results. Also there were users contributions and I did read them but I noticed that most of them are related to installing PHP with IIS, so I thought that they can not help me, since I am trying to install php on Apache.
I was ready to give up and to use WAMP, but DK was not :)
He point me to two user contributions on that installation manual page. First one was about adding system variable PHRC with path to the install directory of php. I followed the instructions and do you know what happened? PHP files were processed.
You would think that my problems were over, but NOOOOO, now MySQL extension was not found. I checked with phpinfo() function and I saw that MySQL extension was not loaded. This one I solved myself. I simply reinstalled MySQL and since then every thing is working just fine.
I know that this post is long, but my troubles with installing PHP 5 were longer, I was working on this for 4 days, and installed and reinstalled everything for about 20 times.
What should I say after all this, only :
You learn something new every day
( or in my case : ..every 4 days :)




2008-02-19
.sql 
YOU said