lnmp+thinkphp5(5.0.10)+git

lnmp安装

lnmp安装教程:https://lnmp.org/install.html

lnmp相关软件目录及文件位置:https://lnmp.org/install.html

安装完lnmp之后需要配置一下nginx

  1. 配置nginx.conf

    一般默认就行

  2. 配置vhost

    为了支持pathinfo改为如下配置

    server
       {
           listen 80;
           #listen [::]:80;
           server_name www.xxx.com;
           index index.php index.html index.htm;
           root  /home/wwwroot/www.xxx.com/public;  #因为thinkphp5的入口文件是在public/下的
    
           error_page   403 404 500  = /404.html;
    
           # Deny access to PHP files in specific directory
           #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
    
            #引入下面这个就能支持pathinfo 不能隐藏入口文件但是为了支持www.xxx.com/user/index/login这个格式采取下面两个locatin形式进行替换
           #include enable-php-pathinfo.conf;  
    
           location / {
               index  index.html index.htm index.php; 
               #autoindex  on;
               #转发规则,支持url重写 主要是为了隐藏入口文件 
               if (!-e $request_filename) {
                   rewrite  ^(.*)$  /index.php?s=$1  last;
                   break;
               }
           }
           location ~ [^/]\.php(/|$)
           {
               fastcgi_pass  unix:/tmp/php-cgi.sock;    
               fastcgi_index index.php;             
               include fastcgi_params;                  
               include pathinfo.conf;                   
               fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
               fastcgi_param PHP_ADMIN_VALUE "open_basedir=/home/wwwroot/www.xxx.com/:/tmp/:/proc/"; 
           }
    
           location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
           {
               expires      30d;
           }
    
           location ~ .*\.(js|css)?$
           {
               expires      12h;
           }
    
           location ~ /.well-known {
               allow all;
           }
    
           location ~ /\.
           {
               deny all;
           }
    
           access_log  /home/wwwlogs/www.xxx.com.log;
           error_log   /home/wwwlogs/www.xxx.com.error.log;
       }

    关于上面的配置参考以下几篇文章

    nginx配置详细的介绍

    tp5 URL重写

    tp5部署linux主机环境

    nginx的配置这样基本就ok了

配置php.ini

因为tp5框架有一个函数scandir被禁用所以修改php.ini文件

找到disable_functions这一行代码删除scandir

通过以上的配置tp5框架基本能跑起来了,但是会报没有写入runtime权限所以需要进入项目添加权限 (如果没有runtime先mkdir runtime) chmod 777 runtime


git配置

为什么要用git?当然是方便管理啊

搭建git服务器

主要参考廖大神做的,搭建完之后,本地和服务器上都git clone一下

提醒:最好不要把配置文件之类的都传到git上
ok~ 配置完成,可以快乐的玩耍了~~~

你可能感兴趣的:(运维)