国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網(wǎng)站 > 建站經(jīng)驗(yàn) > 正文

全新Mac配置PHP開發(fā)環(huán)境教程

2024-04-25 20:16:35
字體:
供稿:網(wǎng)友

趁著這次加硬盤的機(jī)會(huì),就準(zhǔn)備徹底重做開發(fā)環(huán)境,現(xiàn)在對(duì)Mac也有了一定的了解,特地記錄一下本次的開發(fā)環(huán)境安裝詳情,給自己一個(gè)備忘,希望也可以幫助到剛接觸Mac環(huán)境的同學(xué)們。

用了一年的Mac OS X了,之前不熟悉這個(gè)系統(tǒng),用的是系統(tǒng)自帶的PHP以及DMG包安裝的MySQL,時(shí)間長了,慢慢覺得MacBook的速度跟不上了,雖然關(guān)機(jī)次數(shù)不多,但是每次開機(jī),或者喚醒電腦的時(shí)候,系統(tǒng)明顯有一定時(shí)間的卡頓。特別表現(xiàn)在開機(jī)的時(shí)候。完全可以去泡一個(gè)來一桶了。因此干掉MD101上的光驅(qū),換上256G的Sandisk SSD, 干掉原廠的2G 2,換上8G 2 。 速度應(yīng)該是杠杠的了,至少可以再服役2年吧。

趁著這次加硬盤的機(jī)會(huì),就準(zhǔn)備徹底重做開發(fā)環(huán)境。現(xiàn)在對(duì)Mac也有了一定的了解,特地記錄一下本次的開發(fā)環(huán)境安裝詳情,給自己一個(gè)備忘,希望也可以幫助到剛接觸Mac

環(huán)境的同學(xué)們。本開發(fā)環(huán)境,全部基于HomeBrew安裝。

主要軟件版本:PHP5.5.14,Nginx 1.6.0,MySQL5.6.19

OS X Mavericks

重新安裝系統(tǒng),在蘋果商店下載好OS X Mavericks安裝文件,然后準(zhǔn)備一支16G的USB3.0 U盤。制作 OSX Mavericks全新安裝啟動(dòng)U盤。

插上U盤,在終端執(zhí)行:

  1. sudo /Applications/Install/ OS/ X/ 
  2. Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/untitled 
  3. --applicationpath /Applications/Install/ OS/ X/ Mavericks.app --nointeraction 

untitled 是你的u盤盤符,根據(jù)實(shí)際情況來,代碼如下:

  1. Erasing Disk: 0%… 10%… 20%… 30%…100%… 
  2. >Copying installer files to disk… 
  3. Copy complete. 
  4. Making disk bootable… 
  5. Copying boot files… 
  6. >Copy complete. 
  7. >Done. 

看到上面的信息說明啟動(dòng)盤制作成功。 安裝起來so easy :)

安裝完成系統(tǒng)之后, 暫時(shí)還沒有去遷移文件,由于本人喜好攝影,有大量RAW格式的原圖在Aperture的照片庫中,尼康D800一張RAW文件有40M左右,到時(shí)候遷移照片庫和照片流希望不要掉坑里了。 等開發(fā)環(huán)境搞定再說了,更新OS X系統(tǒng)到10.9.4,然后安裝最新的Xcode, 以及在商店買過的軟件,確定系統(tǒng)無問題了,進(jìn)入下一步...

Brew

Brew 是 Mac 下面的包管理工具,通過 Github 托管適合 Mac 的編譯配置以及 Patch,可以方便的安裝開發(fā)工具。 Mac 自帶ruby,所以安裝起來很方便,同時(shí)它也會(huì)自動(dòng)把git也給你裝上。官方網(wǎng)站: <http://brew.sh>; 。

安裝完成之后,建議執(zhí)行一下自檢,brew doctor如果看到

Your system is ready tobrew.那么你的brew已經(jīng)可以開始使用了。

安裝:

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"

自檢:

brew doctor

常用命令: (所有軟件以PHP5.5為例子)

brew update #更新brew可安裝包,建議每次執(zhí)行一下

brew search php55 #搜索php5.5

brew tap josegonzalez/php #安裝擴(kuò)展<gihhub_user/repo>

brew tap #查看安裝的擴(kuò)展列表

brew install php55 #安裝php5.5

brew remove php55 #卸載php5.5

brew upgrade php55 #升級(jí)php5.5

brew options php55 #查看php5.5安裝選項(xiàng)

brew info php55 #查看php5.5相關(guān)信息

brew home php55 #訪問php5.5官方網(wǎng)站

brew services list #查看系統(tǒng)通過 brew 安裝的服務(wù)

brew services cleanup #清除已卸載無用的啟動(dòng)配置文件

brew services restart php55 #重啟php-fpm

注意:brew services 相關(guān)命令最好別經(jīng)常用了,提示會(huì)被移除

代碼如下:

  1. ~ brew services restart php55 
  2. Warning: brew services is unsupported and will be removed soon. 
  3. You should use launchctl instead. 
  4. Please feel free volunteer to support it in a tap. 
  5. Stopping `php55`... (might take a while
  6. ==> Successfully stopped `php55` (label: homebrew.mxcl.php55) 
  7. ==> Successfully started `php55` (label: homebrew.mxcl.php55) 
  8. Oh My Zsh 

ohmyzsh & iTerm2兩個(gè)神器,在Mac os x下是一定要裝的. 兩組配合起來使用,加上插件。簡直是神一樣的存在。 秒殺梅西,內(nèi)馬爾啊:)

Oh 猛戳到官網(wǎng)

安裝 oh my zsh 代碼如下:

curl -L http://install.ohmyz.sh | sh

設(shè)置默認(rèn)shell

查看系統(tǒng)支持的shell列表,Mac 10.9.4 自帶了 zsh 5.0.2,Linux上得安裝。

  1. cat /etc/shells 
  2. # List of acceptable shells for chpass(1). 
  3. # Ftpd will not allow users to connect who are not using 
  4. # one of these shells. 
  5.  
  6. /bin/bash 
  7. /bin/csh 
  8. /bin/ksh 
  9. /bin/sh 
  10. /bin/tcsh 
  11. /bin/zsh 
  12. zsh --version 
  13. zsh 5.0.2 (x86_64-apple-darwin13.0) 
  14. chsh -s /bin/zsh 

雖然Mac自帶了zsh,如果你想要最新版的zsh,那么你用 brew install zsh安裝一個(gè)最新的吧。

/usr/local/bin/zsh --version zsh 5.0.5 (x86_64-apple-darwin13.3.0) 區(qū)別也不會(huì)很大, 默認(rèn)的版本已經(jīng)很新了。

homebrew-cask

安裝cask:

brew tap phinze/homebrew-cask && brew install brew-cask

cask常用命令:

brew cask search #列出所有可以被安裝的軟件

brew cask search php #查找所有和php相關(guān)的應(yīng)用

brew cask list #列出所有通過cask安裝的軟件

brew cask info phpstorm #查看 phpstorm 的信息

brew cask uninstall qq #卸載 QQ

這里談?wù)刢ask對(duì)比Mac App Store的優(yōu)勢(shì):

對(duì)常用軟件支持更全面(特別是開發(fā)者),cask里面會(huì)給你一些驚喜;

軟件更新速度快,一般都是最新版本 Store上很久很久才會(huì)更新版本;

命令安裝感覺比打開Store方便,另外Store在國內(nèi)的速度也是XXOO。

iTerm2

安裝iTerm2:

brew cask install iterm2

