Jump to content

Archived

This topic is now archived and is closed to further replies.

SusieWoosey

making apache server work

Recommended Posts

I want to run a local PHP so I can edit my .php files without having to upload to my website all the time.

MYsql would be nice too, but first things first.

Do I need Apache server on my PC for PHP and MYsql to run? How do I tell my PC that PHP is there, so I can see .php files on my PC, without resorting to uploading them to my webspace?


Appreciate any help.


Suzanne    (sallyjowoods@hotmail.com)




Share this post


Link to post
Share on other sites
Yes you need to install Apache to run your PHP scripts on your PC locally. MySQL doesn't need Apache. MySQL is database server. Apache is a web server.

Installing Apache is rather easy. Make sure you download the msi package and download Apache2.0.x (don't download Apache2.2.x). When you run the Apache installer it'll ask you for a couple of details which are Network Domain ,Server Name and Administrator's Email Address

For the Network Domain and Server Name just enter localhost into the two boxes. Then just add a false email addy into the Admins Email Address eg (admin@localhost). When it ask you where to install Apache to, install it in the root of your hard drive in a folder called server, so click the browse button when it asks for installation directory, type in C:\server, the server folder will be created if it doesn't exists, also change C: to the letter of your hard drive. Now go through the rest of the installation process.

Once Apache is installed, fire up a web browser and type in http://localhost or http://127.0.0.1

The above addresses are local addresses, that only you can access. No one from the web/out side of your network can access those addresses. You should get the Apache welcome message when you go to either of the above addresses.

Now to install PHP, you'll need to go to php.net and download PHP5. Make sure you download the zipped binaries and NOT the INSTALLER. Once you have downloaded PHP. Extract the contents of the zip file to C:\server\PHP\

Once you have extracted the contents of the ZIP. PHP is installed! However you must now configure Apache to parse any PHP files with the PHP Interpreter. To do so go to C:\server\Apache2\conf and open up httpd.conf for editing.

Now look for the following:
[code]#LoadModule ssl_module modules/mod_ssl.so[/code]
Add the following after the above:
[code]LoadModule php5_module "C:/server/php/php5apache2.dll"

#PHPIniDir
PHPIniDir "C:/WINDOWS"[/code]
Now scroll down further to find the following:
[code]AddType application/x-gzip .gz .tgz[/code]
Now add the following after the above:
[code]AddType application/x-httpd-php .php[/code]

Save the httpd.conf file! What you need to do now is go to C:\server\php and find the following files:
libmysql.dll
php5ts.dll
php.ini-recommended

Copy the above three files to the WINDOWS folder (C:WINDOWS\). Once you have done so. Rename php.ini-recommended to just php.ini

Now you have setup Apache to parse the PHP files with the PHP Interpreter. All you need to do now is restart Apache. To do so go to Start > Program Files > Apache HTTP Server 2.0.x > Control Apache Server > Restart

If everything goes to plan. Apache should restart without any beeps/errors popping up. If no beeps/errors come up then Apache and PHP are installed. To test go to C:\server\Apache2\htdocs\ create a new file called test.php, edit this new file and add the following code to it:
[code=php:0]<?php
phpinfo();
?>[/code]

Save test.php. Now open up your browser again and go to http://localhost/test.php

When you go to that address you should get a page full of information about PHP and your server. If you do then Apache and PHP are successfully installed.

All you need to do now is install MySQL, which is easy as its just a step through installer. Make sure when you go to install MySQL you install it in the server folder (NOTE: You'll need to choose the custom install option to do this).

When MySQL is installed you'll need to enable the MySQL extension for PHP to use in order for you to use PHP with MySQL. You can do this by reading [url=http://www.phpfreaks.com/forums/index.php/topic,95378.0.html]this thread[/url].

Hope that helps.

Share this post


Link to post
Share on other sites
Thanks for the help wildteen, I had already downloaded PHP 4.xxxxx so I shall have to go look for php5. Since posting I have been able to get Apache to run without giving me errors, so I must be doing something right.


Will look for php5, and out your help into practice.

Will let you know how I get on.


Thanks for replying

Suzanne.

Share this post


Link to post
Share on other sites
PHP4 is okay. Its up to which version of PHP to start of with. if you use PHP4 you just need to adapt the Apache configuration slightly.

Share this post


Link to post
Share on other sites
Hi wildteen,

Not sure if you'll read this, it's been a while since my first posting, I've been hopistalised since then, so not done much PC work.

Today (21st October) I successfully installed Apache 2.0.59 and PHP5.1.6

Thanks for your help, it went smoothly except for notepad naming my testfile as test.php.txt it took me a while to figure that out :D

Now for MySQL.


Thanks for your help.



SusieWoosey

Share this post


Link to post
Share on other sites
MySQL is easy to install just download the installer from mysql.com and follow the onscreen instructions.

Share this post


Link to post
Share on other sites
Hmm, well I guess my euphoria was short lived.

Seems today it now won't/doesn't want to work.

I get this error when I try to start it - Only one usage of each socket address (protocol/network address/port) is normally permitted. : make_sock could not bind to address 0.0.0.0:80 no listening sockets available.


What have I done wrong or what have I not done?

Any ideas?


Suzanne.

Share this post


Link to post
Share on other sites
Whats repoting that error? Apache? If its MYSQL it should be running on port 3306. POrt 80 can only be used once. It cannot  be shared with other TCP/IP apps.

Share this post


Link to post
Share on other sites
I think it's Apache. It appears to only do it when I close Apache Server down, and restart it. (I think). Anyway Apache seems to be OK now, I get good local .php pages, so my objective of seeing them before committing them to a live website has been achieved.


I've installed MySQL, all seems OK. I cannot use it from that command line client though. Suggestions?



Suzanne

Share this post


Link to post
Share on other sites
To use MYSQL via commad line you need to change directory to the MySQL bin directory. You do something like this:
[code]cd C:\mysql\bin\[/code]

Then you can type mysql -u root and it should log you in to MySQL. If its doesnt then you'll need to add the -p paramter to it and then provide the password for the root user. If you dont get any think from the command  then make sure MySQL is running, check your processes (Ctrl+Alt+Del click processes tab).

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.