Skip to content

Instantly share code, notes, and snippets.

@aquasmit
Last active July 12, 2016 16:42
Show Gist options
  • Save aquasmit/1122de2067eff118bded8512d7dc472b to your computer and use it in GitHub Desktop.
Save aquasmit/1122de2067eff118bded8512d7dc472b to your computer and use it in GitHub Desktop.
nginx essential commands
  • Update virtual host file

Step 1:

$ suno nano /etc/nginx/sites-available/<file-name>

Step 2: $ sudo service nginx reload

  • Enable htaccess in nginx

Step 1: Make sure that you have below line in your host file: try_files $uri $uri/ /index.php?$args; Resource: https://www.digitalocean.com/community/questions/enabling-nginx-mod_rewrite

Your server block should look like:

server{
.....

location / {
 try_files $uri $uri/ /index.php?$args;
}

.......
}

Step 2: $ sudo service nginx reload

  • Activate the host by creating a symbolic link between the sites-available directory and the sites-enabled directory.

$ sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com

$ sudo service nginx restart

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