1 terminal安裝 myzsh,hombrew
myzhs:
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2 安裝nginx,mysql,php(具體版本按需安裝)
brew install nginx
brew install mysql
brew install php
3 文件路徑
nginx: 項(xiàng)目目錄/usr/local/var/www/
配置文件 /usr/local/etc/nginx/nginx.conf
虛擬域名配置 /usr/local/etc/nginx/servers/.conf;
image.png
4.配置虛擬域名,device.conf內(nèi)容
server {
listen 80;
server_name local_device.dqd.com;
access_log /usr/local/etc/nginx/logs/device.access.log;
error_log /usr/local/etc/nginx/logs/device.error.log;
#####默認(rèn)請求
location / {
root /usr/local/var/www/device/webroot/index.php; #定義服務(wù)器的默認(rèn)網(wǎng)站根目錄位置
index index.php index.html index.htm; #定義首頁索引文件的名稱
# fastcgi_pass local.dongqiudi.com;
fastcgi_param SCRIPT_FILENAME /usr/local/var/www/device/webroot/index.php/$fastcgi_script_name;
include fastcgi_params;
try_files $uri $uri/ /index.php?$query_string;
}
# 定義錯(cuò)誤提示頁面
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
#PHP 腳本請求全部轉(zhuǎn)發(fā)到 FastCGI處理. 使用FastCGI默認(rèn)配置.
location ~ \.php$ {
root /usr/local/var/www/device/webroot/index.php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/var/www/device/webroot/index.php/$fastcgi_script_name;
include fastcgi_params;
}
#禁止訪問 .htxxx 文件
location ~ /\.ht {
deny all;
}
}
編輯hosts文件
vim /etc/hosts添加
127.0.0.1 local_device.dqd.com
重啟nginx
sudo nginx -s stop
sudo nginx
5 php添加擴(kuò)展
例如安裝redis擴(kuò)展下載好解壓,cd到redis擴(kuò)展目錄
1./usr/local/Cellar/php@7.0/7.0.30_1/bin/phpize
2../configure --with-php-config=/usr/local/Cellar/php@5.6/5.6.36_1/bin/php-config
3.make && make install
安裝成功會說明擴(kuò)展安裝目錄
/usr/local/Cellar/php@7.0/7.0.30_1/pecl/20151012
4.編輯php.ini加入
[redis] extension=/usr/local/Cellar/php@7.0/7.0.30_1/pecl/20151012/redis.so
重啟php
pkill php-fpm
/usr/local/Cellar/php@7.0/7.0.30_1/sbin/php-fpm -R
