美文网首页
Centos7 安装Nginx

Centos7 安装Nginx

作者: ananRunner | 来源:发表于2021-05-08 16:14 被阅读0次

一、编译安装

1、安装编译安装所需要的依赖
yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
2、下载Nginx
yum install -y wget
wget https://nginx.org/download/nginx-1.18.0.tar.gz
3、解压
tar zxf nginx-1.18.0.tar.gz
cd nginx-1.18.0
4、编译安装(默认设置)
./configure

make && make install
5、查看安装目录
whereis nginx

nginx: /usr/local/nginx
6、启动Nginx
cd /usr/local/nginx/sbin

./nginx

7、查看Nginx是否运行
[root@localhost nginx]# ps -ef | grep nginx
root     12070     1  0 09:54 ?        00:00:00 nginx: master process ./sbin/nginx
nobody   12071 12070  0 09:54 ?        00:00:00 nginx: worker process
root     17581  4023  0 16:05 pts/0    00:00:00 grep --color=auto nginx

8、查看Nginx默认监听端口
vi /usr/local/nginx/conf/nginx.conf
 
--修改保存之后必须重启Nginx


./nginx -s reload

二、yum安装

1、安装
yum install -y nginx
2、启动Nginx并设置开机启动
systemctl start nginx

systemstl enable nginx

3、验证Nginx是否启动
[root@localhost nginx]# ps -ef | grep nginx
root     12070     1  0 09:54 ?        00:00:00 nginx: master process ./sbin/nginx
nobody   12071 12070  0 09:54 ?        00:00:00 nginx: worker process
root     17581  4023  0 16:05 pts/0    00:00:00 grep --color=auto nginx
4、查看Nginx配置文件
vi /etc/nginx/nginx.conf
5、yum安装Nginx,配置文件修生效,重启Nginx
systemctl restart nginx
6、网页查看

Nginx默认的监听端口为80

相关文章

网友评论

      本文标题:Centos7 安装Nginx

      本文链接:https://www.haomeiwen.com/subject/nsiudltx.html