日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

Mac下Nginx、PHP、MySQL 和 PHP-fpm安装配置

發布時間:2023/12/15 数据库 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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.conf

nginx啟動后,在瀏覽器中輸入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.plist

MySQL

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.plist

PHP

brew tap homebrew/php #php擴展 brew install --without-apache --with-fpm --with-mysql php56 ## php-fpm

php設置開機啟動

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安装配置的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。