centos7.2 安装nginx

Posted 让双脚&去腾空

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7.2 安装nginx相关的知识,希望对你有一定的参考价值。

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
  • 创建测试页面
 [[email protected] ~]# 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的主要内容,如果未能解决你的问题,请参考以下文章

CentOS7.2安装配置nginx+flask+python+uwsgi运行环境

CentOS7.2安装配置nginx+uwsgi+python+flask运行环境

CentOS7.2编译安装LNMP

解决在centos7.2下YUM安装nginx-1.12.2依赖的问题

centos7.2下pip3 + python3.5 + django + nginx + uwsgi

centos7.2源码安装php7.0.9和nginx1.10.3服务器