[nycphp-talk] PHundamentals: virtual host addendum?
Stephen Musgrave
stephen at musgrave.org
Wed Jan 14 11:26:34 EST 2004
yes, this is a great idea. thanks to all who contribute to these articles.
in the rush to get the know the language, these finer details are all too
often glazed over.
[guilty.]
i develop on MAC OS X and thought i would offer some additional pointers on
the VIRTUAL HOSTING topic that may be added to the topic by whomever
maintains it.
http://phundamentals.nyphp.org/PH_virtualhosting.php?expiredate=10/10/2003
i would appreciate a peer review on this since i am not totally confident
that my installation is typical (especially with regard to the location of
the Sites directory). there might also be some tips to improve the language
so as to be more helpful.
to set up a virtual host on MAC OS X
1. Setting up the directories for the virtual host
1a. Create a directory within your 'Sites' directory that will hold all the
files for your project. I typically append .dev to the domain name. So if
I were working on a project for project.com, i would name the directory
'project.dev'.
1b. Within the project.dev directory, create your document root directory
(htdocs, www or public_html).
2. Setting up a machine alias in Net Info Manager
2a. Open Net Info Manager (located in Applications/Utilities).
2b. In the middle column, select the 'machines' directory (/machines) and
then select 'localhost'. Click on the 'duplicate' icon on the task bar.
(Be sure that the you have unlocked the application before trying to
duplicate or else the icon will be dim and you won't be able to duplicate.)
2c. Select the 'localhost copy' machine. The details (ip_address, name,
servers) will show up in the panel below the list. double click on the
value for name (localhost copy). Rename it to 'project.dev' or whatever you
would like. This is the string you will enter for the URL in your browser
to reach the virtual host. Close Net Info Manager
3. Edit the Apache httpd.conf file (/etc/httpd/httpd.conf).
3a. Using vi (or other editor), edit the httpd.conf file. It is likely you
will have to use the sudo command: sudo vi httpd.conf (Make a backup
first! -- sudo cp httpd.conf httpd.conf.bak)
3b. Scroll until you see:
<VirtualHost 127.0.0.1>
DocumentRoot /Users/username/Sites
ServerName localhost
</VirtualHost>
3c. Copy and paste this virtual host definition for localhost. Change the
values to look like so:
<VirtualHost 127.0.0.1>
DocumentRoot /Users/username/Sites/project.dev/htdocs
ServerName project.dev
ErrorLog /Users/stephenm/Sites/project.dev/error_log
</VirtualHost>
4d. Save the file.
5. Restart Apache
5a. Open 'System Preferences'.
5b. Click on 'Sharing'.
5c. Under the 'Services' tab, click 'Personal Web Sharing'.
5d. Click on the 'Stop' button. When it shows as 'Start', click it again.
When it shows as 'Stop' you know that the server has restarted normally and
there weren't any compilation errors entered in the httpd.conf file.
5e. Alternately, you can use the command 'apachectl graceful'.
6. Testing
6a. Create an 'index.html' file the document root fold of the virtual host
(Sites/project.dev/htdocs)
6b. Enter 'http://project.dev' into the location of your browser.
6c. You should see file you just created.
STEPHEN.
] stephen at musgrave.org
] http://stephen.musgrave.org/
More information about the talk
mailing list