时间:2021-07-01 10:21:17 帮助过:15人阅读
1. 安装PHP大礼包LNMP:
wget http://soft.vpser.net/lnmp/lnmp1.5.tar.gz -cO lnmp1.5.tar.gz && tar zxf lnmp1.5.tar.gz && cd lnmp1.5 && ./install.sh lnmp
包含了PHP,Nginx,Mysql等等,会默认增加www用户。
2. 启动php-fpm:
cd /usr/local/php/sbin sudo service php-fpm restart
3.修改nginx配置:
server
{
listen 80;
server_name _;
index index.html index.htm index.php;
root /www/phptest;
location ~ \.php {
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.*)")
{
set $real_script_name $1;
set $path_info $2;
}
fastcgi_pass unix:/tmp/php-cgi.sock; # 这里查看/usr/local/php/etc/php-fpm.conf的listen,保持一致
fastcgi_index index.php;
include fastcgi.conf;
include pathinfo.conf;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
...4.重启nginx:
cd /usr/local/nginx/sbin sudo service nginx restart
5. php中mysql配置(略),关键是要配置好数据库名,用户名,密码
6. 如果遇到翻页跳转失败的问题,在thinkphp的入口页index.php第一行加入:
define('_PHP_FILE_',$_SERVER['SCRIPT_NAME']);7. 在本机使用ip/index.php访问吧
相关文章推荐:
什么是Nginx代理服务?nginx正向代理和反向代理的实例
Nginx如何实现跨域访问?Nginx跨域访问的实现
以上就是Nginx配置PHP的详细步骤的详细内容,更多请关注Gxl网其它相关文章!