centos7 nginx安装
2016-04-12 08:03
483 查看
阿里云上买了个域名,准备玩一下。安装nginx
官网地址:
官方文档,一步步来。
添加nginx源:
更新缓存
安装,好小
开启服务:
查看一下我们的公网ip
在浏览器中输入ip
出现页面,则说明成功
nginx默认配置文件:
最后添加防火墙规则:
官网地址:
http://nginx.org/
官方文档,一步步来。
添加nginx源:
[root@xyjk1002 ~]# cat /etc/yum.repos.d/nginx.repo [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1
更新缓存
[root@xyjk1002 ~]# yum clean all & yum makecache
安装,好小
[root@xyjk1002 yum.repos.d]# yum install nginx Loaded plugins: langpacks Resolving Dependencies --> Running transaction check ---> Package nginx.x86_64 1:1.8.1-1.el7.ngx will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================================================================== Package Arch Version Repository Size ============================================================================================================================================================================================================================== Installing: nginx x86_64 1:1.8.1-1.el7.ngx nginx 372 k Transaction Summary ============================================================================================================================================================================================================================== Install 1 Package Total download size: 372 k Installed size: 897 k Is this ok [y/d/N]:
开启服务:
[root@xyjk1002 ~]# systemctl start nginx.service
查看一下我们的公网ip
[root@xyjk1002 ~]# ip addr show eth1 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
在浏览器中输入ip
出现页面,则说明成功
nginx默认配置文件:
[root@xyjk1002 ~]# cat /etc/nginx/conf.d/default.conf server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { root /usr/share/nginx/html;//网站根目录位置 index index.html index.htm;//网站首页默认页面名称 }
最后添加防火墙规则:
[root@xyjk1002 ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent success [root@xyjk1002 ~]# firewall-cmd --reload success [root@xyjk1002 ~]# firewall-cmd --list-all public (default) interfaces: sources: services: dhcpv6-client ssh ports: 80/tcp 22/tcp masquerade: no forward-ports: icmp-blocks: rich rules:
相关文章推荐
- nginx配置成服务
- 如何利用Nginx的缓冲、缓存优化提升性能
- Net分布式系统之三:Keepalived+LVS+Nginx负载均衡之高可用
- nginx gzip开启与配置
- Nginx学习笔记--Nginx图片缩略图,水印处理模块
- [Nginx 2] form表单提交,图片上传
- [Nginx 2] form表单提交,图片上传
- Nginx探索五
- Nginx服务器
- Nginx探索四
- Nginx探索三
- nginx 学习笔记(2) nginx新手入门
- Nginx学习(1)nginx安装
- Nginx探索二
- Nginx+FastCGI运行原理
- nginx 各种配置
- Nginx安装及配置文件nginx.conf详解
- nginx实操(1)安装及选项说明
- Nginx Location处理逻辑(优先级)权威解读
- NGINX-PHP组合