分类:运维 发布时间:2018-02-24 18:43:00
测试环境 - centos 6.5(7) - lnmp1.4 ### 1、安装LNMP稳定版(<a href="https://lnmp.org" target="_blank">来源</a>) ``` wget -c http://soft.vpser.net/lnmp/lnmp1.4.tar.gz && tar zxf lnmp1.4.tar.gz && cd lnmp1.4 && ./install.sh lnmp ``` ### 2、将代码传到对对应目录下 如果使用ftp方式就直接跳到步骤 3 ### 3、执行 composer install 命令 如果报错 1、网络原因,请自行解决 2、提示函数被禁言。打开php安装目录,找到 php.ini 中文件,修改禁用函数字段,删除被禁言的函数 默认路径 /usr/local/php/etc ### 4、访问网站提示500 错误 一、修改对应 nginx 配置文件,我这里直接修改 nignx.conf 文件。具体配置如下 ``` server { listen 80; #listen [::]:80; # 修改成你的网站域名 server_name zlhvc.com ; index index.html index.htm index.php default.html default.htm default.php; # 指向程序目录 root /home/wwwroot/public; #error_page 404 /404.html; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } #注意这里注释掉不然 报错500 ,因为引入了php 配置,其中有句 try_files 开启就有报错 #include enable-php.conf; #按laravel文档配置 location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { # try_files $uri /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } #以下保持默认 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/accsee.log; } ``` 二、如果需要配置 https 这修改如下 ``` server { listen 443 ssl; server_name zlhvc.com; ssl on; root /home/wwwroot/blog/public; # 在配置文件目录下新建cert文件夹,将两个文件传到文件夹内,下面两个值修改成你的值 ssl_certificate cert/111111111.pem; ssl_certificate_key cert/11111111.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; location / { try_files $uri $uri/ /index.php?$query_string; index index.html index.htm index.php; } # 添加php执行 location ~ \.php$ { #fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } } } ``` 三、搜索并删除 .user.ini 文件 ``` find ./ -name .user.ini //搜索文件,如果没有搜到就直接进入第四步 chattr -i .user.ini //修改权限 rm .user.ini //删除文件 ``` 四、修改 fastcgi.conf 文件 ``` fastcgi_param PHP_ADMIN_VALUE "open_basedir=网站根目录路径:/tmp/:/proc/" 例如:fastcgi_param PHP_ADMIN_VALUE "open_basedir=/home/wwwroot/:/tmp/:/proc/"; ``` 注意这里目录要指向 public 上一层目录 五、如果提示 Unknown character set: 'utf8mb4' 错误 产生原因:mysql5.1 及之前没有 utf8mb4 编码。 解决方案:打开 config/database.php,将 utf8mb4 修改成 utf8 ``` 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', ``` 六、修改storage目录权限为777 进入程序根目录,执行 ``` chmod -R 777 storage/ ```
搜索
文章分类
最新文章