266 lines
6.3 KiB
Markdown
266 lines
6.3 KiB
Markdown
|
|
# centos 虚拟机 安装 nginx
|
|||
|
|
|
|||
|
|
pcre 注意需要这个
|
|||
|
|
yum -y install gcc-c++
|
|||
|
|
|
|||
|
|
## 依赖问题
|
|||
|
|
|
|||
|
|
没有gcc的话参考
|
|||
|
|
gcc-4.8.5 含依赖完整RPM安装包(centos7)
|
|||
|
|
貌似不需要perl
|
|||
|
|
|
|||
|
|
参考`pyenv`安装系统开发环境
|
|||
|
|
|
|||
|
|
wiki中:
|
|||
|
|
|
|||
|
|
```shell
|
|||
|
|
yum install gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
Common build problems 中:
|
|||
|
|
|
|||
|
|
```shell
|
|||
|
|
sudo yum install zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel findutils
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 关于 openssl
|
|||
|
|
|
|||
|
|
包安装需要两个
|
|||
|
|
yum install openssl openssl-devel
|
|||
|
|
源码安装只需一个压缩包 openssl-1.0.2h.tar.gz 就行了
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
./config shared zlib
|
|||
|
|
make depend
|
|||
|
|
make
|
|||
|
|
make install
|
|||
|
|
|
|||
|
|
mv /usr/bin/openssl /usr/bin/openssl.bak
|
|||
|
|
mv /usr/include/openssl /usr/include/openssl.bak
|
|||
|
|
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
|
|||
|
|
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
|
|||
|
|
echo “/usr/local/ssl/lib” >> /etc/ld.so.conf
|
|||
|
|
ldconfig -v
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 上传文件
|
|||
|
|
|
|||
|
|
```shell
|
|||
|
|
-rw-r--r--. 1 xxw xxw 1032347 4月 30 11:57 nginx-1.15.12.tar.gz
|
|||
|
|
-rw-r--r--. 1 xxw xxw 5375802 4月 30 17:31 openssl-1.0.2n.tar.gz
|
|||
|
|
-rw-r--r--. 1 xxw xxw 2065161 4月 30 11:57 pcre-8.40.tar.gz
|
|||
|
|
-rw-r--r--. 1 xxw xxw 607698 4月 30 15:44 zlib-1.2.11.tar.gz
|
|||
|
|
[xxw@centos7]~/download%
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 解压编译
|
|||
|
|
|
|||
|
|
```shell
|
|||
|
|
cd /home/xxw/download
|
|||
|
|
tar zxvf nginx-1.15.12.tar.gz
|
|||
|
|
tar zxvf openssl-1.0.2n.tar.gz
|
|||
|
|
tar zxvf pcre-8.40.tar.gz
|
|||
|
|
tar zxvf zlib-1.2.11.tar.gz
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
```shell
|
|||
|
|
cd /home/xxw/download/pcre-8.40
|
|||
|
|
./configure --prefix=/home/xxw/download/install/pcre
|
|||
|
|
make
|
|||
|
|
make install
|
|||
|
|
|
|||
|
|
cd /home/xxw/download/zlib-1.2.11
|
|||
|
|
./configure --prefix=/home/xxw/download/install/zlib
|
|||
|
|
make
|
|||
|
|
make install
|
|||
|
|
|
|||
|
|
cd /home/xxw/download/openssl-1.0.2n
|
|||
|
|
./config --prefix=/home/xxw/download/install/openssl
|
|||
|
|
make
|
|||
|
|
make install
|
|||
|
|
|
|||
|
|
|
|||
|
|
cd /home/xxw/download/nginx-1.15.12
|
|||
|
|
|
|||
|
|
# 注意configure的时候 pcre zlib openssl 都是源码目录
|
|||
|
|
./configure --with-http_stub_status_module --prefix=/home/xxw/nginx --with-pcre=/home/xxw/download/pcre-8.40 --user=zp --with-zlib=/home/xxw/download/zlib-1.2.11 --with-http_ssl_module --with-openssl=/home/xxw/download/openssl-1.0.2n
|
|||
|
|
make
|
|||
|
|
make install
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
最后 注意 防火墙
|
|||
|
|
|
|||
|
|
```shell
|
|||
|
|
firewall-cmd --zone=public --list-all
|
|||
|
|
firewall-cmd --get-active-zones
|
|||
|
|
firewall-cmd --zone=public --add-port=8088/tcp --permanent
|
|||
|
|
firewall-cmd --reload
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
# 2020-04-24 长安安装 1.17.10
|
|||
|
|
|
|||
|
|
```shell
|
|||
|
|
cd /root/Downloads/ng17
|
|||
|
|
tar zxvf nginx-1.17.10.tar.gz
|
|||
|
|
tar zxvf openssl-1.1.1g.tar.gz
|
|||
|
|
tar zxvf pcre-8.44.tar.gz
|
|||
|
|
tar zxvf zlib-1.2.11.tar.gz
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
```shell
|
|||
|
|
cd /root/Downloads/ng17/pcre-8.44
|
|||
|
|
./configure --prefix=/root/Downloads/ng17/install/pcre
|
|||
|
|
make
|
|||
|
|
make install
|
|||
|
|
|
|||
|
|
cd /root/Downloads/ng17/zlib-1.2.11
|
|||
|
|
./configure --prefix=/root/Downloads/ng17/install/zlib
|
|||
|
|
make
|
|||
|
|
make install
|
|||
|
|
|
|||
|
|
cd /root/Downloads/ng17/openssl-1.1.1g
|
|||
|
|
./config --prefix=/root/Downloads/ng17/install/openssl
|
|||
|
|
make
|
|||
|
|
make install
|
|||
|
|
|
|||
|
|
|
|||
|
|
cd /root/Downloads/ng17/nginx-1.17.10/
|
|||
|
|
|
|||
|
|
# 注意configure的时候 pcre zlib openssl 都是源码目录而不是安装目录
|
|||
|
|
./configure --with-http_stub_status_module --prefix=/root/nginx --with-pcre=/root/Downloads/ng17/pcre-8.44 --user=root --with-zlib=/root/Downloads/ng17/zlib-1.2.11 --with-http_ssl_module --with-openssl=/root/Downloads/ng17/openssl-1.1.1g
|
|||
|
|
make
|
|||
|
|
make install
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
restart.sh
|
|||
|
|
|
|||
|
|
```shell
|
|||
|
|
cd /data01/nginx/bin/nginx
|
|||
|
|
before=`ps -ef|grep nginx|grep -v grep|grep userapp|grep -v xiewei|awk '{print $2}'`
|
|||
|
|
ps -ef|grep nginx|grep -v grep|grep userapp|grep -v xiewei|awk '{print $2}'|xargs -i kill -9 {}
|
|||
|
|
/data01/nginx/bin/nginx/sbin/nginx
|
|||
|
|
echo "restart!"
|
|||
|
|
echo $before
|
|||
|
|
after=`ps -ef|grep nginx|grep -v grep|grep userapp|grep -v xiewei|awk '{print $2}'`
|
|||
|
|
echo $after
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 2020-07-23 180 安装
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
configure: error: C preprocessor "/lib/cpp" fails sanity check
|
|||
|
|
yum install kernel-headers
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
yum install gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel
|
|||
|
|
|
|||
|
|
yum -y install gcc-c++
|
|||
|
|
|
|||
|
|
cd /data01/ng17
|
|||
|
|
tar zxvf nginx-1.17.10.tar.gz
|
|||
|
|
tar zxvf openssl-1.1.1g.tar.gz
|
|||
|
|
tar zxvf pcre-8.44.tar.gz
|
|||
|
|
tar zxvf zlib-1.2.11.tar.gz
|
|||
|
|
|
|||
|
|
cd /data01/ng17/pcre-8.44
|
|||
|
|
./configure --prefix=/data01/ng17/install/pcre
|
|||
|
|
make
|
|||
|
|
make install
|
|||
|
|
|
|||
|
|
cd /data01/ng17/zlib-1.2.11
|
|||
|
|
./configure --prefix=/data01/ng17/install/zlib
|
|||
|
|
make
|
|||
|
|
make install
|
|||
|
|
|
|||
|
|
cd /data01/ng17/openssl-1.1.1g
|
|||
|
|
./config --prefix=/data01/ng17/install/openssl
|
|||
|
|
make
|
|||
|
|
make install
|
|||
|
|
|
|||
|
|
|
|||
|
|
cd /data01/ng17/nginx-1.17.10/
|
|||
|
|
|
|||
|
|
# 注意configure的时候 pcre zlib openssl 都是源码目录而不是安装目录
|
|||
|
|
./configure --with-http_stub_status_module --prefix=/data01/nginx --with-pcre=/data01/ng17/pcre-8.44 --user=userapp --with-zlib=/data01/ng17/zlib-1.2.11 --with-http_ssl_module --with-openssl=/data01/ng17/openssl-1.1.1g
|
|||
|
|
make
|
|||
|
|
make install
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
|
|||
|
|
# 2021-10-24 亚信云 安装
|
|||
|
|
|
|||
|
|
```shell
|
|||
|
|
mkdir -p /home/dacp/src/nginx_install
|
|||
|
|
cd /home/dacp/src
|
|||
|
|
tar zxvf zlib-1.2.11.tar.gz
|
|||
|
|
tar zxvf pcre-8.45.tar.gz
|
|||
|
|
tar zxvf openssl-1.1.1l.tar.gz
|
|||
|
|
tar zxvf nginx-1.20.1.tar.gz
|
|||
|
|
|
|||
|
|
cd /home/dacp/src/pcre-8.45
|
|||
|
|
./configure --prefix=/home/dacp/src/nginx_install/pcre
|
|||
|
|
make
|
|||
|
|
make install
|
|||
|
|
|
|||
|
|
cd /home/dacp/src/zlib-1.2.11
|
|||
|
|
./configure --prefix=/home/dacp/src/nginx_install/zlib
|
|||
|
|
make
|
|||
|
|
make install
|
|||
|
|
|
|||
|
|
cd /home/dacp/src/openssl-1.1.1l
|
|||
|
|
./config --prefix=/home/dacp/src/nginx_install/openssl
|
|||
|
|
make
|
|||
|
|
make install
|
|||
|
|
|
|||
|
|
|
|||
|
|
cd /home/dacp/src/nginx-1.20.1/
|
|||
|
|
|
|||
|
|
# 注意configure的时候 pcre zlib openssl 都是源码目录而不是安装目录
|
|||
|
|
./configure --with-http_stub_status_module --prefix=/home/dacp/nginx --with-pcre=/home/dacp/src/pcre-8.45 --user=dacp --with-zlib=/home/dacp/src/zlib-1.2.11 --with-http_ssl_module --with-openssl=/home/dacp/src/openssl-1.1.1l
|
|||
|
|
make
|
|||
|
|
make install
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
# 安装包下载
|
|||
|
|
2021-10
|
|||
|
|
|
|||
|
|
zlib-1.2.11.tar.gz
|
|||
|
|
pcre-8.45.tar.gz
|
|||
|
|
openssl-1.1.1l.tar.gz
|
|||
|
|
nginx-1.20.1.tar.gz
|
|||
|
|
|
|||
|
|
[[2022-02-20]]
|
|||
|
|
|
|||
|
|
zlib-1.2.11.tar.gz
|
|||
|
|
pcre-8.45.tar.gz
|
|||
|
|
openssl-1.1.1m.tar.gz
|
|||
|
|
nginx-1.20.2.tar.gz
|
|||
|
|
|
|||
|
|
## nginx
|
|||
|
|
nginx-1.17.10.tar.gz
|
|||
|
|
Stable version
|
|||
|
|
http://nginx.org/en/download.html
|
|||
|
|
http://nginx.org/download/nginx-1.20.1.tar.gz
|
|||
|
|
|
|||
|
|
|
|||
|
|
## openssl
|
|||
|
|
openssl-1.1.1g.tar.gz
|
|||
|
|
> The latest stable version is the 3.0 series. Also available is the 1.1.1 series which is our Long Term Support (LTS) version
|
|||
|
|
https://www.openssl.org/source/
|
|||
|
|
https://www.openssl.org/source/openssl-1.1.1l.tar.gz
|
|||
|
|
https://www.openssl.org/source/openssl-1.1.1m.tar.gz
|
|||
|
|
|
|||
|
|
## pcre
|
|||
|
|
http://www.pcre.org/
|
|||
|
|
https://sourceforge.net/projects/pcre/files/pcre/8.45/
|
|||
|
|
|
|||
|
|
pcre-8.44.tar.gz
|
|||
|
|
|
|||
|
|
## zlib
|
|||
|
|
http://www.zlib.net/
|
|||
|
|
http://www.zlib.net/zlib-1.2.11.tar.gz
|
|||
|
|
|
|||
|
|
|
|||
|
|
zlib-1.2.11.tar.gz
|