laravel 使用lnmp安装 注意事项

西树先森

<!--

  • @Author: starkwang
  • @Contact me: https://shudong.wang/about
  • @Date: 2019-09-25 11:38:25
  • @LastEditors: starkwang
  • @LastEditTime: 2019-09-26 14:50:26
  • @Description: laravel 使用lnmp安装 注意事项

-->

本文首发:https://shudong.wang/10565.html

怎么删除 user.ini

chattr -i .user.ini

安装 zsh

apt-get update
apt-get install zsh git -y

使用ake

sh -c "$(curl -fsSL https://raw.githubusercontent.com/wsdo/ake/master/install.sh)"

mysql 远程连接

1. 允许远程ip连接
mysql -u root -p 
mysql>use mysql; 
mysql>update user set host = '%' where user = 'root'; 
mysql>flush privileges;
mysql>exit;
 
root可以换成你的用户名
 
如果没有创建用户,执行grant all PRIVILEGES on 数据库名.* to 用户名@'%' identified by '密码'

2. 关闭防火墙
iptables -L -n --line-numbers
iptables -D INPUT 7 #(代表3306端口的)

生成 ssh-keygen

ssh-keygen -t rsa -C "wsd312@163.com"

laravel 安装

composer install --optimize-autoloader --no-dev
cp .env.example .env

注意事项

  1. 首先开启php.ini中的错误提示:display_error=on; 这个环境中默认是off
    vim /usr/local/php/etc/php.ini

    /display_error 查找到修改

  2. storage,bootstrap/cache目录可写权限
    chmod +x storage
    chmod +x bootstrap/cache
  3. 修改禁用函数
    php.ini

    2019-09-26-14-39-30

    把这个proc_open 干掉

  4. fastcgi.conf 里面的open_basedir 注释掉 (public禁止访问外层)
/usr/local/nginx/conf/fastcgi.conf

#fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";
  1. 删除 .user.ini
    chattr -i .user.ini rm .user.ini
  2. 重启:lnmp reload

nginx 重启

lnmp nginx reload

php-fpm 重启

lnmp php-fpm reload

都重启

lnmp reload

nginx配置文件

server
    {
        listen 80;
        #listen [::]:80;
        server_name v1.shudong.wang ;
        index index.php index.htm index.php default.html default.htm default.php;
        root  /home/shudong/api/public;

        include rewrite/laravel.conf;
        #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;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log off;
    }

fastcgi 配置文件

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REQUEST_SCHEME     $scheme;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;
#fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";
阅读 756

西树与前端
关注西树教育「[链接]」,每天进步一点。

从事开发多年,前端、后端(go、Python、php)、服务架构都有涉猎,经历过大公司、创业公司,擅长前端及...

7k 声望
915 粉丝
0 条评论

从事开发多年,前端、后端(go、Python、php)、服务架构都有涉猎,经历过大公司、创业公司,擅长前端及...

7k 声望
915 粉丝
文章目录
宣传栏