centos下搭建lnmp環(huán)境運(yùn)行l(wèi)aravel應(yīng)用

軟件版本

  • nginx 1.12
  • mysql 5.7
  • php 7.2
  • redis 3.2
  • laravel 5.5

lnmp安裝

通過lnmp.org直接安裝nginx+mysql+php

網(wǎng)站配置

安裝完成后,軟件目錄/usr/local,網(wǎng)站默認(rèn)目錄/home/wwwroot
通過在/usr/local/nginx/conf/vhost中添加vhost,設(shè)置laravel應(yīng)用,具體內(nèi)容如下

server
    {
        listen 80;
        #listen [::]:80;
        server_name .tax.com ;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/tax/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-pathinfo.conf;
        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;
        }
        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/taxation.beke-off.lianjia.com.log;
        error_log /home/wwwlogs/error-tax.log;
    }

需要注意的是默認(rèn)的include enable-php-pathinfo.conf;這一行一定要注釋掉,并且使用上面的配置來指定fast-cgi的運(yùn)行方式,否則會(huì)報(bào)500錯(cuò)誤。
最后運(yùn)行即可。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容