Mac下Nginx、PHP、MySQL 和 PHP-fpm安装配置
生活随笔
收集整理的這篇文章主要介紹了
Mac下Nginx、PHP、MySQL 和 PHP-fpm安装配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
之前換電腦裝了個Mnmp,有遇到一些小坑,寫在這,希望能幫到一些初次搭建Mnmp的phper。
.
.
.
安裝 Mac 的包管理器 - homebrew
Homebrew是一款Mac OS平臺下的軟件包管理工具,擁有安裝、卸載、更新、查看、搜索等很多實用的功能。
安裝Homebrew之前,需要確定mac是否安裝過xcode,然后安裝xcode命令行工具。
#安裝xcode命令行工具 xcode-select --install如果該方法你不愿用或者各種原因,可以:
登錄 [https://developer.apple.com/download/more/][1] 然后下載 dmg 安裝注:一定要選擇和mac系統版本,xcode版本一致的命令行工具。
好了現在我們開始安裝Homebrew。
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"安裝好了Homebrew之后,便可以使用brew命令來安裝相應的包了。
Nginx
brew install nginx執行完之后Nginx就安裝好了,以下為nginx幾個常用命令。
# 啟動 nginx服務 sudo nginx# 重新加載配置|重啟|停止|退出 nginx nginx -s reload|reopen|stop|quit#測試配置是否有語法錯誤 nginx -t # 啟動 nginx sudo ngixn -c /usr/local/etc/nginx/nginx.conf#測試配置是否有語法錯誤 nginx -t -c /usr/local/etc/nginx/nginx.confnginx啟動后,在瀏覽器中輸入http://localhost:8080/,回車即可看到運行結果,顯示的是/usr/local/Cellar/nginx/1.10.0/html/index.html文件的內容。
設置開機自啟動nginx服務設置:
mkdir -p ~/Library/LaunchAgents cp /usr/local/Cellar/nginx/1.10.0/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plistMySQL
brew install mysql #啟動mysql /usr/local/Cellar/mysql/5.7.12/bin/mysqld #設置密碼 /usr/local/bin/mysqladmin -u root password 'new-password' #登錄mysql mysql -u root -p設置開機啟動
mkdir -p ~/Library/LaunchAgents/ cp /usr/local/Cellar/mysql/5.7.12/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plistPHP
brew tap homebrew/php #php擴展 brew install --without-apache --with-fpm --with-mysql php56 ## php-fpmphp設置開機啟動
mkdir -p ~/Library/LaunchAgents cp /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist配置 Nginx
vim /usr/local/etc/nginx/nginx.conf#隱藏入口文件配置 location / {index index.php index.html index.htm;if (!-e $request_filename) {rewrite ^/(.*)$ /index.php?$1 last; #ci框架寫法#rewrite ^/(.*)$ /index.php?s=/$1 last; #tp框架寫法break;} }修改host
vim /etc/hosts # 127.0.0.1 www.test.com #總結
以上是生活随笔為你收集整理的Mac下Nginx、PHP、MySQL 和 PHP-fpm安装配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Windows CE是什么(downlo
- 下一篇: HTML的各种基本标签