码迷,mamicode.com
首页 > 其他好文 > 详细

centos7.2 安装nginx

时间:2018-01-27 00:42:57      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:分享图片   /etc   link   ice   htm   repo   systemd   pos   variable   

Nginx的安装

  • 安装快速HTTP服务器“的Nginx”并配置HTTP服务器# install from EPEL
[root@linuxprobe~]# yum --enablerepo=epel -y install nginx
# 基础设置
 [root@linuxprobe~]# vi /etc/nginx/nginx.conf
# line 40: change hostname
server_name linuxprobe.org; 
[root@linuxprobe ~]# systemctl start nginx 
[root@linuxprobe ~]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@linuxprobe ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain linuxprobe.org 
10.1.1.56 vdevops.com
# 开启防火墙
[root@linuxprobe ~]# firewall-cmd --add-service=http --permanent 
  提示FirewallD is not running  
  https://jingyan.baidu.com/article/5552ef47f509bd518ffbc933.html
success [root@linuxprobe ~]# firewall-cmd --reload success
  • 客户端设置主机,从浏览器访问linuxprobe.org 
    技术分享图片

虚拟主机设置

  • 配置nginx的
[root@linuxprobe ~]# vi /etc/nginx/conf.d/linuxcool.com.conf
# create new

server {
    listen       80;
    server_name  linuxcool.com;

    location / {
        root   /usr/share/nginx/linuxcool;
        index  index.html index.htm;
    }
}
[root@linuxprobe ~]# mkdir /usr/share/nginx/linuxcool
[root@linuxprobe w ~]# systemctl restart nginx
  • 创建测试页面
 [root@linuxprobe ~]# vi /usr/share/nginx/virtual.host/index.html
<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Nginx LinuxCool Test Page
</div>
</body>
</html>

技术分享图片

 

 

 

配置nginx视频

http://v.youku.com/v_show/id_XMjgwOTU2MDM1Mg==.html

centos7.2 安装nginx

标签:分享图片   /etc   link   ice   htm   repo   systemd   pos   variable   

原文地址:https://www.cnblogs.com/nyfz/p/8361921.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!