关于thinkphp3.2部署到lnmp环境

关于thinkphp3.2部署到lnmp环境

1.安装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

2.修改:php.ini文件位置:/usr/local/php/etc/php.ini

搜索查找到:cgi.fix_pathinfo 配置项,默认为0,修改为1,开启 pathinfo 选项。

3.修改:nginx的配置文件

默认只有 include enable-php.conf,注释掉;
然后添加一行:include enable-php-pathinfo.conf

4.修改TP配置修改

‘URL_MODEL’ => 3, 文件:\ThinkPHP\Conf\convention.php

5.配置niginx


worker_processes auto;

error_log  /home/wwwlogs/nginx_error.log  crit;

pid        /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

events
    {
        use epoll;
        worker_connections 51200;
        multi_accept on;
    }

http
    {
        include       mime.types;
        default_type  application/octet-stream;

        server_names_hash_bucket_size 128;
        client_header_buffer_size 32k;
        large_client_header_buffers 4 32k;
        client_max_body_size 50m;

        sendfile   on;
        tcp_nopush on;

        keepalive_timeout 60;

        tcp_nodelay on;

        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        fastcgi_buffer_size 64k;
        fastcgi_buffers 4 64k;
        fastcgi_busy_buffers_size 128k;
        fastcgi_temp_file_write_size 256k;

        gzip on;
        gzip_min_length  1k;
        gzip_buffers     4 16k;
        gzip_http_version 1.1;
        gzip_comp_level 2;
        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
        gzip_vary on;
        gzip_proxied   expired no-cache no-store private auth;
        gzip_disable   "MSIE [1-6]\.";

        #limit_conn_zone $binary_remote_addr zone=perip:10m;
        ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.

        server_tokens off;
        access_log off;

server
    {
        listen 80 default_server;
        #listen [::]:80 default_server ipv6only=on;
        server_name _;
        index index.html index.htm index.php;
        root  /home/wwwroot/default/zbsj;

        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        #include enable-php.conf;
	include enable-php-pathinfo.conf;

	location ~ .php
	{	
	    set $path_info "";
	    set $real_script_name $fastcgi_script_name;
	    #如果地址与引号内的正则表达式匹配
	    if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
	    #将文件地址赋值给变量 $real_script_name
	    set $real_script_name $1;	
	    #将文件地址后的参数赋值给变量 $path_info
    	    set $path_info $2;
	    }
    
	    #配置fastcgi的一些参数
	    fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
	    fastcgi_param SCRIPT_NAME $real_script_name;
	    fastcgi_param PATH_INFO $path_info;
	}
	if (!-e $request_filename)
	{
	    #地址作为将参数rewrite到index.php上。
	    rewrite ^/(.*)$ /index.php/$1;
    	    #若是子目录则使用下面这句,将subdir改成目录名称即可。
	    #rewrite ^/subdir/(.*)$ /subdir/index.php/$1;
	}
        access_log  /home/wwwlogs/access.log;
    }
include vhost/*.conf;
}

6.ThinkPHP index.php入口文件添加以下代码

define('_PHP_FILE_',$_SERVER['SCRIPT_NAME']);
define('__APP__', '');

3.Linux 下ThinkPHP项目出现_STORAGE_WRITE_ERROR_:./Application/Runtime/Cache/Admin/0dfec61edd66f450033aa87c28a760f4.php 因为日志文件夹没有执行权限.这时要给他加上权限

执行以下命令 :sudo chmod -R 777 Runtime

猜你喜欢

转载自blog.csdn.net/wolegequ1993/article/details/91359013