CentOS 7 yum 安装 Nginx
来源:互联网 发布:长沙淘宝仓库打包招聘 编辑:程序博客网 时间:2024/05/24 02:39
CentOS 7 yum 安装 Nginx
1.添加Nginx到YUM源
添加CentOS 7 Nginx yum资源库,打开终端,使用以下命令:
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2.安装Nginx
在你的CentOS 7 服务器中使用yum
命令从Nginx源服务器中获取来安装Nginx:
sudo yum install -y nginx
Nginx将完成安装在你的CentOS 7 服务器中。
3.启动Nginx
刚安装的Nginx不会自行启动。运行Nginx:
sudo systemctl start nginx.service
如果一切进展顺利的话,现在你可以通过你的域名或IP来访问你的Web页面来预览一下Nginx的默认页面;
如果看到这个页面,那么说明你的CentOS 7 中 web服务器已经正确安装。
CentOS 7 开机启动Nginx
sudo systemctl enable nginx.service
更多systemctl命令可查看《systemctl命令用法》
Nginx配置信息
网站文件存放默认目录
/usr/share/nginx/html
网站默认站点配置
/etc/nginx/conf.d/default.conf
自定义Nginx站点配置文件存放目录
/etc/nginx/conf.d/
Nginx全局配置
/etc/nginx/nginx.conf
Nginx启动
nginx -c nginx.conf
service nginx start
现在Nginx已经启动了,直接访问服务器就能看到Nginx欢迎页面了的。
如果还无法访问,则需配置一下Linux防火墙。
iptables -I INPUT 5 -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
service iptables save
service iptables restart
Nginx的命令以及配置文件位置:
service nginx start # 启动Nginx服务
service nginx stop # 停止Nginx服务
service nginx.conf # Nginx配置文件位置
现在Nginx已经启动了,直接访问服务器就能看到Nginx欢迎页面了的。
如果还无法访问,则需配置一下Linux防火墙。
iptables -I INPUT 5 -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
service iptables save
service iptables restart
Nginx的命令以及配置文件位置:
service nginx start # 启动Nginx服务
service nginx stop # 停止Nginx服务
service nginx.conf # Nginx配置文件位置
vi /etc/nginx/nginx.conf 更改root 配置 为新的web目录
This is the default index.html page that is distributed withnginx on Fedora. It is located in/usr/share/nginx/html.
You should now put your content in a location of your choice and edit theroot configuration directive in thenginx configuration file/etc/nginx/nginx.conf.
Linux查看公网IP
您可以运行以下命令来显示你的服务器的公共IP地址:
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
阅读全文
0 0
- CentOS 7 YUM 安装 Nginx
- CentOS 7 yum 安装 Nginx
- centos 7 yum 安装 NGINX
- centos 7 yum安装 nginx
- CentOS 7 yum 安装 Nginx
- CentOS 7 yum 安装 Nginx
- CentOS 7 yum 安装 Nginx
- CentOS 7 yum 安装 Nginx
- CentOS 7 YUM 安装 Nginx
- CentOS 7 yum 安装 Nginx
- CentOS 7 yum 安装 Nginx
- CentOS 7 YUM 安装 Nginx
- centos yum安装nginx
- CentOS yum 安装 nginx
- Centos yum 安装Nginx
- CentOS yum安装nginx
- CentOS 7 yum安装nginx-1.12.0
- CentOS 7下 yum方式安装Nginx
- jQuery Mobile学习笔记(一)——移动平台
- JavaScript 常用55个技巧
- Optimizing Rule Placement in Software-Defined Networks for Energy-aware Routing
- (六)redis常用数据类型 SortedSet
- 杂记——喵哥吃鱼的问题
- CentOS 7 yum 安装 Nginx
- Linux常用命令大全
- 代码中的小细节,让你感叹自己的强大
- 欧姆龙NX1P2编程学习(1)-编写功能块注意事项
- Matlab读取和写入excel表格文件
- (转载)多线程编程学习四(Lock 的使用)
- jQuery Mobile学习笔记(八)——安装及离线
- Echarts 使用 markLine 画线
- 20170914 js模拟事件,什么click()都是伪模拟