Last active
September 19, 2016 18:59
-
-
Save toadkicker/a756d139471d47b282c9 to your computer and use it in GitHub Desktop.
Revisions
-
toadkicker revised this gist
Sep 19, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,8 +13,8 @@ sudo apt-get install language-pack-en sudo apt-get install build-essential curl libssl-dev libpcre3 libpcre3-dev unzip git export NPS_VERSION=1.9.32.3 export NGINX_VERSION=1.11.4 export NODE_VERSION=6.6.0 ``` ## Download Nginx, PageSpeed, and NodeJS -
toadkicker revised this gist
Jun 24, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ sudo apt-get install build-essential curl libssl-dev libpcre3 libpcre3-dev unzip export NPS_VERSION=1.9.32.3 export NGINX_VERSION=1.9.1 export NODE_VERSION=0.10.38 ``` ## Download Nginx, PageSpeed, and NodeJS -
toadkicker revised this gist
Jun 14, 2015 . 1 changed file with 17 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ *Assumes you're doing everything under /home/ubuntu* ## OS configuration ``` sudo apt-get update sudo apt-get install language-pack-en @@ -17,15 +17,7 @@ export NGINX_VERSION=1.9.1 eport NODE_VERSION=0.10.38 ``` ## Download Nginx, PageSpeed, and NodeJS ``` git clone https://github.com/joyent/node.git @@ -39,7 +31,7 @@ sudo mkdir /var/ngx_pagespeed_cache sudo chown www-data:www-data /var/ngx_pagespeed_cache ``` ## Nginx install ``` tar -xzvf nginx-${NGINX_VERSION}.tar.gz cd nginx-${NGINX_VERSION} @@ -54,7 +46,15 @@ cd ~ You now have nginx located at /usr/local/nginx with config files in /usr/local/nginx/conf ### Generate a self signed SSL cert (spdy requires it) ``` sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /usr/local/nginx/ssl/nginx.key -out /usr/local/nginx/ssl/nginx.crt sudo chown root /usr/local/nginx/ssl/nginx.* chmod 0400 /usr/local/nginx/ssl/nginx.* ``` ## Node Install Grab a beer, this one runs for ~10 minutes. @@ -78,19 +78,20 @@ Also Ubuntu needs this to be run sudo setcap cap_net_bind_service=+ep /usr/local/bin/node ``` ## Clustering Node with PM2 ``` sudo npm install -g pm2 pm2 start -i 4 server.js ``` `-i 4` is the number of node forks to run ## Upstart Jobs for nginx save as `/etc/init/nginx.conf` ``` ### nginx description "nginx http daemon" author "George Shammas <georgyo@gmail.com>" @@ -122,4 +123,3 @@ Then check the upstart job list: and start the job: `sudo initctl start nginx` -
toadkicker created this gist
Jun 14, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,125 @@ # The Perfect Node / Nginx Server - Ubuntu 14.10 64 bit - Node 0.10.x from source - Nginx from source with SPDY & Pagespeed support *Assumes you're doing everything under /home/ubuntu* 1) OS configuration ``` sudo apt-get update sudo apt-get install language-pack-en sudo apt-get install build-essential curl libssl-dev libpcre3 libpcre3-dev unzip git export NPS_VERSION=1.9.32.3 export NGINX_VERSION=1.9.1 eport NODE_VERSION=0.10.38 ``` Generate a self signed SSL cert (spdy requires it) ``` sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /usr/local/nginx/ssl/nginx.key -out /usr/local/nginx/ssl/nginx.crt sudo chown root /usr/local/nginx/ssl/nginx.* chmod 0400 /usr/local/nginx/ssl/nginx.* ``` 2) Download Nginx, PageSpeed, and NodeJS ``` git clone https://github.com/joyent/node.git wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip unzip release-${NPS_VERSION}-beta.zip cd ngx_pagespeed-release-${NPS_VERSION}-beta wget https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz tar -xvf ${NPS_VERSION}.tar.gz sudo mkdir /var/ngx_pagespeed_cache sudo chown www-data:www-data /var/ngx_pagespeed_cache ``` 3) Nginx install ``` tar -xzvf nginx-${NGINX_VERSION}.tar.gz cd nginx-${NGINX_VERSION} ./configure --with-http_spdy_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-file-aio --with-ipv6 --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --add-module=/home/ubuntu/ngx_pagespeed-release-${NPS_VERSION}-beta --sbin-path=/usr/local/sbin make sudo make install sudo mkdir /usr/local/nginx/ssl cd ~ ``` You now have nginx located at /usr/local/nginx with config files in /usr/local/nginx/conf 4) Node Install Grab a beer, this one runs for ~10 minutes. ``` git clone https://github.com/joyent/node.git cd node git checkout v${NODE_VERSION} ./configure make sudo make install ``` I noticed that root gets set as owner for ~/.npm so this fixes breakage with using non-sudo'd npm. ``` sudo chown -R ubuntu:ubuntu ~ ``` Also Ubuntu needs this to be run ``` sudo setcap cap_net_bind_service=+ep /usr/local/bin/node ``` 5) Clustering Node with PM2 ``` sudo npm install -g pm2 pm2 start -i 4 server.js ``` `-i 4` is the number of node forks to run 6) Upstart Jobs nginx - save as `/etc/init/nginx.conf` ``` # nginx description "nginx http daemon" author "George Shammas <georgyo@gmail.com>" start on (filesystem and net-device-up IFACE=lo) stop on runlevel [!2345] env DAEMON=/usr/local/sbin/nginx env PID=/var/run/nginx.pid expect fork respawn respawn limit 10 5 #oom never pre-start script $DAEMON -t if [ $? -ne 0 ] then exit $? fi end script exec $DAEMON ``` Then check the upstart job list: `initctl list | grep nginx` and start the job: `sudo initctl start nginx`