Forked from kengoldfarb/install_nginx_pagespeed_php.sh
Created
August 22, 2014 12:04
-
-
Save zaherg/1683e0f41130405527e4 to your computer and use it in GitHub Desktop.
This file contains 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 characters
#!/bin/bash | |
## Author: Ken Goldfarb <[email protected]> | |
## https://github.com/kengoldfarb | |
## | |
## This script will install Nginx+Pagespeed with PHP-FPM 5.5.x | |
## It's testsed working on a stock AWS Ubuntu 13.10 image | |
## | |
## BONUS: Oh-my-zsh installation included! | |
# ZSH - Uncomment these lines to install Oh-My-ZSH (https://github.com/robbyrussell/oh-my-zsh) | |
#apt-get install zsh | |
#apt-get install git-core | |
#wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh | |
#chsh -s `which zsh` | |
# PAGESPEED | |
apt-get install -y build-essential zlib1g-dev libpcre3 libpcre3-dev libssl-dev libgd2-xpm-dev libgeoip-dev libperl-dev unzip libxml2-dev libxslt-dev | |
cd ~ | |
wget https://github.com/pagespeed/ngx_pagespeed/archive/v1.8.31.3-beta.zip | |
unzip v1.8.31.3-beta.zip # or unzip v1.7.30.1-beta | |
cd ngx_pagespeed-1.8.31.3-beta/ | |
wget https://dl.google.com/dl/page-speed/psol/1.8.31.3.tar.gz | |
tar -xzvf 1.8.31.3.tar.gz # expands to psol/ | |
# Echo Module | |
cd ~ | |
wget https://github.com/openresty/echo-nginx-module/archive/v0.53.tar.gz | |
tar xzvf v0.53.tar.gz | |
# MORE HEADERS | |
cd ~ | |
wget https://github.com/agentzh/headers-more-nginx-module/archive/v0.25.tar.gz | |
tar xzvf v0.25.tar.gz | |
# check http://nginx.org/en/download.html for the latest version | |
cd ~ | |
wget http://nginx.org/download/nginx-1.6.0.tar.gz | |
tar -xvzf nginx-1.6.0.tar.gz | |
cd nginx-1.6.0/ | |
./configure --add-module=$HOME/ngx_pagespeed-1.8.31.3-beta --with-pcre-jit --with-debug --with-http_addition_module --with-http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_mp4_module --with-http_perl_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_spdy_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-mail --with-mail_ssl_module --add-module=$HOME/headers-more-nginx-module-0.25 --add-module=$HOME/echo-nginx-module-0.53 | |
make | |
make install | |
# Setup nginx dirs | |
mkdir -p /var/log/nginx | |
# Create startup script for nginx | |
echo '#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the nginx web server | |
# Description: starts nginx using start-stop-daemon | |
### END INIT INFO | |
PATH=/opt/nginx/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/share/nginx:/usr/share/nginx/sbin | |
DAEMON=/usr/local/nginx/sbin/nginx | |
NAME=nginx | |
DESC=nginx | |
test -x $DAEMON || exit 0 | |
# Include nginx defaults if available | |
if [ -f /etc/default/nginx ] ; then | |
. /etc/default/nginx | |
fi | |
set -e | |
case "$1" in | |
start) | |
echo -n "Starting $DESC: " | |
start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \ | |
--exec $DAEMON -- $DAEMON_OPTS | |
echo "$NAME." | |
;; | |
stop) | |
echo -n "Stopping $DESC: " | |
start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \ | |
--exec $DAEMON | |
echo "$NAME." | |
;; | |
restart|force-reload) | |
echo -n "Restarting $DESC: " | |
start-stop-daemon --stop --quiet --pidfile \ | |
/usr/local/nginx/logs/$NAME.pid --exec $DAEMON | |
sleep 1 | |
start-stop-daemon --start --quiet --pidfile \ | |
/usr/local/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS | |
echo "$NAME." | |
;; | |
reload) | |
echo -n "Reloading $DESC configuration: " | |
start-stop-daemon --stop --signal HUP --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \ | |
--exec $DAEMON | |
echo "$NAME." | |
;; | |
*) | |
N=/etc/init.d/$NAME | |
echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0' > /etc/init.d/nginx | |
chmod 0755 /etc/init.d/nginx | |
service nginx start | |
# PHP55-fpm | |
apt-get install -y python-software-properties | |
add-apt-repository -y ppa:ondrej/php5 # Use ppa:ondrej/php5-oldstable for PHP 5.4 | |
apt-get update | |
apt-get install -y php5-common php5-fpm php5-mysql php5-sqlite php5-curl php5-imagick php5-gd php5-cli | |
# Update php configs | |
sed -i "s/listen = \/var\/run\/php5-fpm.sock/listen = 127.0.0.1:9000/g" /etc/php5/fpm/pool.d/www.conf # Use a port instead of a socket | |
# sed -i "s/short_open_tag = Off/short_open_tag = On/g" /etc/php5/fpm/php.ini # Turn on PHP short tags | |
# sed -i "s/post_max_size = 3M/post_max_size = 250M/g" /etc/php5/fpm/php.ini # Change the php POST size | |
# sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 200M/g" /etc/php5/fpm/php.ini # Change the php max upload size | |
# sed -i "s/memory_limit = 128M/memory_limit = -1/g" /etc/php5/fpm/php.ini | |
# sed -i "s/max_execution_time = 30/max_execution_time = 300/g" /etc/php5/fpm/php.ini | |
# sed -i "s/max_input_time = 60/max_input_time = 300/g" /etc/php5/fpm/php.ini | |
# sed -i "s/post_max_size = 8M/post_max_size = 300M/g" /etc/php5/fpm/php.ini | |
sed -i "s/session.gc_maxlifetime = 1440/session.gc_maxlifetime = 43200/g" /etc/php5/fpm/php.ini # Update session timeout | |
service php5-fpm restart | |
# Start nginx on boot | |
update-rc.d nginx defaults |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment