Forum Moderators: phranque

Message Too Old, No Replies

Configuring Apache with PHP

         

stod

7:52 pm on Feb 23, 2011 (gmt 0)

10+ Year Member



Can anyone help me please? I am trying to build an Apache server on a Windows 7 Pro (64 bit) system and am having some problems configuring it to work with MySQL and PHP.

I have previous used Apache 1.3 with MySQL and PHP on a Windows XP system with no problems.

For the Windows 7 system I have used the files
httpd-2.2.17-win32-x86-no_ssl.msi for the apache file
mysql-essential-4.1.11-win32.msi for MySQL
php-5.3.5-nts-Win32-VC6-x86.zip for PHP

and installed Apache in c:\apache, MySQL in c:\mysql and php in c:\php.

I have followed the instructions in [thesitewizard.com...] to configure apache for php5.

As php5apache2_2.dll was not part of the php release I downloaded a copy of this from
[kromann.info...]


I followed the instructions on this web site and added the command

LoadModule php5_module "c:/php/php5apache2_2.dll"


to the file httpd.conf

I've tried both with the quotation marks and without. However, in both cases, on rebooting the system, Apache fails to start (automatically or manually) and checking the Event Log tells me that "there is an incorrect function".

When I remove this line from httpd.conf and reboot then the Apache Service starts automatically.

I can open a browser and type
http://localhost
and get the correct display "it works".

However, when I run the file phpinfo.php it simply displays the contents of this file.

phpinfo.php is......

<?php phpinfo(); ?>



when I run the file mysqltest.php it simply dispalys the line "ok loaded"

mysqltest.php is .....


<html>

<head>
<title>MySQL Connection Test</title>
</head>

<body>
<p>ok loaded </p>
<h2>
<?php
$user = "root";
$conn = mysql_connect( "localhost", $user, "rpjjslne" )
or die( "Sorry - unable to connect to MySQL" );
echo( "Congratulations - you connected to MySQL" );
?>
</h2>
</body>
</html>




So, can anyone please advise me what I am doing wrong and how to correct it please?

coopster

8:01 pm on Feb 24, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



php-5.3.5-nts-Win32-VC6-x86.zip for PHP


Try using the thread-safe version instead. It's the reason you couldn't find this in the first place:

As php5apache2_2.dll was not part of the php release I downloaded a copy of this from


The thread-safe version will have it as part of the distribution. Dump your other downloaded copy and use the one in the thread-safe distro. If by chance it is not in the msi (installer) option then something is amiss, grap a copy of the zip and use that instead.

stod

10:05 pm on Feb 24, 2011 (gmt 0)

10+ Year Member



Thanks very much coopster. Yes, the thread-safe version worked. Apache service now starts on booting system. I'm now struggling however to get php to work.

Have taken the php.ini-development file from the php folder and copied it to c:\windows and renamed it php.ini.

I have then amended the two lines...

doc_root = "c:\apache\htdocs"

extension_dir = "c:\php\ext"

to reflect where I have installed my files.

I have also added the line

extension = "php_mysql.dll"

I have also copied the file php_mysql.dll from c:\php\ext to c:\windows\system and to c:\windows\system32.

However, I still get the same results running phpinfo.php and mysqltest.php.

Can you help me please or can anyone tell me what I am doing wrong please?

coopster

10:21 pm on Feb 24, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I meant the thread-safe version of PHP from the PHP Windows download page:

[windows.php.net...]

If that is the file you used, great! Next, you need to copy one the development.ini file as you mentioned, and make your updates. Excellent there too. However, no need to be copying files into your Windows system directories. That is the part you are missing. You can tell PHP where all that is located with an Apache directive. See this page for details:

[php.net...]

stod

8:36 am on Feb 25, 2011 (gmt 0)

10+ Year Member



Thanks coopster. Yes I used the thread safe version. The link to php.net was useful reading. Thank ypou also to leosghost for the PM. Have printed everything and will study this evening and try again. Will keep you posted but in the meantime, thank you.

stod

10:58 pm on Mar 2, 2011 (gmt 0)

10+ Year Member



Thank you coopster and (through PM) leosghost. It's taken a while to sort everything but it now all works. So, for anyone wishing to learn from my experinces here is a summary (warts and all).

System is Windows 7 Professional 64 bit.
Apache file used is httpd-2.2.17-win32-x86-no_ssl.msi
MySQL file used is mysql-5.5.9-winx64.msi
PHP file used is php-5.2.17-Win32-VC6-x86.zip

Created folders C:\apache, c:\php and c:\mysql.

Installed Apache choosing to install in c:\apache. At the end of installation errors were reported in the Dos window. However, rebooted system and checked Services (Control Panel - System and security - Administrative Tools - Services) to confirm that Apache had started. Opened browser and entered

http://localhost

to confirm that an Apache Service was working.

Installed MySQL choosing c:\mysql in which to install files. Then ran the configuration wizard. Chose the detailed configuration - developer machine - multifunctional database - no chnage to InnodB - Decision Supoport - enable TCP/IP and enabled the firewall for port 3306 and opted to install a BIN folder and set a password for the database. On executing there was an error due to port 3306. I tried switching the Antivirus firewall off but this did not change the outcome. Rebooted the system.

Both Apache and MySQL services started. Copied my.ini from c:\mysql to c:\ and rebooted the system.

Switched off the antivirus firewall and ran the MySQL configuration wizard again opting fro detaield configuration and the reconfiguration option. Decided this time not to opt to set up the firewall for port 3306.

Rebooted the system. Apache and MySQL service staretd okay and still had confirmation that the Apache Service was working when I entered
http://localhost
into the browser.

Installed PHP unzipping the files into c:\php.

Amended the file httpd.conf found in c:\apache\conf as follows:

at the end of the section with LoadModule I added the following two lines (note forward slashes)


LoadModule php5module "c:/php/php5apache2_2.dll"
AddHandler application/x-httpd-php .php

at the end of the file I added the following line (note the final forward slash)

PHPIniDir "c:/php/"

Then copied php.ini-recommended (found in c:\php) to php.ini (in c:\php).
Amended php.ini as follows.

Ensured that there were the following two lines:

doc_root = "c:\apache\htdocs"
extension_dir = "c:\php\ext"

and removed the semicolon (comment) from the following two lines

extension = mysql.dll
extension = mysqli.dll


Saved the file (in c:\php) and then copied it to c:\apache\bin as well.

Rebooted the system. Apache and MySQL service started.

Opened browser and confirmed Apache Service with

http://localhost

Confirmed PHP with

http://localhost/phpinfo.php

Confirmed MySQL with

http://localhost/mysqltest.php

Hope that this is helpful. Thank you for your help.

coopster

11:18 pm on Mar 2, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Nice job :)

kingster

11:47 pm on Mar 2, 2011 (gmt 0)

10+ Year Member



While it may not be what the DIY kind of person wants... I heartily recommend (for local "lab" environments, especially) WAMP... You can get it here: [wampserver.com...]

It even gives you a nice little tray icon.

That said, if you're doing it on a true server, I'd likely not go this route.

All that said, congrats on getting it going.