centos6 安装nginx最新稳定版

首先, 看这里: http://nginx.org/en/linux_packages.html#stable

 

 

第一步: 在/etc/yum.repos.d/下创建nginx.repo文件

第二步: 编辑nginx.repo文件, 内容如下: 

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

第三步: 安装nginx

yum install nginx

第四步: 编辑nginx.conf

vim /etc/nginx/nginx.conf
server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.php index.html index.htm;
    }

    #error_page  404              /404.html;

    # 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$ {
        # root           html;
        root           /usr/share/nginx/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        # fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        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;
    #}
}

第五步: 启动php-fpm(你可以将它理解为PHP的解释器)

service php-fpm start
[root@proxyin php-fpm.d]# ps -ef | grep php-fpm
root       9707      1  0 03:41 ?        00:00:00 php-fpm: master process (/etc/php-fpm.conf)
apache     9708   9707  0 03:41 ?        00:00:00 php-fpm: pool www            
apache     9709   9707  0 03:41 ?        00:00:00 php-fpm: pool www            
apache     9710   9707  0 03:41 ?        00:00:00 php-fpm: pool www            
apache     9711   9707  0 03:41 ?        00:00:00 php-fpm: pool www            
apache     9712   9707  0 03:41 ?        00:00:00 php-fpm: pool www            
root       9715   7933  0 03:41 pts/3    00:00:00 grep php-fpm

第六步: 浏览器输入ip地址进行访问

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在CentOS 8上安装Nginx的步骤如下: 1. 首先,下载Nginx安装包。可以使用以下命令下载最新稳定版本: ``` wget -c https://nginx.org/download/nginx-1.12.0.tar.gz ``` 2. 下载完成后,解压安装包并进入解压后的目录: ``` tar -zxvf nginx-1.12.0.tar.gz cd nginx-1.12.0 ``` 3. 安装Nginx所需的依赖库。在CentOS 8上,可以使用以下命令安装所需的依赖库: ``` yum install -y gcc pcre-devel openssl-devel ``` 4. 执行配置命令以配置Nginx的编译参数: ``` ./configure ``` 5. 编译并安装Nginx: ``` make make install ``` 6. 安装完成后,可以使用以下命令启动、停止或重启Nginx: ``` cd /usr/local/nginx/sbin/ 启动:./nginx 停止:./nginx -s stop 退出:./nginx -s quit 重启:./nginx -s reload ``` 请注意,以上命令中的路径可能会因个人安装的不同而有所变化,如果路径不同,请根据实际情况修改路径。 <span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [centos8安装nginx](https://blog.csdn.net/m0_55390780/article/details/119677449)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [Centos 8 安装 nginx](https://blog.csdn.net/qq_59636442/article/details/123936647)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值