Skip to content

Instantly share code, notes, and snippets.

@matteocrippa
Last active December 16, 2015 15:49
Show Gist options
  • Save matteocrippa/5458820 to your computer and use it in GitHub Desktop.
Save matteocrippa/5458820 to your computer and use it in GitHub Desktop.
Nginx - Create base configuration for a php website
# 1 - Use vi/vim/nano to create a file according the domain name
sudo vi /etc/nginx/sites-available/example.com
# 2 - add these lines inside:
server {
server_name example.com www.example.com;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
root /var/www/example.com/htdocs;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
}
# 3 - create symbolic link
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
# 4 - verify that the config file is ok
sudo nginx -t
# 5 - if everything is ok now reload nginx
sudo service nginx reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment