menu LittleJake's Blog
color_lens
avatar
Jake Liu
Never Settle
creative commons by-nc-sa
hit
Category
keyboard_arrow_down

© 2024 LittleJake's Blog.

萌ICP备20223020号

记一次在Nginx部署ThinkPHP项目

timg (1).jpg

LNMP Setup Steps

Using Shell to proceed setup LNMP.

wget http://soft.vpser.net/lnmp/lnmp1.6.tar.gz -cO lnmp1.6.tar.gz && tar zxf lnmp1.6.tar.gz && cd lnmp1.6 && ./install.sh lnmp

Setup and change conf vhost/.conf

Main problems after setup

  1. pathinfo
  2. base_dir
  3. .htaccess

Pathinfo

Pathinfo problem is solved in the new version of LNMP. You can include it in the conf file rewrite/thinkphp.conf

Add code below into conf file:

include enable-php-pathinfo.conf;
location /
{
  try_files $uri $uri/ /index.php?s=$uri&$args;
  if (!-e $request_filename) {
    rewrite ^(.*)$ /index.php?s=/$1 last;
    break;
  }
}

base_dir

There are 3 possible conf files to change base_dir setting. nginx/conf/fastcgi.confphp.ini.user.ini

Comment the base_dir setting in fastcgi.conf can solve it.

.htaccess

Forbidden the access of .htaccess in file vhost/.conf.

location ~ /\.ht 
{
  deny all;
}

Buy me a beer

buymeacoffee
Jake Liu
Never Settle

Title: 记一次在Nginx部署ThinkPHP项目

Author: Jake Liu

Origin:

Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) For any re-post you must give appropriate credit.

文章遵循CC许可 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 转载请注明出处

Tag:thinkphp, nginx, lnmp

评论区

Add a new comment.

Theme