![]() User websites appear in the Users/Sites/ directory. Let me show you how to create multiple websites on your local machine. Hosting websites on my local machine during development is a must. One OS X feature I make much use of is the integrated Apache server. Compared to Windows-based machines, Mac's OS X operating system is light years better. This way you can easily restore your virtual host configuration.As someone who had always developed on PCs, switching over to using Mac OS X was like going from peasant to prince. If you later re-install the OS or XAMPP you’ll lose the changes to the respective files. I would recommend backing-up the /etc/hosts, /Applications/XAMPP/xamppfiles/etc/nf and /Applications/XAMPP/xamppfiles/etc/extra/nf files whenever you make changes and store them on a separate drive or USB stick. To ensure the virtual host has been configured correctly, restart XAMPP’s Apache server and point your browser to Options Indexes FollowSymLinks Includes execCGIĭocumentRoot "/Users/steve/Sites/MySite1" # localhost ĭocumentRoot "/Applications/XAMPP/xamppfiles/htdocs" The DocumentRoot and are set to the site’s root folder. You do not need to add a corresponding entry in /etc/hosts as this is included by default.įor the local.mysite1 configuration you can see that beginning on line 37 we are setting the ServerName to the name of virtual host we configured in the /etc/hosts file. If you don’t, when you point your browser to all you’ll see is the directory listing of the first virtual host, in this case local.mysite1, and not the XAMPP start page. Note that although I only want to configure a virtual host for local.mysite1, beginning on line 24 I’ve added a virtual host for localhost as the default named sever with the ServerName set to localhost and the DocumentRoot and set to /Applications/XAMPP/htdocs. Remove the example virtual host configurations beginning on line 23 then add the following code block at the end of the file. ServerAdmin "/Applications/XAMPP/xamppfiles/docs/"ĮrrorLog "logs/-error_log"ĬustomLog "logs/-access_log" common ServerAlias ErrorLog "logs/-error_log"ĬustomLog "logs/-access_log" common ![]() ServerAdmin "/Applications/XAMPP/xamppfiles/docs/" # match a ServerName or ServerAlias in any block. # The first VirtualHost section is used for all requests that do not # Almost any Apache directive may go into a VirtualHost container. So, open the file /Applications/XAMPP/xamppfiles/etc/extra/nf. Virtual hosts in XAMPP are configured in the nf file and not the usual nf file. We need to add a line to the end of this file for each virtual host we want to configure. ![]() # localhost is used to configure the loopback interface ![]() In the example I’m going to configure a virtual host for a site that has a root folder of /Users/steve/Sites/MySite1/ and I’ll name the virtual host local.mysite1.Įnsure you stop XAMPP’s Apache server before editing either of the files below. Smultron is free and whilst no longer under development works under 10.5.8. files and will ask for authentication if required. Sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hostsĪn alternative is to use an editor like Smultron which has an option from the File menu to Open Hidden. To edit this file you can open TextEdit with root privileges from a Terminal window like so. The /etc/hosts file is hidden and a standard or admin user doesn’t normally have write access to it. Update: A new version of MAMP (1.8) was released in September 2009. I’m assuming that you’ve not already added virtual hosts to the /etc/hosts file for a previous MAMP install. These are /etc/hosts, /Applications/XAMPP/xamppfiles/etc/nf and /Applications/XAMPP/xamppfiles/etc/extra/nf. With XAMPP we need to edit 3 files as opposed to only the 2 with MAMP. So, there is no alternative but to do it manually. Unlike the Pro version of MAMP, XAMPP doesn’t have a nice GUI to allow virtual hosts to be configured easily. XAMPP provides a similar local server environment to MAMP, but configuring virtual hosts is a little different. Thinking that maybe the writing was on the wall for MAMP I started looking for an alternative and came across XAMPP. More recently I noticed that MAMP hadn’t been updated in nearly a year and their support forum resembled a wilderness. A while back I posted about configuring virtual hosts in MAMP.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |