ubuntu 16.04+nginx+mysql+php7.1+laravel5.5环境

发布时间:2019-08-07 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了ubuntu 16.04+nginx+mysql+php7.1+laravel5.5环境脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

一、安装php7.1

#添加php
sudo add-apt-reposITory ppa:ondrej/php
#更新apt数据,载入php源数据
sudo apt update
#安装php-FPM
sudo apt install php7.1-fpm
sudo apt install php7.1

二、安装nginx

sudo apt install nginx

三、为laravel 5.5安装php扩展

sudo apt install php7.1-MySQL  mcrypt  php7.1-mcrypt  php7.1-mbstring  php7.1-XMl  oPEnssl

四、配置php配置

sudo vim /etc/php/7.1/fpm/php.ini

找到 cgi.fix_pathinfo 修改为 0 ,如下:
cgi.fix_pathinfo=0
保存并退出,因为这是一个可能的安全漏洞

五、为laravel配置nginx

sudo vi /etc/nginx/sites-enabled/default
server {
    listen 80 default_server;
    listen [::]:80 default_server;


    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.Debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a PRoduction server!
    #
    # include snippets/snakeoil.conf;


    root /VAR/www/htML/auth/public;


    # Add index.php to the list if you are using PHP
    index index.php index.html index.htm index.nginx-debian.html;


    server_name _;


    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ /index.php?$query_string;
    }


    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ .php$ {
    #    include snippets/fastcgi-php.conf;
    #
    #    # With php7.0-cgi alone:
    #    fastcgi_pass 127.0.0.1:9000;
    #    # With php7.0-fpm:
    #    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    #}


    location ~ .php$ {
        include snippets/fastcgi-php.conf;
    #
    #    # With php7.0-cgi alone:
    #    fastcgi_pass 127.0.0.1:9000;
    #    # With php7.0-fpm:
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
    #    fastcgi_index index.php;
        include fastcgi_params;
    }


    # deny access to .htaccess files, if apache's document root
    # concurs with nginx's one
    #
    #location ~ /.ht {
    #    deny all;
    #}
    location ~ /.(?!well-known).* {
        deny all;
    }
}

脚本宝典总结

以上是脚本宝典为你收集整理的ubuntu 16.04+nginx+mysql+php7.1+laravel5.5环境全部内容,希望文章能够帮你解决ubuntu 16.04+nginx+mysql+php7.1+laravel5.5环境所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。