Skip to content

Instantly share code, notes, and snippets.

@harikt
Last active September 24, 2015 02:47
Show Gist options
  • Save harikt/656142 to your computer and use it in GitHub Desktop.
Save harikt/656142 to your computer and use it in GitHub Desktop.
Virtual host
Replace the blog and public directory according to the names .
Sample which Ryan Mauger http://www.rmauger.co.uk/ helped me on #zf-talk .
<Bittarman> open your terminal, and type this,
sudo echo "127.0.0.1 blog.local www.blog.local" >> /etc/hosts
<Bittarman> then, sudo vim /etc/apache2/sites-available/blog.local
<Bittarman> and paste this into it http://pastie.org/1112846
<VirtualHost *:80>
ServerName blog.local
ServerAlias www.blog.local
DocumentRoot /var/www/blog/public
<Directory /var/www/blog/public>
AllowOverride All
</directory>
</VirtualHost>
<Bittarman> replacing /var/www/blog/public with the path to your public dir
<Kit-10> (thanks Bittarman for helping resolve this)
<Bittarman> then, sudo a2ensite blog.local && sudo apache2ctl restart
<Bittarman> and finally, you will probably need sudo a2enmod rewrite
@harikt
Copy link
Author

harikt commented Jun 15, 2015

Apache 2.4 settings for virtual host .

/etc/apache2/sites-available/hello.localhost.conf , depending upon how the conf is read.

<VirtualHost *:80>
    ServerName hello.localhost
    ServerAlias www.hello.localhost
    DocumentRoot /var/www/harikt/hello/
    <Directory /var/www/harikt/hello/>
        DirectoryIndex index.php
        AllowOverride All
        Require all granted
    </directory>
</VirtualHost>
a2ensite hello.localhost
service apache2 reload

Add in /etc/hosts

127.0.0.1   hello.localhost www.hello.localhost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment