-
Set root by default
$ sudo -s
-
Make sure that we use last update of apt-get
$ apt-get update
-
Install lib
$ apt-get install python-software-properties dialog $ nginx=development # use nginx=stable for latest stable version (1.2.4 at time of posting) $ add-apt-repository ppa:nginx/$nginx $ apt-get update $ apt-get install nginx
-
Start nginx
$ service nginx start
-
Nginx should start at boot time but if not, run
$ update-rc.d nginx defaults
-
Install mysql
$ apt-get install mysql-server mysql-client
-
Install php
$ add-apt-repository ppa:brianmercer/php5 $ apt-get update $ apt-get upgrade $ apt-get install php5-fpm
-
open /etc/php5/fpm/php.ini and add the line cgi.fix_pathinfo = 1 right at the end of the file:
$ nano -w /etc/php5/fpm/php.ini
-
edit nginx conf
user www-data; worker_processes 4;
error_log /var/log/nginx/error.log; pid /var/run/nginx.pid;
events { worker_connections 1024; # multi_accept on; }
http { include /etc/nginx/mime.types;
access_log /var/log/nginx/access.log; sendfile on; tcp_nopush on; keepalive_timeout 65; tcp_nodelay on; types_hash_max_size 2048; server_tokens off; index index.php index.html index.htm; gzip on; gzip_disable "MSIE [1-6].(?!.*SV1)"; upstream php { server 127.0.0.1:9000; } include /etc/nginx/conf.d/*.conf; #include /etc/nginx/sites-enabled/*;
}
-
edit etc/nginx/conf.d/default.conf
server { fastcgi_buffer_size 4K; fastcgi_buffers 64 4k;
server_name _; root /var/www/sites/$host; error_log /var/log/nginx/error.log notice; access_log /var/log/nginx/access.log combined; location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } # Very rarely should these ever be accessed outside of your lan location ~* .(txt|log)$ { allow 127.0.0.1; deny all; } location ~ ..*/.*.php$ { return 403; } location / { try_files $uri rewrite; } location @rewrite { # Some modules enforce no slash (/) at the end of the URL # Else this rewrite block wouldn't be needed (GlobalRedirect) rewrite ^/(.*)$ /index.php?q=$1; } location ~ .php$ { # Zero-day exploit defense. # http://forum.nginx.org/read.php?2,88845,page=3 # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi. # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And then cross your fingers that you won't get hacked. try_files $uri =404; fastcgi_split_path_info ^(.+.php)(/.+)$; #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_intercept_errors on; fastcgi_pass php; } location ~* .(js|css|png|jpg|jpeg|gif|ico)$ { expires max; log_not_found off; }
}
Last active
December 20, 2015 20:38
-
-
Save apirak/6191424 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment