安装nginx(默认监听80)

ngxinx : 强大的web项目发布服务软件!
 
1.支持域名解析
2.支持流量监控
3.对静态资源处理能力强大!
4.负载均衡配置.
反向解析等......
 
 
通过yum安装
centos 的软件源中默认无nginx软件,centos软件源位置: /etc/yum.repos.d/
# 1.添加nginx的软件源 
vi /etc/yum.repos.d/nginx.repo 
# 按i进入编辑模式 
[nginx] 
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
 
# 保存退出 :wq 
# 2. 安装 yum install -y nginx 
# 3. 添加为系统服务(可以开机自启动) 
systemctl enable nginx 
# 4. 启动/停止/重启 systemctl start/stop/reload nginx 
# 5. 查看运行的端口 netstat -atunp 
# 6. 本地访问nginx默认发布的首页 curl 127.0.0.1:80 # 80可以不写 
# 7. 关闭防火墙,外网可以通过Ip访问nginx默认的首页 
systemctl stop
firewalld.service
 
通过源码安装
# 1. 先下载 
cd /usr/local
wget http://nginx.org/download/nginx-1.13.7.tar.gz
# 2. 解压 tar -zxvf nginx-1.13.7.tar.gz # 3. 编译 cd nginx-1.13.7 ./configure # 4. 安装 make make insatll # 5. 启动并访问默认页面 cd /usr/local/nginx/sbin ./nginx #启动-------->启动成功后,可以访问默认的nginx页面
./nginx -s stop #停止
./nginx -s reload #重启
./nginx -t #检查nginx.conf配置文件的语法
# 6. 检查运行状态

netstat -atunp
# 查看80端口 


curl 127.0.0.1:80
# 本地访问默认页面 
 
http://IP地址:80
# 远程访问nginx默认页面 (前提:云服务器控制台手动打开80端口)
 
替换ngxin默认首页为自己的页面
# 1. 找nginx安装位置 
whereis nginx #(安装位置etc 中, 网页在:/usr/share/nginx/html中) 
# 2. 上传自己的网站到nginx的html目录 
# /usr/share/nginx/html

 

posted @ 2020-11-27 20:32  情~睿  阅读(673)  评论(0编辑  收藏  举报