您的位置:首页 > 运维架构 > Nginx

Linux下Nginx安装

2017-06-06 09:52 375 查看
0 下载地址

1 安装过程

2 安装中存在的问题
问题1 ./configure: error: the HTTP rewrite module requires the PCRE library.

问题2 ./configure: error: the HTTP gzip module requires the zlib library.

问题3 启动后无法访问,但是进程存在,且没有错误日志

问题4 启动报错

3 常用命令
3.1 启动

3.2 重启

3.3 关闭

3.4 检测配置文件是否正确

参考

0 下载地址

下载地址

1 安装过程

# 1.解压
tar -zxvf nginx-1.9.13.tar.gz
# 2.切换到解压后的目录
cd nginx-1.9.13
# 3.创建组和用户
groupadd -f www
useradd -g www www
# 4.配置(包含HTTP SSL模块)
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module
# 5.编译
make
# 6.安装
make install


2 安装中存在的问题

问题1 ./configure: error: the HTTP rewrite module requires the PCRE library.

You can either disable the module by using –without-http_rewrite_module

option, or install the PCRE library into the system, or build the PCRE library

statically from the source with nginx by using –with-pcre= option.

解决:

yum -y install pcre-devel


问题2 ./configure: error: the HTTP gzip module requires the zlib library.

You can either disable the module by using –without-http_gzip_module

option, or install the zlib library into the system, or build the zlib library

statically from the source with nginx by using –with-zlib= option.

解决:

yum -y install openssl openssl-devel


问题3 启动后无法访问,但是进程存在,且没有错误日志

解决:

# 关闭防火墙
systemctl stop firewalld.service


问题4 启动报错

./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

解决:

# 查找libpcre.so.1
find / -iname "libpcre.so.1"
# 结果
# /software/apache/pcre-8.34/.libs/libpcre.so.1
# /usr/local/lib/libpcre.so.1
# /usr/local/pcre-8.34/lib/libpcre.so.1

# 原因:
# 1.没装PCRE
# 2.PCRE包路径不在LD_LIBRARY_PATH下

# 方法1:设置LD_LIBRARY_PATH中包含pcre包的路径
# 这种方式使用export命令,所以只在本次登录生效
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

# 方法2:nginx默认会从/lib64或/lib下读取libpcre.so.1文件,所以设置软链接即可
ln -s /usr/local/lib/libpcre.so.1 /lib64/


3 常用命令

3.1 启动

cd /usr/local/nginx/sbin
./nginx


3.2 重启

/usr/local/nginx/sbin/nginx -s reload


3.3 关闭

#方法1:第一个是完整有序的停止,第二个是快速停止
/usr/local/nginx/sbin/nginx -s quit
/usr/local/nginx/sbin/nginx -s stop
#方法2:
pkill -9 nginx


3.4 检测配置文件是否正确

/usr/nginx/sbin/nginx -t


参考

linux下安装nginx

Nginx: error while loading shared libraries: libpcre.so.1解决

启动nginx,报错:error while loading shared libraries: libpcre.so.1:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: