Warning: file_get_contents() expects exactly 1 parameter, 5 given in /www/wwwroot/www.zc91.cn/wp-includes/functions.php on line 6620

Warning: file_get_contents() expects exactly 1 parameter, 5 given in /www/wwwroot/www.zc91.cn/wp-includes/functions.php on line 6620
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  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }

fastcgi_param SCRIPT_FILENAME scripts$fastcgi_script_name;
改成  
fastcgi_param SCRIPT_FILENAME /Users/linchen/Sites$fastcgi_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_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

9、测试文件

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

     phpinfo();

?>

10、访问

http://127.0.0.1:80

未经允许不得转载:紫竹林-程序员中文网 » centos7.9安装编译安装nginx
关于我们 免责申明 意见反馈 隐私政策
程序员中文网:公益在线网站,帮助学习者快速成长!
关注微信

微信扫码
关注微信

技术交流群
管理员微信号
每天精选资源文章推送
管理员QQ
随时随地碎片化学习
管理员抖音号
发现有趣的