I'm working with XAMPP on Mac OS X.
I'm trying to run a Symfony website properly for a client, and I really don't know Symfony (yet). I just want to install and launch it.
I've changed my /etc/hosts file this way:
127.0.0.1 www.mysite.local
And the httpd.conf file this way:
<VirtualHost *:80> ServerName www.mysite.local DocumentRoot /Applications/MAMP/htdocs/mysite/web DirectoryIndex index.php <Directory /Applications/MAMP/htdocs/mysite/web> AllowOverride All Allow from All </Directory> Alias /sf /Applications/MAMP/htdocs/mysite/lib/vendor/symfony/data/web/sf <Directory "/Applications/MAMP/htdocs/mysite/lib/vendor/symfony/data/web/sf"> AllowOverride All Allow from All </Directory> </VirtualHost>
Now, the site is working (yay!), but I can't access any more any of my other local sites because localhost is rendered as www.mysite.local.
Where am I wrong?
The Apache HTTP server supports virtual hosts, meaning that it can respond to requests that are directed to multiple IP addresses or host names that correspond to the same host machine. You can configure each virtual host to provide different content and to behave differently.
Create a Virtual Hosts By default on Ubuntu systems, Apache Virtual Hosts configuration files are stored in /etc/apache2/sites-available directory and can be enabled by creating symbolic links to the /etc/apache2/sites-enabled directory.
IP-based virtual hosts use the IP address of the connection to determine the correct virtual host to serve. Therefore you need to have a separate IP address for each host. With name-based virtual hosting, the server relies on the client to report the hostname as part of the HTTP headers.
This worked for me!
To run projects like http://localhost/projectName
:
<VirtualHost localhost:80> ServerAdmin localhost DocumentRoot path/to/htdocs/ ServerName localhost </VirtualHost>
To run projects like http://somewebsite.com
locally:
<VirtualHost somewebsite.com:80> ServerAdmin [email protected] DocumentRoot /path/to/htdocs/somewebsiteFolder ServerName www.somewebsite.com ServerAlias somewebsite.com </VirtualHost>
The same for other websites:
<VirtualHost anothersite.local:80> ServerAdmin [email protected] DocumentRoot /path/to/htdocs/anotherSiteFolder ServerName www.anothersite.local ServerAlias anothersite.com </VirtualHost>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With