sh 在Ubuntu 18.04上安装Nginx

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 在Ubuntu 18.04上安装Nginx相关的知识,希望对你有一定的参考价值。

#!/bin/bash
# THIS IS MEANT TO BUILD IT FROM SOURCE AND INSTALLING IT
# http://nginx.org/en/download.html
# UPDATE SYSTEM
apt-get update && apt-get upgrade -y
# GET NGINX MAINLINE FROM SOURCE
wget http://nginx.org/download/nginx-1.17.3.tar.gz
# EXTRACT NGINX
tar -zxvf https://nginx.org/download/nginx-1.17.3.tar.gz
cd nginx-1.17.3/
# INSTALL DEPENDENCIES
apt-get install build-essential
apt-get install libpcre3 libpcre3-dev libpcrecpp0v5 libssl-dev zlib1g-dev
#CONFIGURE NGINX
./configure --sbin-path=/usr/bin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-debug --with-pcre --with-http_ssl_module
#or
./configure \
  --sbin-path=/usr/bin/nginx \                  #location of the executable
  --conf-path=/etc/nginx/nginx.conf \           #path of the configuration file
  --error-log-path=/var/log/nginx/error.log \   #where to store the error logs
  --http-log-path=/var/log/nginx/access.log \   #where to store the access logs
  --with-debug \
  --with-pcre \                                 #use the pcre library for regex
  --pid-path=/var/run/nginx.pid                 #for referencing the process id
  --with-http_ssl_module
# BUILD BINARIES
make
# INSTALL NGINX
make install
# RUN NGINX
nginx
#!/bin/bash
# UPDATE SYSTEM
sudo apt-get update && apt-get upgrade -y
# GET NGINX MAINLINE FROM SOURCE
wget https://nginx.org/download/nginx-1.17.3.tar.gz
# EXTRACT NGINX
tar -zxvf https://nginx.org/download/nginx-1.17.3.tar.gz
cd nginx-1.17.3/
# INSTALL DEPENDENCIES
sudo apt-get install libpcre3 libpcre3-dev libpcrecpp0v5 libssl-dev zlib1g-dev
#CONFIGURE NGINX
./configure --sbin-path=/usr/bin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-debug --with-pcre --with-http_ssl_module
# BUILD BINARIES
make
# INSTALL NGINX
sudo make install
# RUN NGINX
sudo nginx
sudo apt-get install nginx
#THIS IS MEANT TO COPY KEEP THE CONFIG FILE ON THE HOST
docker run -p 80:80 --name nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx

#OTHER VERSIONS
docker run -p 80:80 --name nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx:alpine
docker run -p 80:80 --name nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx:stable
docker run -p 80:80 --name nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx:latest
docker run -p 80:80 --name nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx:mainline

#RUN ON DEBUG MODE
docker run -p 80:80 --name nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx nginx-debug -g 'daemon off;'

以上是关于sh 在Ubuntu 18.04上安装Nginx的主要内容,如果未能解决你的问题,请参考以下文章

sh 在ubuntu 18.04上安装golang

sh 在Ubuntu 18.04上安装MongoDB 4.0

sh 在ubuntu 18.04上安装i3-gap

sh 在ubuntu 18.04上安装i3-gap

Ubuntu18.04系统安装nginx

Ubuntu18.04 Server安装Nginx+Git服务