Build your own Database Driven Website using PHP & MySQL - Part 1: Installation

I have problem with the Apache when i type the command LoadModule…php4apache2.dll and when i restart Apache it says: The reqested operation has failed!
why i cant load it?

ace,

The Apache error log may have additional information on why the error has failed.

Some things to check:

Is php4apache2.dll in the location you indicated in your httpd.conf file? Is it definitely named php4apache2.dll (if you’ve installed PHP 5, for example, it’s called php5apache2.dll). Are you running Apache 2, and not Apache 1.3? Have you copied php4ts.dll to your Windows SYSTEM32 directory?

On line 486 of httpd.conf the following error is referenced.
Connot load c:'php/php5apache2.dll into server: The specified module could not be found.

Before installing PHP I downloaded Apache 2.2, installed it and confirmed that it worked.

I then downloaded PHP 5.0 as instructed in the book starting on page 6. I then performed steps 1-5 from page 7 and top of page 8.

I then skipped pages 8-10 because my XP Professional does not have IIS.

I performed the steps 1-5 on page 11. Step 5 failed because Apache would not restart.

I disabled the last 3 statements in the httpd.conf file and was able to start Apache.

I am running on Windows XP on the HP Pavilion dv2040ca Notebook. The last 3 lines in the httpd.conf file are:

LoadModule php5_module c:/php/php5apache2.dll
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

I have confirmed that the file c:/php/php5apache2.dll does exist. Have I missed a reference to php5_module somewhere? Any assistance would be appreciated.

… Ralph

Ralph,

From the page numbers you’re quoting, it sounds like you don’t have a slightly older version of the book, perhaps the October 2004 reprint (the latest version was printed in June 2006). You can see which version you have on the credits page at the start of the book.

Assuming you’re working with the October 2004 edition, you may have missed a step in the installation of PHP 5 that was left out of that version, and is documented on the errata page for the book:

p.7 step 2
In PHP 5 or later, you must copy the libmysql.dll file from the PHP installation directory to your system32 directory along with php5ts.dll.

Let me know whether copying that file solves your problem or not. Hopefully it should get you going!

Thank you for the reply but…
I had used the online instructions that included the instruction of moving libmysql.dll to the Windows/system32 folder. The pdf file I used for follow up reference is the October 2004 version. In any event this is not the problem.

Without the PHP references, MySQL and Apache2.2 are operational. I re-installed PHP 5.2.3 (using zip file) from the PHP download site. I still have the error that the module cannot be loaded by Apache.

Do you have any other ideas?

… Ralph

Nothing leaps to mind. Can you confirm the exact revision of Apache you’re using (e.g. 2.2.4) so that I can run through the instructions on my end with the exact same versions to confirm that they work?

-Kev.

Kevin,

Yes, I have installed Apache 2.2.4.

Hi Ralph,

I’ve just gone through the setup process on my own system and I can confirm that something has indeed changed. With the release of Apache 2.2, you now need to point to the file php5apache2_2.dll (not php5apache2.dll) when editing your httpd.conf file.

Give this a try and let me know if it works for you.

Thanks. I made the change to php5apache2_2.dll and now I am operational. After doing the samples in the first 4 chapters I am now ready to buy the book. Thanks again… Ralph

I’m having this exact same problem. I’m on 10.3.9, however.

Has anyone figured this out yet?

Is the MySQL binary with in your path? On Mac I don’t know how to set it.
But perhapes if you run the command in the MySQL binary directory.

ThisHereComputer:/bin Pure L$ mysql -u root mysql
-bash: mysql: command not found

I’m no expert at this (quite a newbie, in fact) but, from what I can tell, it’s not working from /bin either.

I’m just starting to look at PHP/MySQL and I’ve tried the installation offered in the opening chapter of the Sitepoint book under XP Pro. All appears to be running but the last step to configure passwords for MySQL has thrown up a problem: I can’t seem to log onto the server.

Trying the ‘mysql -u root mysql’ command gives me “ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO)”. I’m going word-blind checking that I’ve not missed something in the configurations of the various components (MySQL 5.0.51b, PHP 5.2.6, Apache 2.2.9).

Can anyone shed some light as to what I’m missing?

Thanks

Hi ldp,

It sounds like you have successfully set up a root password on your MySQL server. To log in with that password, you need to add -p to the mysql command:

mysql -u root -p mysql

The -p tells MySQL that you wish to provide a password with your connection request.

Hi Kevin,

Thanks for the very quick response.

I sort of worked out that the server was wanting a password, but the problem was that I couldn’t remember setting one! I tried a number of usual suspects but no joy. When I tried the configuration wizard and wanted to see what happened when I tried the password setup there it was asking me again for the password…

Anyway, its a new day and determined to solve this one I have just embarked on installing MySQL on my notebook. I’m going through the configuration wizard and I get to the ‘Network Options’ and scrutinise the text of your book and begin to wonder whether I unchecked ‘Strict Mode’ previously as per instructions …?

Viola! I can get in. Sometimes you just have to walk away from a problem and do something else (i.e. sleep). I’m making an assumption that ‘Strict Mode’ has a bearing on security/passwords. Is this true?

Anyway thanks for confirming my suspicions, and focusing my attention. On with the rest of the book …

L :slight_smile:

Hi Kevin,
How do I type commands into a bin directory. WHy I type mysql -u root mysql" I get “command not found”

If MySQL is installed in /usr/local/mysql, then the bin directory is /usr/local/mysql/bin. So you must first switch to that directory:

cd /usr/local/mysql/bin

…and then type the command:

mysql -u root mysql

If that still doesn’t work, try being explicit about telling it to run the command in the current directory:

./mysql -u root mysql

I’ve tried for about two or three days now to figure this out on my own but I’m not having any luck.

I’m following the individual installation steps and I am getting caught up trying to reach the localhost in my browser after installing MySQL and Apache. The “It Works” page is not happening for me.

I made sure I apache was running. I just keep getting the “Failed to Connect” screen. I decided I would go ahead and move on to install PHP. Well the second steps says to locate the php.ini-dist file to make a copy of it. This file is nowhere to be found for me.

I’m really sorry to ask for help… I’d just like to get these things installed so I can learn to build better sites.

Thanks in advance!

Hi sdavids,

I’ll do my best to help, but I need some more information first:

Are you installing on Windows, Mac or Linux? Is it possible Apache was installed to run on port 8080 (in which case you should be trying the address http://localhost:8080 instead of just http://localhost).

Well the second steps says to locate the php.ini-dist file to make a copy of it. This file is nowhere to be found for me.

That’s very odd. What files are present in the directory where you extracted the PHP distribution’s ZIP file?

Hi Kevin,

Installing PHP you write:

choose the PHP 5.2.x zip package under Windows Binaries; avoid the installer version.

but under PHP 5.3 there appears to be 4 versions

VC9 x86 Non Thread Safe
VC9 x86 Thread Safe
VC6 x86 Non Thread Safe
VC6 x86 Thread Safe

I will be using Apache on a 32 bit machine so which do you recommend?

Thanks

PS I think I need a VC6 version, but which one?