Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- nginxver=1.5.6
- echo "Nginx listen port?"
- read listen_port
- mkdir -p /home/${USER}/src/nginx
- cd ~/src/nginx
- # Download Pagespeed module
- wget https://github.com/pagespeed/ngx_pagespeed/archive/release-1.6.29.7-beta.zip
- unzip release-1.6.29.7-beta
- cd ngx_pagespeed-release-1.6.29.7-beta/
- wget https://dl.google.com/dl/page-speed/psol/1.6.29.7.tar.gz
- tar -xzvf 1.6.29.7.tar.gz
- # Install Nginx
- cd ~/src/nginx
- wget http://nginx.org/download/nginx-${nginxver}.tar.gz
- tar xvf nginx-${nginxver}.tar.gz
- cd nginx-${nginxver}
- ./configure --prefix=/home/${USER}/nginx \
- --add-module=$HOME/src/nginx/ngx_pagespeed-release-1.6.29.7-beta \
- --with-http_ssl_module \
- --with-http_gzip_static_module \
- --with-http_image_filter_module \
- --with-http_mp4_module \
- --with-http_random_index_module \
- --with-http_realip_module \
- --with-http_stub_status_module \
- --with-http_sub_module
- make && make install
- # Configure Nginx
- mkdir /home/${USER}/nginx/conf/sites-available
- mkdir /home/${USER}/nginx/conf/sites-enabled
- mkdir /home/${USER}/nginx/pagespeed_temp
- echo "
- worker_processes 8;
- events {
- worker_connections 1024;
- }
- http {
- index index.php index.html index.htm;
- sendfile on;
- tcp_nopush on;
- tcp_nodelay on;
- keepalive_timeout 65;
- types_hash_max_size 2048;
- server_tokens off;
- pagespeed on;
- pagespeed FileCachePath /home/${USER}/nginx/pagespeed_temp;
- pagespeed RewriteLevel PassThrough;
- pagespeed UsePerVHostStatistics on;
- pagespeed Statistics on;
- pagespeed StatisticsLogging on;
- pagespeed LogDir /home/${USER}/nginx/logs/pagespeed;
- pagespeed MessageBufferSize 100000;
- include /home/${USER}/nginx/conf/mime.types;
- default_type application/octet-stream;
- server {
- # Default server block blacklisting all unconfigured access
- listen 12513;
- server_name _;
- return 444;
- }
- include /home/${USER}/nginx/conf/sites-enabled/*;
- }
- " > /home/${USER}/nginx/conf/nginx.conf
- echo "
- server {
- listen ${listen_port};
- root /home/${USER}/nginx/html/;
- index index.php index.html index.htm;
- server_name _;
- location / {
- index index.html index.html;
- }
- location ~* \.php$ {
- try_files \$uri =404;
- fastcgi_index index.php;
- fastcgi_pass unix:/home/${USER}/php5.4/var/run/php5-fpm.sock;
- include fastcgi_params;
- fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
- fastcgi_param SCRIPT_NAME \$fastcgi_script_name;
- }
- location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
- access_log off;
- log_not_found off;
- expires 360d;
- }
- location ~ /\. {
- access_log off;
- log_not_found off;
- deny all;
- }
- # redirect server error pages to the static page /50x.html
- #
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- }
- }
- " > /home/${USER}/nginx/conf/sites-available/default
- ln -s /home/${USER}/nginx/conf/sites-available/default /home/${USER}/nginx/conf/sites-enabled/default
- # Cleanup
- rm -rf ~/src/nginx
- # Start server
- ~/nginx/sbin/nginx
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement