? 没有对nginx安装部署进行说明,此处做个总结!
首先查看Linux相关系统版本号
cat /etc/*-release
判断有没有装nginx(判断是否已经安装了Nginx)
whereis nginx
nginx: /usr/sbin/nginx /etc/nginx /usr/lib64/nginx
前置条件
安装ngnix的前置条件是, 安装一下三个库:
在安装这三个库之前还要确认一下是否安装好了gcc/g++/make等一系列的编译环境。下面我们一步一步开始安装。
安装gcc g++ 等一系列的编译环境
CentOS版:
安装make:
yum -y install gcc automake autoconf libtool make
安装g++:
yum install -y gcc gcc-c++
安装PCRE库,为了重写rewrite
安装目录设置为 /usr/local/src
cd /usr/local/src wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
tar -zxvf pcre-8.38.tar.gz
cd pcre-8.38
./configure
make make install
3.安装zlib库,为了gzip压缩
cd /usr/local/src
wget http://www.zlib.net/zlib-1.2.12.tar.gz
tar -zxvf zlib-1.2.12.tar.gz
cd zlib-1.2.12
./configure
make
make install
4.安装SSL
cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz
tar -zxvf openssl-1.0.1t.tar.gz
5.安装nginx
cd /usr/local/src
wget http://nginx.org/download/nginx-1.8.0.tar.gz
tar -zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0
Ubuntu 安装
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y libtool
sudo apt-get install -y libpcre3 libpcre3-dev
sudo apt-get install -y zlib1g-dev
sudo apt-get install -y libssl-dev
sudo apt-get install -y openssl
curl -sLO http://nginx.org/download/nginx-1.22.1.tar.gz
tar -zxvf nginx-1.22.1.tar.gz
cd nginx-1.22.1
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_realip_module
make
make install
6.解决启动错误 :如果是32位系统
ln -s /usr/local/lib/libpcre.so.1 /lib
如果是64位系统
ln -s /usr/local/lib/libpcre.so.1 /lib64
cd /
mkdir -p /var/temp/nginx/client
然后在启动nginx就OK了
/usr/local/webserver/nginx/sbin/nginx
./nginx -c /usr/local/nginx/conf/nginx.conf
cd /usr/local/nginx/sbin
./nginx -s stop
./nginx -s quit
./nginx
./nginx -s reload
|