redhat 安装nginx过程完整记录

原创
2018/01/10 10:41
阅读数 2.5K

1、下载nginx安装包

在nginx官网http://nginx.org/ 下载linux的安装包nginx-1.13.8.tar.gz

2、上传到linux

用xftp上传到linux   /opt目录,之后解压。

tar -xzf nginx-1.13.8.tar.gz  

3、编译nginx

 [root@localhost opt]# cd nginx-1.13.8
[root@localhost nginx-1.13.8]# ./configure

报错,提示没有pcre库。

./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=<path> option.

4、安装pcre

在pcre官网http://www.pcre.org/下载压缩包pcre-8.41.tar.gz  ,同样上传到/opt目录

解压 tar -xzf pcre-8.41.tar.gz

安装pcre ,先编译

[root@localhost pcre-8.41]# ./configure

没通过,报错:

configure: error: You need a C++ compiler for C++ support.

需要安装c++编译器

[root@localhost pcre-8.41]# yum install -y gcc gcc-c++
安装成功后,再次编译pcre,通过。

make && make install 

5、再次编译nginx

重复第三步动作

6、安装nginx

make&&make install

安装成功。安装目录:/usr/local/nginx

7、启动并验证

cd /usr/local/nginx

[root@localhost nginx]# ./sbin/nginx 
./sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

再次报错

8、解决这个问题

增加软连接:

执行ls /lib64/ | grep pcre

会显示如下信息:

libpcre.so.0

libpcre.so.0.0.1

然后添加软连接:

执行命令ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1

 

[root@localhost nginx]# ls /lib64/ | grep pcre
libpcre.so.0
libpcre.so.0.0.1
[root@localhost nginx]# ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1
[root@localhost nginx]# ./sbin/nginx 

9、再次启动并验证

[root@localhost nginx]# ./sbin/nginx 
[root@localhost nginx]# ps -ef|grep ngnix
root     30494 19701  0 05:37 pts/0    00:00:00 grep ngnix
[root@localhost nginx]# ps -ef|grep nginx
root     30490     1  0 05:37 ?        00:00:00 nginx: master process ./sbin/nginx
nobody   30491 30490  0 05:37 ?        00:00:00 nginx: worker process
root     30496 19701  0 05:37 pts/0    00:00:00 grep nginx

浏览器访问正常。完成。

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
1 收藏
0
分享
返回顶部
顶部