centos7.9安装编译安装nginx - 程序员中文网-程序员中文网 centos7.9安装编译安装nginx - 程序员中文网-程序员中文网
欢迎光临
我们一直在努力

centos7.9安装编译安装nginx

centos7.9安装编译安装nginx安装步骤:

1、 安装wget

yum -y install wget

2、 安装编译工具和依赖

yum -y install gcc gcc-c++ make libtool zlib zlib-devel openssl openssl-devel pcre pcre-devel

2、 下载Nginx安装包

wget http://nginx.org/download/nginx-1.23.2.tar.gz

3、解压Nginx压缩包

tar zxvf nginx-1.23.2.tar.gz

4、进入Nginx目录下

cd nginx-1.23.2

5、配置安装运行目录

需要SSL

./configure --prefix=/www/server/nginx --with-http_stub_status_module --with-http_ssl_module

不需要SSL

./configure --prefix=/www/server/nginx

6、执行编译安装

make && make install

7、启动nginx

/www/server/nginx/sbin/nginx

8、配置php

打开/www/server/nginx/conf目录下nginx的nginx.conf
location ~ \.php{
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scriptsfastcgi_script_name;
            include        fastcgi_params;
        }

fastcgi_param SCRIPT_FILENAME scriptsfastcgi_script_name;
改成  
fastcgi_param SCRIPT_FILENAME /Users/linchen/Sitesfastcgi_script_name;

修改index.php默认执行文件
location / {
            root   html;
            index  index.php index.html index.htm;
        }

最终配置
location ~ \.php{
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param SCRIPT_FILENAMEdocument_root$fastcgi_script_name;
            include        fastcgi_params;
        }

9、测试文件

打开/www/server/nginx/html目录创建index.php写入
<?php

     phpinfo();

?>

10、访问

http://127.0.0.1:80

赞(3)
未经允许不得转载:程序员中文网 » centos7.9安装编译安装nginx
手机电脑