Skip to content

Instantly share code, notes, and snippets.

@m-antoni
Last active November 22, 2019 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m-antoni/ae3ae48e4703b15632480442f805ec3d to your computer and use it in GitHub Desktop.
Save m-antoni/ae3ae48e4703b15632480442f805ec3d to your computer and use it in GitHub Desktop.
Create a Virtual Host in Ubuntu 18.04

Create a Virtual Host in Ubuntu 18.04

  • On your Terminal

      $ cd /etc/apache2/sites-available/
    
      $ ls
    
      $ sudo cp /etc/apache2/sites-avalable/000-default.conf /etc/apache2/sites-available/[SITENAME].conf
    
      $ sudo nano /etc/apache2/sites-available/[SITENAME].conf
    
  • Edit the file make fill in the credentials needed

      <VirtualHost *:80>
      	ServerName sitename.test
      	DocumentRoot "/var/www/html/[SITEFOLDER]/public"
      <Directory "/var/www/html/[SITEFOLDER]/public">
      	Options Indexes FollowSymLinks
      	AllowOverride All
      	Require all granted
      </Directory>
      </VirtualHost>
    
  • Enabled the Virtual Host file

      $ sudo a2ensite [SITENAME].conf
    
  • Remove index.php from url

      $ sudo a2enmod rewrite
    
  • Restart the apache service

      $ sudo service apache2 restart
    
  • Setup a localhost file

      $ sudo nano /etc/hosts
    
      127.0.0.1	sitename.test
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment