Skip to content

Instantly share code, notes, and snippets.

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
wget && 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
# Move the script to the init.d directory & make executable
cp /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