这边介绍的是对lnmp进行常见的环境配置,以及对常见的环境报错进行修复
一、nginx配置虚拟主机
server {
listen 80;
server_name www.tp5.com;
access_log /data/wwwlogs/tp5.log combined;
error_log /data/wwwlogs/tp5_error.log;
set $root /data/wwwroot/tp5/public;
location ~ \.php {
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
{
root $root;
}
location / {
root $root;
index index.html index.php;
if ( -f $request_filename) {
break;
}
if ( !-e $request_filename) {
rewrite ^(.*)$ /index.php/$1 last;
break;
}
}
}
二、常见报错及修复
1、提示 access denied
修改php.ini下的cgi.fix_pathinfo=0,把0改成1,如下
cgi.fix_pathinfo=1
2、提示 No input file specified
修改nginx配置文件中的fastcgi.conf,如下
fastcgi_param PHP_ADMIN_VALUE "open_basedir=/mnt/hgfs/www/:/tmp/:/proc/";
把open_basedir设置到php的目录或者父目录中/mnt/hgfs/www/