上面提過的神器組合,更多使用方法請(qǐng)參考[iTerm2官方文檔](http://www.iterm2.com/#/section/documentation), 這里就不詳細(xì)說明了。

安裝開發(fā)常用的包&軟件

安裝開發(fā)包,代碼如下:

brew install wget watch tmux cmake openssl imagemagick graphicsmagick gearman geoip readline autoconf multitail source-highlight autojump zsh-completions sshfs

升級(jí)一下系統(tǒng)自帶的vim,代碼如下:

brew install ctags macvim --env-std --override-system-vim

安裝常用軟件

brew cask install alfred appcleaner firefox google-chrome phpstorm sublime-text sequel-pro sketch mplayerx thunder qq

Alfred 是個(gè)很不錯(cuò)的東西,推薦必須安裝。它默認(rèn)搜索目錄不包含brew cask安裝的軟件,因此手動(dòng)將`/opt/homebrew-cask`添加到Alfred的搜索目錄

MySQL PHP Nginx Redis Memcache

前面做了這么多的準(zhǔn)備工作,其實(shí) zsh iTerm2 brew 等等這些由于篇幅以及能力有限,一時(shí)半會(huì)也講不完,更多選擇,更多歡樂,就在Google

search,現(xiàn)在才入正題。come on :)

安裝MySQL,代碼如下:

brew install mysql

MySQL開機(jī)啟動(dòng):

ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

安裝完成之后開啟MySQL安全機(jī)制:

/usr/local/opt/mysql/bin/mysql_secure_installation

根據(jù)終端提示,輸入root密碼,然后依次確認(rèn)一些安全選項(xiàng),具體信息可以參考

外國友人的這篇文章

查看一下MySQL運(yùn)行情況

  1. ~ ps aux | grep mysql 
  2. calvin   1695 0.0 0.5 2719864 90908 ?? S  1:38上午 0:00.31 /usr/local/Cellar/mysql/5.6.19/bin/mysqld --basedir=/usr/local/Cellar/mysql/5.6.19 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql/5.6.19/lib/plugin --bind-address=127.0.0.1 --log-error=/usr/local/var/mysql/CalvinsMacBook-Pro.local.err --pid-file=/usr/local/var/mysql/CalvinsMacBook-Pro.local.pid --socket=/tmp/mysql.sock --port=3306 
  3. calvin   1323 0.0 0.0 2444628 1020 ?? S  1:38上午 0:00.04 /bin/sh /usr/local/opt/mysql/bin/mysqld_safe --bind-address=127.0.0.1 --datadir=/usr/local/var/mysql 

#測(cè)試連接MySQL

  1. mysql -uroot -p 
  2. Welcome to the MySQL monitor. Commands end with ; or /g. 
  3. Your MySQL connection id is 23 
  4. Server version: 5.6.19-log Homebrew 
  5.  
  6. Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 
  7.  
  8. Oracle is a registered trademark of Oracle Corporation and/or its 
  9. affiliates. Other names may be trademarks of their respective 
  10. owners. 
  11.  
  12. Type 'help;' or '/h' for help. Type '/c' to clear the current input statement. 
  13.  
  14. mysql> 

安裝phpmyadmin,代碼如下:

brew install phpmyadmin

安裝PHP

添加brew的PHP擴(kuò)展庫:

brew update brew tap homebrew/dupes brew tap josegonzalez/homebrew-php

可以使用brew options php55命令來查看安裝php5.5的選項(xiàng),這里我用下面的選項(xiàng)安裝:

brew install php55 --with-fpm --with-gmp --with-imap --with-tidy --with-debug --with-mysql --with-libmysql

PHP編譯過程中如果遇到configure: error: Cannot find OpenSSL's <evp.h>錯(cuò)誤,執(zhí)行xcode-select --install 重新安裝一下Xcode Command Line Tools 在GitHubHomeBrew上有關(guān)于這個(gè)討論:

  1. _For future reference of anybody looking for Command Line Tools with Xcode 5, 
  2. open up a Terminal window and type xcode-select --install. A window will 
  3. appear informing you command line tools are required. Click Install and you 
  4. should be good to go_ 

等待PHP編譯完成,開始安裝PHP常用擴(kuò)展,擴(kuò)展安裝過程中brew會(huì)自動(dòng)安裝依賴包,例如php55-pdo-pgsql

會(huì)自動(dòng)裝上postgresql,這里我安裝以下PHP擴(kuò)展:

brew install php55-apcu/ php55-gearman/ php55-geoip/ php55-gmagick/ php55-imagick/ php55-intl/ php55-mcrypt/ php55-memcache/ php55-memcached/ php55-mongo/ php55-opcache/ php55-pdo-pgsql/ php55-phalcon/ php55-redis/ php55-sphinx/ php55-swoole/ php55-uuid/ php55-xdebug;

擴(kuò)展里面提一下php55-phalcon 和php55-swoole.一個(gè)是C語言寫的PHP框架,安裝來個(gè)人摸索熟悉一下,還沒有真正的使用過,大致看了一下文檔,感覺非常吊炸天。目前公司的項(xiàng)目是基于Yii2的,也看看這個(gè)框架。

另外一個(gè)swoole是國產(chǎn)的PHP高性能網(wǎng)絡(luò)通信框架,貌似不錯(cuò),可能在項(xiàng)目中會(huì)考慮用到它。

由于Mac自帶了php和php-fpm,因此需要添加系統(tǒng)環(huán)境變量PATH來替代自帶PHP版本,代碼如下:

  1. echo 'export PATH="$(brew --prefix php55)/bin:$PATH"' >> ~/.bash_profile #for php 
  2. echo 'export PATH="$(brew --prefix php55)/sbin:$PATH"' >> ~/.bash_profile #for php-fpm 
  3. echo 'export PATH="/usr/local/bin:/usr/local/sbib:$PATH"' >> ~/.bash_profile #for other brew install soft 
  4. source ~/.bash_profile 

測(cè)試一下效果:

#brew安裝的php 他在/usr/local/opt/php55/bin/php

  1. php -v 
  2. PHP 5.5.14 (cli) (built: Jul 16 2014 15:43:06) (DEBUG) 
  3. Copyright (c) 1997-2014 The PHP Group 
  4. Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies 
  5. with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies 
  6. with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans 

#Mac自帶的PHP

  1. /usr/bin/php -v 
  2. PHP 5.4.24 (cli) (built: Jan 19 2014 21:32:15) 
  3. Copyright (c) 1997-2013 The PHP Group 
  4. Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies 

#brew安裝的php-fpm 他在/usr/local/opt/php55/sbin/php-fpm

  1. php-fpm -v 
  2. PHP 5.5.14 (fpm-fcgi) (built: Jul 16 2014 15:43:12) (DEBUG) 
  3. Copyright (c) 1997-2014 The PHP Group 
  4. Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies 
  5. with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies 
  6. with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans 

#Mac自帶的php-fpm

  1. /usr/sbin/php-fpm -v 
  2. PHP 5.4.24 (fpm-fcgi) (built: Jan 19 2014 21:32:57) 
  3. Copyright (c) 1997-2013 The PHP Group 
  4. Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies 

修改php-fpm配置文件,vim /usr/local/etc/php/5.5/php-fpm.conf,找到pid相關(guān)大概在25行,去掉注釋pid = run/php-fpm.pid, 那么php-fpm的pid文件就會(huì)自動(dòng)產(chǎn)生在/usr/local/var/run/php-fpm.pid,下面要安裝的Nginx pid文件也放在這里。

代碼如下:

  1. #測(cè)試php-fpm配置 
  2. php-fpm -t 
  3. php-fpm -c /usr/local/etc/php/5.5/php.ini -y /usr/local/etc/php/5.5/php-fpm.conf -t 
  4.  
  5. #啟動(dòng)php-fpm 
  6. php-fpm -D 
  7. php-fpm -c /usr/local/etc/php/5.5/php.ini -y /usr/local/etc/php/5.5/php-fpm.conf -D 
  8.  
  9. #關(guān)閉php-fpm 
  10. kill -INT `cat /usr/local/var/run/php-fpm.pid` 
  11.  
  12. #重啟php-fpm 
  13. kill -USR2 `cat /usr/local/var/run/php-fpm.pid` 
  14.  
  15. #也可以用上文提到的brew命令來重啟php-fpm,不過他官方不推薦用這個(gè)命令了 
  16. brew services restart php55 
  17.  
  18. #還可以用這個(gè)命令來啟動(dòng)php-fpm 
  19. launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist 

啟動(dòng)php-fpm之后,確保它正常運(yùn)行監(jiān)聽9000端口:

  1. lsof -Pni4 | grep LISTEN | grep php 
  2. php-fpm 30907 calvin 9u IPv4 0xf11f9e8e8033a2a7 0t0 TCP 127.0.0.1:9000 (LISTEN) 
  3. php-fpm 30917 calvin 0u IPv4 0xf11f9e8e8033a2a7 0t0 TCP 127.0.0.1:9000 (LISTEN) 
  4. php-fpm 30918 calvin 0u IPv4 0xf11f9e8e8033a2a7 0t0 TCP 127.0.0.1:9000 (LISTEN) 
  5. php-fpm 30919 calvin 0u IPv4 0xf11f9e8e8033a2a7 0t0 TCP 127.0.0.1:9000 (LISTEN) 

#正常情況,會(huì)看到上面這些進(jìn)程

PHP-FPM開機(jī)啟動(dòng):

ln -sfv /usr/local/opt/php55/*.plist ~/Library/LaunchAgents launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php55.plist

安裝php composer:

brew install composer

#檢查一下情況

composer --version

Composer version 1.0.0-alpha8 2014-01-06 18:39:59

redis memcached這些軟件brew 已經(jīng)自動(dòng)依賴安裝上,如果想開機(jī)自動(dòng)啟動(dòng),或者查看使用說明 brew info redis即可。另外,composer的中文文檔:猛戳這里

安裝Nginx

brew install nginx --with-http_geoip_module

Nginx啟動(dòng)關(guān)閉命令:

  1. #測(cè)試配置是否有語法錯(cuò)誤 
  2. nginx -t 
  3. #打開 nginx 
  4. sudo nginx 
  5.  
  6. #重新加載配置|重啟|停止|退出 nginx 
  7. nginx -s reload|reopen|stop|quit 
  8.  
  9. #也可以使用Mac的launchctl來啟動(dòng)|停止 
  10. launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist 
  11. launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist 

Nginx開機(jī)啟動(dòng):

ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist

Nginx監(jiān)聽80端口需要root權(quán)限執(zhí)行,因此:

sudo chown root:wheel /usr/local/Cellar/nginx/1.6.0_1/bin/nginx

sudo chmod u+s /usr/local/Cellar/nginx/1.6.0_1/bin/nginx

配置nginx.conf

創(chuàng)建需要用到的目錄:

  1. mkdir -p /usr/local/var/logs/nginx 
  2. mkdir -p /usr/local/etc/nginx/sites-available 
  3. mkdir -p /usr/local/etc/nginx/sites-enabled 
  4. mkdir -p /usr/local/etc/nginx/conf.d 
  5. mkdir -p /usr/local/etc/nginx/ssl 
  6. sudo mkdir -p /var/www 
  7. sudo chown :staff /var/www 
  8. sudo chmod 775 /var/www 
  9. vim /usr/local/etc/nginx/nginx.conf 

輸入以下內(nèi)容:

  1. worker_processes 1; 
  2. error_log /usr/local/var/logs/nginx/error.log debug; 
  3.  
  4.  
  5. pid /usr/local/var/run/nginx.pid; 
  6.  
  7.  
  8. events { 
  9. worker_connections 256; 
  10.  
  11.  
  12. http { 
  13. include mime.types; 
  14. default_type application/octet-stream; 
  15.  
  16. log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 
  17. '$status $body_bytes_sent "$http_referer" ' 
  18. '"$http_user_agent" "$http_x_forwarded_for"'
  19.  
  20. access_log /usr/local/var/logs/access.log main; 
  21.  
  22. sendfile on; 
  23. keepalive_timeout 65; 
  24. port_in_redirect off; 
  25.  
  26. include /usr/local/etc/nginx/sites-enabled/*; 

設(shè)置nginx php-fpm配置文件,碼如下:

  1. vim /usr/local/etc/nginx/conf.d/php-fpm 
  2. #proxy the php scripts to php-fpm 
  3. location ~ /.php$ { 
  4. try_files $uri = 404; 
  5. fastcgi_pass 127.0.0.1:9000; 
  6. fastcgi_index index.php; 
  7. fastcgi_intercept_errors on; 
  8. include /usr/local/etc/nginx/fastcgi.conf; 

nginx虛擬主機(jī)準(zhǔn)備工作

#創(chuàng)建 info.php index.html 404.html 403.html文件到 /var/www 下面

vi /var/www/info.php vi /var/www/index.html vi /var/www/403.html vi /var/www/404.html

創(chuàng)建默認(rèn)虛擬主機(jī)default

vim /usr/local/etc/nginx/sites-available/default

輸入:

  1. server { 
  2. listen 80; 
  3. server_name localhost; 
  4. root /var/www/; 
  5. access_log /usr/local/var/logs/nginx/default.access.log main; 
  6.  
  7. location / { 
  8. index index.html index.htm index.php; 
  9. autoindex on; 
  10. include /usr/local/etc/nginx/conf.d/php-fpm; 
  11.  
  12. location = /info { 
  13. allow 127.0.0.1; 
  14. deny all; 
  15. rewrite (.*) /.info.php; 
  16.  
  17. error_page 404 /404.html; 
  18. error_page 403 /403.html; 

創(chuàng)建ssl默認(rèn)虛擬主機(jī)default-ssl

vim /usr/local/etc/nginx/sites-available/default-ssl

輸入:

  1. server { 
  2. listen 443; 
  3. server_name localhost; 
  4. root /var/www/; 
  5. access_log /usr/local/var/logs/nginx/default-ssl.access.log main; ssl on; 
  6. ssl_certificate ssl/localhost.crt; 
  7. ssl_certificate_key ssl/localhost.key; 
  8. ssl_session_timeout 5m; 
  9. ssl_protocols SSLv2 SSLv3 TLSv1; 
  10. ssl_ciphers HIGH:!aNULL:!MD5; 
  11. ssl_prefer_server_ciphers on; 
  12. location / { 
  13. include /usr/local/etc/nginx/conf.d/php-fpm; 
  14. location = /info { 
  15. allow 127.0.0.1; 
  16. deny all; 
  17. rewrite (.*) /.info.php; 
  18. error_page 404 /404.html; 
  19. error_page 403 /403.html; 

創(chuàng)建phpmyadmin虛擬主機(jī)

vim /usr/local/etc/nginx/sites-available/phpmyadmin

輸入以下配置:

  1. server { 
  2. listen 306; 
  3. server_name localhost; 
  4. root /usr/local/share/phpmyadmin; 
  5. error_log /usr/local/var/logs/nginx/phpmyadmin.error.log; access_log /usr/local/var/logs/nginx/phpmyadmin.access.log main; ssl on; 
  6. ssl_certificate ssl/phpmyadmin.crt; 
  7. ssl_certificate_key ssl/phpmyadmin.key; 
  8. ssl_session_timeout 5m; 
  9. ssl_protocols SSLv2 SSLv3 TLSv1; 
  10. ssl_ciphers HIGH:!aNULL:!MD5; 
  11. ssl_prefer_server_ciphers on; 
  12. location / { 
  13. index index.html index.htm index.php; 
  14. include /usr/local/etc/nginx/conf.d/php-fpm; 
  15. } } 

設(shè)置SSL

  1. mkdir -p /usr/local/etc/nginx/ssl openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=US/ST=State/L=Town/O=Office/CN=localhost" -keyout /usr/local/etc/nginx/ssl/localhost.key -out /usr/local/etc/nginx/ssl/localhost.crt openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=US/ST=State/L=Town/O=Office/CN=phpmyadmin" -keyout /usr/local/etc/nginx/ssl/phpmyadmin.key -out /usr/local/etc/nginx/ssl/phpmyadmin.crt 

創(chuàng)建虛擬主機(jī)軟連接,開啟虛擬主機(jī)

ln -sfv /usr/local/etc/nginx/sites-available/default /usr/local/etc/nginx/sites-enabled/default ln -sfv /usr/local/etc/nginx/sites-available/default-ssl /usr/local/etc/nginx/sites-enabled/default-ssl ln -sfv /usr/local/etc/nginx/sites-available/phpmyadmin /usr/local/etc/nginx/sites-enabled/phpmyadmin

啟動(dòng)|停止Nginx

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist

接下來你可以通過下面這些連接訪問:

  1. <http://localhost/> -> index.html 
  2. <http://localhost/info> -> info.php via phpinfo(); 
  3. <http://localhost/404> -> 404.html 
  4. <https://localhost/> -> index.html(SSL) 
  5. <https://localhost/info> -> info.php via phpinfo();(SSL) 
  6. <https://localhost/404> -> 404.html(SSL) 
  7. <https://localhost:306> -> phpmyadmin(SSL) 

設(shè)置快捷服務(wù)控制命令

為了后面管理方便,將命令 alias 下,vim ~/.bash_aliases 輸入一下內(nèi)容:

  1. alias nginx.start='launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist' alias nginx.stop='launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist' alias nginx.restart='nginx.stop && nginx.start' alias php-fpm.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist" alias php-fpm.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist" alias php-fpm.restart='php-fpm.stop && php-fpm.start' alias mysql.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist" alias mysql.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist" alias mysql.restart='mysql.stop && mysql.start' alias redis.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.redis.plist" alias redis.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.redis.plist" alias redis.restart='redis.stop && redis.start' alias memcached.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist" alias memcached.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist" alias memcached.restart='memcached.stop && memcached.start' 

讓快捷命令生效

echo "[[ -f ~/.bash_aliases ]] && . ~/.bash_aliases" >> ~/.bash_profile source ~/.bash_profile #創(chuàng)建站點(diǎn)目錄到主目錄,方便快捷訪問 ln -sfv /var/www ~/htdocs

有時(shí)間會(huì)進(jìn)一步整理一下,感覺有點(diǎn)亂,第一次在segmentfault上碼字,寫到一半的時(shí)候不小心滑一下觸摸板,瀏覽器后退了,雖然有提示不要離開,點(diǎn)擊了不離開之后,Safari白屏。 然后還特地去吐了個(gè)槽,害我白白又浪費(fèi)很久來寫這個(gè)博客。希望能幫助到剛剛接觸Mac的同學(xué)。enjoy Mac‘s development EVN :)

參考資料:Install Nginx, PHP-FPM, MySQL and phpMyAdmin on OS X Mavericks using Homebrew

本文由Fish創(chuàng)作

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 米泉市| 东乡| 界首市| 凤翔县| 宜兴市| 兴国县| 迁西县| 尚志市| 讷河市| 惠来县| 霍州市| 谢通门县| 宽甸| 冕宁县| 西丰县| 双峰县| 咸阳市| 织金县| 嘉义市| 丰镇市| 衢州市| 石台县| 新余市| 黄冈市| 福建省| 西贡区| 措美县| 黄陵县| 剑河县| 邳州市| 图片| 涟源市| 东丽区| 绥江县| 济阳县| 罗平县| 玛纳斯县| 峨山| 沙雅县| 柞水县| 景洪市|