nginx部署
一、安装nginx
1.下载所需的安装包并上传到指定服务器
openssl: https://mchapp.gitee.io/blog/2021/08/10/Linux%E5%AE%89%E8%A3%85nginx/openssl-1.1.1b.tar.gz
zlib:https://mchapp.gitee.io/blog/2021/08/10/Linux%E5%AE%89%E8%A3%85nginx/zlib-1.2.11.tar.gz
pcre:https://mchapp.gitee.io/blog/2021/08/10/Linux%E5%AE%89%E8%A3%85nginx/pcre-8.42.tar.gz
nginx:https://mchapp.gitee.io/blog/2021/08/10/Linux%E5%AE%89%E8%A3%85nginx/nginx-1.15.12.tar.gz
2.root用户操作,chmod 777 * 授权所有文件
3.按照顺序依次安装
(1)首先安装openssl库
[root@localhost ~]# tar -zxvf openssl-1.1.1b.tar.gz [root@localhost ~]# cd openssl-1.1.1b [root@localhost ~]# ./config [root@localhost ~]# make [root@localhost ~]# make install
(2)安装zlib库
[root@localhost ~]# tar -zxvf zlib-1.2.11.tar.gz [root@localhost ~]# cd zlib-1.2.11 [root@localhost ~]# ./configure [root@localhost ~]# make [root@localhost ~]# make install
(3)安装pcre库
[root@localhost ~]# tar -zxvf pcre-8.42.tar.gz [root@localhost ~]# cd pcre-8.42 [root@localhost ~]# ./configure [root@localhost ~]# make [root@localhost ~]# make install
(4)安装nginx
[root@localhost ~]# tar -zxvf nginx-1.15.12.tar.gz [root@localhost ~]# cd nginx-1.15.12 [root@localhost ~]# ./configure [root@localhost ~]# make [root@localhost ~]# make install
4.配置nginx.conf
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf 将server_name的值改为ip地址
5.进入sbin目录下,使用已下命令启动
[root@localhost ~]# ./nginx 启动 [root@localhost ~]# ./nginx -s stop 关闭 [root@localhost ~]# ./nginx -s reload 重启
6.在vi /etc/rc.local中,添加 /usr/local/nginx/sbin/nginx
[root@localhost ~]# vim /etc/rc.local 最后一行添加 /usr/local/nginx/sbin/nginx
7.访问nginx服务器
curl localhost:80