PHP项目部署 Linux 服务器
一。运行环境
- Centos7 x64
- lnmp (Linux , Nginx , Mysql , PHP/Python)
二。安装依赖和修改配置
安装Lnmp环境集成包:https://lnmp.org/install.html
wget -c http://soft.vpser.net/lnmp/lnmp1.4.tar.gz && tar zxf lnmp1.4.tar.gz && cd lnmp1.4 && ./install.sh lnmp
添加、删除虚拟主机及伪静态管理:https://lnmp.org/faq/lnmp-vhost-add-howto.html
lnmp vhost add 、 lnmp vhost list 、 lnmp vhost del
LNMP默认网站配置文件:/usr/local/nginx/conf/nginx.conf
LNMPA默认网站配置文件:/usr/local/nginx/conf/nginx.conf 和 /usr/local/apache/conf/extra/httpd-vhosts.conf
LAMP默认网站配置文件:/usr/local/apache/conf/extra/httpd-vhosts.conf
相关配置:
TP5 需要设置 防跨目录设置:https://lnmp.org/faq/lnmp-vhost-add-howto.html
LNMP 1.4上如果不想用防跨目录或者修改.user.ini的防跨目录的目录还需要将 /usr/local/nginx/conf/fastcgi.conf 里面的fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/"; 在该行行前添加 # 或删除改行,需要重启nginx。
1
/usr/local/php/etc/php.ini
找到disable_functions 后面的scandir删除掉这个函数。
lnmp restart
2
/usr/local/nginx/conf/vhost/域名.conf/
3
include enable-php.conf;
修改为
include enable-php-pathinfo.conf;
4 nginx 配置
server
{
listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;
#server_name _;
#server_name 127.0.0.1;
server_name 服务器ip;
index index.html index.htm index.php;
root /data/wwwroot/项目名/;
include enable-php.conf;
location / {
#autoindex on;
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=/$1 last;
}
}
}
5 网站访问目录指向public
6 设置相关目录权限
chmod -R 777 目录
7 如需要用到Redis 则需要PHP环境安装扩展支持Redis
https://lnmp.org/faq/addons.html
安装
进入lnmp解压后的目录,执行:./addons.sh install redis
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报