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

前端之家收集整理的这篇文章主要介绍了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;
    }
}
原文链接:https://www.f2er.com/ubuntu/350087.html

猜你在找的Ubuntu相关文章