Advertisement
Guest User

Untitled

a guest
Nov 4th, 2013
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.01 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. nginxver=1.5.6
  4.  
  5. echo "Nginx listen port?"
  6. read listen_port
  7.  
  8. mkdir -p /home/${USER}/src/nginx
  9. cd ~/src/nginx
  10.  
  11. # Download Pagespeed module
  12. wget https://github.com/pagespeed/ngx_pagespeed/archive/release-1.6.29.7-beta.zip
  13. unzip release-1.6.29.7-beta
  14. cd ngx_pagespeed-release-1.6.29.7-beta/
  15. wget https://dl.google.com/dl/page-speed/psol/1.6.29.7.tar.gz
  16. tar -xzvf 1.6.29.7.tar.gz
  17.  
  18. # Install Nginx
  19. cd ~/src/nginx
  20. wget http://nginx.org/download/nginx-${nginxver}.tar.gz
  21. tar xvf nginx-${nginxver}.tar.gz
  22. cd nginx-${nginxver}
  23.  
  24. ./configure --prefix=/home/${USER}/nginx \
  25. --add-module=$HOME/src/nginx/ngx_pagespeed-release-1.6.29.7-beta \
  26. --with-http_ssl_module \
  27. --with-http_gzip_static_module \
  28. --with-http_image_filter_module \
  29. --with-http_mp4_module \
  30. --with-http_random_index_module \
  31. --with-http_realip_module \
  32. --with-http_stub_status_module \
  33. --with-http_sub_module
  34. make && make install
  35.  
  36. # Configure Nginx
  37. mkdir /home/${USER}/nginx/conf/sites-available
  38. mkdir /home/${USER}/nginx/conf/sites-enabled
  39. mkdir /home/${USER}/nginx/pagespeed_temp
  40.  
  41. echo "
  42. worker_processes 8;
  43.  
  44. events {
  45.     worker_connections 1024;
  46. }
  47.  
  48. http {
  49.     index index.php index.html index.htm;
  50.  
  51.     sendfile on;
  52.     tcp_nopush on;
  53.     tcp_nodelay on;
  54.     keepalive_timeout 65;
  55.     types_hash_max_size 2048;
  56.     server_tokens off;
  57.    
  58.     pagespeed on;
  59.     pagespeed FileCachePath /home/${USER}/nginx/pagespeed_temp;
  60.     pagespeed RewriteLevel PassThrough;
  61.     pagespeed UsePerVHostStatistics on;
  62.     pagespeed Statistics on;
  63.     pagespeed StatisticsLogging on;
  64.     pagespeed LogDir /home/${USER}/nginx/logs/pagespeed;
  65.     pagespeed MessageBufferSize 100000;
  66.  
  67.     include /home/${USER}/nginx/conf/mime.types;
  68.     default_type application/octet-stream;
  69.    
  70.     server {
  71.         # Default server block blacklisting all unconfigured access
  72.         listen       12513;
  73.         server_name _;
  74.         return 444;
  75.     }
  76.  
  77.     include /home/${USER}/nginx/conf/sites-enabled/*;
  78. }
  79. " > /home/${USER}/nginx/conf/nginx.conf
  80.  
  81. echo "
  82. server {
  83.    listen       ${listen_port};
  84.  
  85.     root /home/${USER}/nginx/html/;
  86.    index index.php index.html index.htm;
  87.    
  88.    server_name _;
  89.    
  90.     location / {
  91.         index index.html index.html;
  92.     }
  93.  
  94.     location ~* \.php$ {
  95.         try_files \$uri =404;
  96.         fastcgi_index index.php;
  97.         fastcgi_pass unix:/home/${USER}/php5.4/var/run/php5-fpm.sock;
  98.         include fastcgi_params;
  99.         fastcgi_param   SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
  100.         fastcgi_param   SCRIPT_NAME  \$fastcgi_script_name;
  101.     }
  102.    
  103.     location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
  104.         access_log        off;
  105.         log_not_found     off;
  106.         expires           360d;
  107.     }
  108.    
  109.     location ~ /\. {
  110.         access_log off;
  111.         log_not_found off;
  112.         deny all;
  113.     }
  114.    # redirect server error pages to the static page /50x.html
  115.    #
  116.    error_page   500 502 503 504  /50x.html;
  117.    location = /50x.html {
  118.    }
  119.  
  120. }
  121. " > /home/${USER}/nginx/conf/sites-available/default
  122.  
  123. ln -s /home/${USER}/nginx/conf/sites-available/default /home/${USER}/nginx/conf/sites-enabled/default
  124.  
  125. # Cleanup
  126. rm -rf ~/src/nginx
  127.  
  128. # Start server
  129. ~/nginx/sbin/nginx
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement