本文涉及PHP開(kāi)發(fā)中一些環(huán)境搭建,如Larval和Ngnix。
Nginx
Nginx啟動(dòng)關(guān)閉命令
#測(cè)試配置是否有語(yǔ)法錯(cuò)誤
nginx -t
#打開(kāi) nginx
sudo nginx
#重新加載配置|重啟|停止|退出 nginx
nginx -s reload|reopen|stop|quit
Nginx server 配置
- 進(jìn)入
/usr/local/etc/nginx目錄; - 使用
mkdir servers創(chuàng)建servers目錄; -
vim nginx.conf打開(kāi)nginx配置文件; - 在
nginx.conf文件中加入include servers/*;添加結(jié)果如http{ include servers/*; }, - 在servers目錄下,創(chuàng)建
*.conf文件,以下實(shí)例為laravel.conf
server {
listen 8081;
server_name localhost;
# 設(shè)定網(wǎng)站根目錄
root /Users/kevin/www/bi.service/public;
# 網(wǎng)站默認(rèn)首頁(yè)
index index.php index.html index.htm;
# 修改為 Laravel 轉(zhuǎn)發(fā)規(guī)則,否則PHP無(wú)法獲取$_GET信息,提示404錯(cuò)誤
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# PHP 支持
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}