CentOS 6.8 yum安装 Nginx

1、下载

# 切换到yum源目录
cd /etc/yum.repos.d

# 下载nginx yum源
wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm  

2、安装

# 安装,得到yum源文件nginx.repo
rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm

# 查看安装包
yum list | grep nginx

# 显示结果
nginx-release-centos.noarch                6-0.el6.ngx                   installed
nginx.x86_64                               1.16.0-1.el6.ngx              nginx  
nginx-debug.x86_64                         1.8.0-1.el6.ngx               nginx  
nginx-debuginfo.x86_64                     1.16.0-1.el6.ngx              nginx  
nginx-module-geoip.x86_64                  1.16.0-1.el6.ngx              nginx  
nginx-module-geoip-debuginfo.x86_64        1.16.0-1.el6.ngx              nginx  
nginx-module-image-filter.x86_64           1.16.0-1.el6.ngx              nginx  
nginx-module-image-filter-debuginfo.x86_64 1.16.0-1.el6.ngx              nginx  
nginx-module-njs.x86_64                    1.16.0.0.3.2-1.el6.ngx        nginx  
nginx-module-njs-debuginfo.x86_64          1.16.0.0.3.2-1.el6.ngx        nginx  
nginx-module-perl.x86_64                   1.16.0-1.el6.ngx              nginx  
nginx-module-perl-debuginfo.x86_64         1.16.0-1.el6.ngx              nginx  
nginx-module-xslt.x86_64                   1.16.0-1.el6.ngx              nginx  
nginx-module-xslt-debuginfo.x86_64         1.16.0-1.el6.ngx              nginx  
nginx-nr-agent.noarch                      2.0.0-12.el6.ngx              nginx  
pcp-pmda-nginx.x86_64                      3.10.9-9.el6                  base 

# 安装nginx
yum install nginx.x86_64  

3、启动

service nginx start

4、nginx配置文件 

# 配置php
vi /etc/nginx/conf.d/default.conf

* $document_root:# 网站的根目录,在server配置中root指令中指定的值 

server {
    listen       80;   #配置监听端口
    server_name  localhost;  #配置域名
    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    root   /usr/share/nginx/html;     #服务默认启动目录
    index  index.php index.html index.htm;    #默认访问文件

    #error_page  404              /404.html;   # 配置404页面
    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;   #错误状态码的显示页面,配置后需要重启
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值