LNMP环境之Nginx安装与分析

1.安装nginx所需的pcre库,让nginx支持url重写的rewrite功能
yum install pcre pcre-devel -y

2.安装openssl-devel模块,nginx需要支持https
[root@web01 opt]# yum install openssl openssl-devel -y

2.1 安装gcc编译器
yum install gcc -y

3.下载nginx源码包
[root@web01 opt]# mkdir -p /home/chaoge/tools
[root@web01 opt]# cd /home/chaoge/tools/
[root@web01 tools]# wget http://nginx.org/download/nginx-1.16.0.tar.gz
[root@web01 tools]# echo $?
0

4.创建nginx普通用户
[root@web01 tools]# useradd nginx -u 1111 -s /sbin/nologin -M

5.开始解压缩编译nginx
[root@web01 tools]# tar -zxf nginx-1.16.0.tar.gz
[root@web01 nginx-1.16.0]# ./configure --user=nginx --group=nginx --prefix=/opt/nginx-1.16.0/ --with-http_stub_status_module --with-http_ssl_module
[root@web01 nginx-1.16.0]# echo $?
0
[root@web01 nginx-1.16.0]# make && make install
[root@web01 nginx-1.16.0]# echo $?
0

6.配置软连接,生产环境常用操作,便于运维、开发、测试使用,以及nginx以后的升级
[root@web01 nginx-1.16.0]# ln -s /opt/nginx-1.16.0/ /opt/nginx
[root@web01 nginx-1.16.0]# ll /opt/
总用量 0
lrwxrwxrwx  1 root  root   18 3月  18 22:45 nginx -> /opt/nginx-1.16.0/
drwxr-xr-x  6 root  root   54 3月  18 22:43 nginx-1.16.0

7.配置nginx环境变量
[root@web01 sbin]# echo 'PATH="$PATH:/opt/nginx/sbin"'  >> /etc/profile
[root@web01 sbin]# tail -1 /etc/profile
PATH="$PATH:/opt/nginx/sbin"



[root@web01 ~]# echo $PATH
/opt/nginx/sbin:/opt/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin

posted @ 2020-08-06 00:40  王子建  阅读(146)  评论(0编辑  收藏  举报