Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ubuntu nginx install
#Remove previous
/usr/sbin/update-rc.d -f nginx remove
service nginx stop && rm -f -R /usr/local/nginx && rm -f /usr/local/sbin/nginx && apt-get remove nginx && rm -Rf /etc/init/nginx
#Create downloads store folder
apt-get update
apt-get upgrade
cd ~ && mkdir -p downloads && mkdir -p /var/www/html && cd ~/downloads
#Replace by the latest version number found on http://nginx.org/
wget http://nginx.org/download/nginx-1.9.7.tar.gz && tar -xvf nginx-1.9.7.tar.gz && cd nginx-1.9.7
#Install the PCRE library needed by nginx
apt-get -y install libpcre3 libpcre3-dev build-essential libssl-dev
#Create nginx user
useradd --shell /sbin/nologin nginx
#These flags make sure to put nginx somewhere that is usuall in PATH and to activate the https module
./configure --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_mp4_module --with-http_secure_link_module --with-file-aio
make && make install
cp /usr/local/nginx/sbin/nginx /usr/sbin/nginx
mkdir -p /etc/nginx && cp /usr/local/nginx/conf/nginx.conf /etc/nginx/nginx.conf && cp /usr/local/gninx/conf/mime.types /etc/nginx
# Download nginx startup script
cd ~/downloads
wget -O nginx_init_default.sh https://gist.githubusercontent.com/tienrocker/97ac7f886651873cbfda/raw/8dc3fefd9682fddcd557a55bdac9f43a4ef2989f/nginx_init_default
# Move the script to the init.d directory & make executable
cp nginx_init_default.sh /etc/init.d/nginx && chmod +x /etc/init.d/nginx
# Add nginx to the system startup
/usr/sbin/update-rc.d -f nginx defaults
systemctl daemon-reload
#This will make sure you get the following commands
service nginx start
service nginx stop
service nginx restart
service nginx status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.