Skip to content

Instantly share code, notes, and snippets.

@NimzyMaina
Last active November 14, 2018 16:29
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 NimzyMaina/fd2812120e6db1d4086f43339f5f550f to your computer and use it in GitHub Desktop.
Save NimzyMaina/fd2812120e6db1d4086f43339f5f550f to your computer and use it in GitHub Desktop.
Codeigniter Nginx Web config
upstream php {
server unix:/var/run/php/php7.2-fpm.sock;
}
server {
listen 80;
server_name www.example.com example.com;
root /var/www/example.com;
index index.html index.php;
# Enable rewrite error log
error_log /var/www/example.com/storage/logs/error.log;
access_log /var/www/example.com/storage/logs/access.log;
# Any HTTP request other than those for assets folder, files folder and robots.txt
# is treated as a request for your index.php file.
location ~* ^/(assets|files|robots\.txt)(\?[0-9]+) { }
location / {
try_files $uri $uri/ /index.php;
}
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass php;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
# Deny access to .htaccess files, if Apache's document root
# concurs with Nginx's one
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment