nginx降权+PHP匹配

本文详细指导如何下载Ubuntu系统,克隆备份,通过Xshell连接,并配置Nginx,包括安装依赖如libgd-dev和OpenSSL,解决编译时的PCRE和SSL模块问题,最后完成PHP和php-fpm的部署。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

下载Ubuntu系统并且进行克隆,可以在出现问题的时候直接切换另一个虚拟机进行使用

然后进行连接xshell (55条消息) 使用Xshell连接Ubuntu详解_steelbeng的博客-优快云博客_xshell连接ubuntu

安装依赖

sudo apt install libgd-dev

下载nginx

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

解压nginx

tar -zvxf nginx-1.22.1.tar.gz

编译安装

cd nginx-1.22.1

编译并指定安装位置,执行安装之后会创建指定文件夹/www/env/nginx

./configure --prefix=/www/env/nginx \
--with-pcre \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_image_filter_module \
--with-http_slice_module \
--with-mail \
--with-threads \
--with-file-aio \
--with-stream \
--with-mail_ssl_module \
--with-stream_ssl_module 

发现报错,检查不通过,则说明缺少某些依赖。需执行以下命令:

sudo apt-get install build-essential

然后再执行上面的检查命令,出现下面这种情况,则是检查通过

 然后在进行以上步骤

报错

./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre= option. PCRE库PCRE库支持正则表达式。如果我们在配置文件nginx.conf中使用了正则表达式,那么在编译Nginx时就必须把PCRE库编译进Nginx,因为Nginx的HTTP模块需要靠它来解析正则表达式。另外,pcre-devel是使用PCRE做二次开发时所需要的开发库,包括头文件等,这也是编译Nginx所必须使用的。

可以这样安装:

sudo apt update

sudo apt install libpcre3 libpcre3-dev

 又发现报错

./configure: error: SSL modules require the OpenSSL library. You can either do not enable the modules, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source with nginx by using --with-openssl= option OpenSSL库

如果服务器不只是要支持HTTP,还需要在更安全的SSL协议上传输HTTP,那么需要拥有OpenSSL。另外,如果我们想使用MD5、SHA1等散列函数,那么也需要安装它。  

可以这样安装:

sudo apt-get install openssl libssl-dev 执行编译并安装

成功!

make && make install

在浏览器进行连接

nginx常用命令:

nginx -s reload 修改配置后重新加载生效

nginx -s stop 快速停止

nginx nginx -s start 启动

nginx nginx -s quit 完整有序的停止

nginx nginx -v 查看nginx的版本

nginx -V 查看版本和nginx的配置选项

nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确

nginx -s reopen 重新打开日志文件  

创建普通用户

  1. useradd -d /home/test -m test

  2. passwd test

 切换用户

sudo su test

 测试是否可以启动nginx

 启动失败,需要创建相应文件

设置权限

php部署

安装php和php-fpm

查看服务运行状态

修改权限

配置php-fpm

修改配置监听9000端口来处理nginx的请求

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值