View: 4350|Reply: 10
|
Step-by-Step: Installing Apache 2.0.35 for Windows
[Copy link]
|
|
Changing the document directory
Here we'll cover some basics on configuring Apache. Apache is configured by a very large file called "httpd.conf". In this file are the instructions for how Apache behaves. Much of the file are comments which are not processed by the server. All lines with comments start with the pound symbol "#". The lines that actually take effect do not have the pound symbol at the beginning. The comments give you a good idea of what each line in the configuration file does. It may be a good idea to just print out the whole "httpd.conf" file and study it and all the different parts.
Take a look at your "Start" menu. Apache is now setup there.
First let's cover where you'll put your documents so that people can see them from the Internet. To do this we'll look in the "httpd.conf Configuration file". Go to "Start" --> "Programs" --> "Apache HTTP Server 2.0.35" --> "Configure Apache Server" --> "Edit the httpd.conf Configuration file".
A text file called "httpd.conf" pops up.
Use the "Find" function of notepad to search for "DocumentRoot". You'll see this.
By default, all web documents will be stored in "C:/Program Files/Apache Group/Apache2/htdocs". Let's test this out by creating a small file called "index.html" with the message "hello cruel world!" and putting it into this directory. The reason we called it "index.html" is because that's the default document type for Apache. When Apache finds a "index.html" file in a directory, it know to display this file first. Go to your web browser again and type in either "http://localhost" or "http://127.0.0.1". You should see our message.
Now, you can either keep this directory for all your web files, but personally I would change it to something in a less buried directory like "C:\webdocs" or something like that. It's up to you. All you have to do is change the path in the config file. To illustrate, take a look at the picture where I changed the Document Root to "C:\webdocs". Easy.
When you close the window with the configuration file with your changes, you'll see this message asking if you want to save your changes. Click "Yes".
However, although you saved your changes, your changes are not in effect since the webserver is already running. You must restart the Apache webserver for your changes in your "httpd.conf" file to take place. You can do this easily by selecting "Restart" in the Apache program group.
Now that we've restarted our Apache server, let's see what happens when we go to "http://localhost".
Wow, what a large message. Well, we get this message because we haven't created "c:\webdocs" nor created a default file. Once I create the proper directory and default file, we get this. That's much better (I think)
[ Last edited by Remy_3D on 23-2-2004 at 07:35 AM ] |
|
|
|
|
|
|
|
Configure Apache for PHP
This guide assumes that you have already installed PHP on your system. If you have not yet done so, please take a look at this guide: Installing PHP on a Windows Webserver
Now that you've installed PHP on your server that is running Apache, you'll need to configure Apache so that it can utilize PHP properly. In this example, we'll be configuring PHP on Apache 2.0.
First thing to do is to stop Apache.
Go to "Start" --> "Programs" --> "Apache HTTP Server" --> "Control Apache Server" --> "Stop".
You should get a message that Apache is stopping.
We now need to edit a file called "httpd.conf". This file is located at "C:\Program Files\Apache Group\Apache2\conf". Use any text editor such as Notepad to edit it.
Or another way you can edit httpd.conf is to go to "Start" --> "Programs" --> "Apache HTTP Server" --> "Configure Apache Server" --> Edit the Apache httpd.conf Configuration File".
We need to setup the ScriptAlias for PHP. This creates a name for the directory where PHP is located.
Use the search function in your text editor and search for "ScriptAlias". You'll find something like this:
---------------
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache2/cgi-bin/"
---------------
Assuming that you followed the default installation of PHP and installed PHP into "c:/php/", then add the following line under "ScriptAlias"
ScriptAlias /php/ "c:/php/"
If you didn't install PHP into "c:/php/", then replace "c:/php/" with the directory into which you installed PHP.
-----------------
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache2/cgi-bin/"
ScriptAlias /php/ "c:/php/"
-----------------
Basically we just connected "/php/" to "c:/php/". So anytime the server encounters "/php/", it will be translated into "c:/php/".
Now let's work on "Action". Use the search function in your text editor to find the phrase "Action lets you"
-----------------
# Action lets you define media types that will execute a script whenever
# a matching file is called. This eliminates the need for repeated URL
# pathnames for oft-used CGI file processors.
# Format: Action media/type /cgi-script/location
# Format: Action handler-name /cgi-script/location
#
-----------------
On a new line without a # add the following line:
Action application/x-httpd-php /php/php.exe
It should look like this:
-------------------
# Action lets you define media types that will execute a script whenever
# a matching file is called. This eliminates the need for repeated URL
# pathnames for oft-used CGI file processors.
# Format: Action media/type /cgi-script/location
# Format: Action handler-name /cgi-script/location
#
Action application/x-httpd-php /php/php.exe
-------------------
Now we have to let Apache know which files contain PHP code.
Use your search function to look for "AddType".
------------
# AddType allows you to add to or override the MIME configuration
# file mime.types for specific file types.
#
AddType application/x-tar .tgz
AddType image/x-icon .ico
------------
Add the line:
AddType application/x-httpd-php .php
It should look like this:
---------------
# AddType allows you to add to or override the MIME configuration
# file mime.types for specific file types.
#
AddType application/x-tar .tgz
AddType image/x-icon .ico
AddType application/x-httpd-php .php
---------------
Now, save the httpd.conf file and restart Apache.
Now we have to write a small php file to test out if PHP actually works.
Open up Notepad and paste the code between the two lines in the page.
----------------------------
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo "<p>Hello World</p>"; ?>
</body>
</html>
----------------------------
In Notepad, select "File" then "Save As". Browse to your website document directory and save the file as "index.php". Keep the "" marks. This makes Notepad save the file with the ".php" extension instead of ".txt".
Now fire up your web browser and point it at the directory where you saved the file. You should see this:
If you see the actual code of the page, then something is wrong. You will need to go back and figure out what is missing.
Depending on your particular setup, you may or may not have to edit a file called php.ini. This file is in your c:\windows directory.
That's it, your done!
[ Last edited by Remy_3D on 23-2-2004 at 07:45 AM ] |
|
|
|
|
|
|
|
hi...
TQ bebanyak coz tutorial ni memang betul-betul membantu..
ini 1st time saya install apache & php..
ikut tutorial ni and berjaya install..
tapi ada masalah sikit.. & nak tanya pendapat u
hope u dapat tolong..
after install apache & php, saya install mySQL..
tapi sekarang ni mySQL tak connect dengan php..
ada tak tips untuk settle masalah ni..
saya ada jgk search kat internet tapi buat masa ni tak jumpa lagi cara untuk settle masalah ni..
hope u boleh bagi pendapat..
ni kali pertama saya install mySQL..
TQ.. |
|
|
|
|
|
|
|
Reply #4 jun_sk's post
bukak PHP.INI pastu uncomment mysql punya driver
Utk lebih mudah dlm setting Apache/PHP/MySQL ni, lebih baik guna pre-packaged ditribution, cthnya, WAMP... lagi senang, x yah pening2 kepala |
|
|
|
|
|
|
pijotfly This user has been deleted
|
|
|
|
|
|
|
|
Reply #5 neotoxin's post
betul tu, senang guna wamp. tapi, kalau nak betul-betul belajar, install satu-satu and try make it work. the knowledge you get from it, priceless. i used wamp initially and very easy, but i don't learn a lot. when i tried install them one by one, i made lots of mistakes but i learned a lot too... and very satisfying when i resolved the mistakes. but, really, it's up to individual.
|
|
|
|
|
|
|
|
better belajar cara nak install satu persatu... atleast tak la buta sangat kan...
lepas tu, lau dah faham..bleh la install memana integration like wamp ke easyphp ke... |
|
|
|
|
|
|
|
Reply #8 mygirlz's post
heh.. I said it because I've done it. PHP on IIS6.0 with MSSQL (unusual combination isn't it?) |
|
|
|
|
|
|
|
ok tu memang ok...tapi tula..cara code lam windows binary ngan dalam linux environment berbeza..kekadang jalan kat windows..tapi lam linux...dia quite sensitip...lau iis ni senang nak mapping...lam apache lak berlainan..tapi terpulang kat individu la...mana yang senang... |
|
|
|
|
|
|
|
Originally posted by oobi at 28-5-2007 01:05 AM
betul tu, senang guna wamp. tapi, kalau nak betul-betul belajar, install satu-satu and try make it work. the knowledge you get from it, priceless. i used wamp initially and very easy, but i don ...
Yeah I agree with you.. Berguna masa buat troubleshooting, costumizekan feature & banyak lagi... |
|
|
|
|
|
|
| |
|