lnmp 给tp5配置虚拟主机

这边介绍的是对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/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容