laravel 使用lnmp安裝 注意事項

<!--php

  • @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安裝 注意事項

-->css

本文首發: 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 查找到修改html

  2. storage,bootstrap/cache目錄可寫權限
    chmod +x storage
    chmod +x bootstrap/cache
  3. 修改禁用函數
    php.ini

    2019-09-26-14-39-30

    把這個proc_open 幹掉mysql

  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/";
相關文章
相關標籤/搜索