linux服务下安装nginx 系统版本Ubuntu 18.04.4
一、下载nginx包(已存入我的百度网盘)
链接:https://pan.baidu.com/s/19e4FbscqZXNrPPnpDwaIDQ
提取码:4mj9
或者到官网下载:http://nginx.org/en/download.html
二、将上面的包上传到服务器(我习惯直接传到root目录下)
三、依次安装
openssl-fips-2.0.12.tar.gz,
zlib-1.2.8.tar.gz,
pcre-8.42.tar.gz,
nginx-1.10.1.tar.gz
安装openssl-fips-2.0.12.tar.gz
[root@localhost mrms]# tar -zxvf openssl-fips-2.0.12.tar.gz
[root@localhost mrms]# cd openssl-fips-2.0.12
[root@localhost openssl-fips-2.0.12]# ./config
[root@localhost openssl-fips-2.0.12]# make
[root@localhost openssl-fips-2.0.12]# make install
安装zlib-1.2.8.tar.gz
[root@localhost mrms]#
[root@localhost mrms]# cd zlib-1.2.8
[root@localhost zlib-1.2.8]# ./configure
[root@localhost zlib-1.2.8]# make
[root@localhost zlib-1.2.8]# make install
安装pcre-8.38.tar.gz
[root@localhost mrms]# tar -zxvf pcre-8.42.tar.gz
[root@localhost mrms]# cd pcre-8.42
[root@localhost pcre-8.21]# ./configure
[root@localhost pcre-8.21]# make
[root@localhost pcre-8.21]# make install
出错:libtool: warning: relinking 'libpcrecpp.la'
解决办法:./configure --disable-shared --with-pic
之后执行:make 没有错误
安装 nginx-1.10.1.tar.gz
[root@localhost mrms]# tar -zxvf nginx-1.10.1.tar.gz
[root@localhost mrms]# cd nginx-1.10.1
[root@localhost nginx-1.10.1]# ./configure --prefix=/usr/local/nginx --with-pcre=../pcre-8.42 --with-zlib=../zlib-1.2.8 --with-openssl=../openssl-fips-2.0.12
[root@localhost nginx-1.10.1]# make
[root@localhost nginx-1.10.1]# make install
如果:make出错:src/core/ngx_murmurhash.c:37:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
h ^= data[2] << 16;
~~^~~~~~~~~~~~~~~~
解决办法:进入到nginx-1.6.3目录下(解压的目录)
找到当前目录下找到objs文件夹,并进入,打开文件Makefile,找到有一下内容的这行:
CFLAGS = -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g
把这行内容中的 “-Werror”去掉
-Werror: gcc将所有的警告当成错误进行处理
##########至此Nginx的安装完成!############
四、检测是否安装成功
ps -ef | grep xxx
[root@localhost nginx-1.2.6]# cd /usr/local/nginx/sbin
[root@localhost sbin]# ./nginx -t
出现如下所示提示,表示安装成功
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
如果报错提示:./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
执行命令:ldconfig -v|grep pcre
启动nginx:
[root@localhost sbin]# ./nginx
查看端口
[root@localhost sbin]# netstat -ntlp
结果如下
##########至此Nginx的安装启动完成!############
标签:pcre,18.04,tar,gz,nginx,Ubuntu,root,localhost
来源: https://www.cnblogs.com/cg-take/p/13099790.html