MAC安裝Nginx Mysql Php的過程記錄

2021-10-07 17:01:25 字數 2063 閱讀 3861

目錄:

1.使用brew安裝,首先需要安裝brew。

2.安裝php。

3.安裝nginx。

4.安裝mysql。

官網上給出的安裝方式是:/usr/bin/ruby -e "$(curl -fssl "

但是,raw.githubusercontent.com 連線不到。

網上給出在 hosts裡修改 ip 位址在這裡也是行不通。

有大神提供國內安裝源:/bin/zsh -c "$(curl -fssl "

brew search 搜尋

brew install 安裝

brew uninstall(remove) 解除安裝

mac 原有php因版本不適合專案,所以需要安裝php7.3。

php -v 檢視當前php版本

brew install [email protected] 安裝php7.3

brew link [email protected] 新增php7.3的軟鏈

系統會提示你將他給出的兩行環境變數新增到你的~/.bash_profile 裡,例如:export path="/usr/local/opt/[email protected]/bin:path"

export path="/usr/local/opt/[email protected]/sbin:path"

vi ~/.bash_profile 開啟檔案加入這兩行內容。儲存

source ~/.bash_profile 生成環境變數

php -v 檢視是否改為7.3版本

brew install nginx 安裝最新版

瀏覽器輸入localhosts:8080 檢視是否訪問成功!

下面加入我們自己的專案,使用虛擬網域名稱配置

修改自己專案的檔案許可權:chmod -r 777 檔案目錄

配置檔案位置:/usr/local/etc/nginx/nginx.conf

vim /usr/local/etc/nginx/nginx.conf

在 #user nobody; 下新增自己的使用者和組

user hui staff; user 自己的使用者 自己的組

配置檔案最後一行,有 include servers/*; (沒有就新增)

進入到 /usr/local/etc/nginx/servers

建立自己專案的配置檔案:touch 專案名自己起.conf

配置檔案裡的內容:

server

location ~ .php$

關於 fastcgi_pass 的內容是 php-fpm 的配置檔案裡的listen。修改hosts,加入你的網域名稱

訪問專案遇到403 502 ?

目錄許可權修改了麼?

fastcgi_pass正確麼?

使用者和組對麼?

brew search mysql : 查詢有沒有mysql

brew install mysql@版本 :安裝某個版本的mysql

brew install mysql : 安裝最新的mysql

如果是解除安裝後的重新安裝 一定要將之前的資料和檔案刪除乾淨 否則會影響新安裝mysql的啟動。my.cnf 也要刪除。要brew link 新mysql

mysql8 預設的身份驗證是:caching_sha2_password。

因專案需要,在my.cnf 中新增一行:

default_authentication_plugin=mysql_native_password

root使用者登入mysql:mysql -uroot -p

修改驗證方式:

alter user 『root』@『localhost』 identified with mysql_native_password by 『使用者密碼』;

專案就可以使用mysql啦

啟動mysql.server start

sudo nginx

sudo php-fpm

重啟mysql.server restart

sudo nginx -s start

定時重啟Nginx MySql等服務

利用 linux crontab,每天定時重啟 nginx mysql等服務。命令列格式說明 f1 f2 f3 f4 f5 program 其中 f1 是表示分鐘,f2 表示小時,f3 表示乙個月份中的第幾日,f4 表示月份,f5 表示乙個星期中的第幾天。program 表示要執行的程式。當 f1 ...

Mac安裝Jupyter NoteBook和執行

安裝 pip3 install jupyter啟動 jupyter notebook 指定埠啟動 jupyter notebook port 啟動伺服器但不開啟瀏覽器 jupyter notebook no browser幫助 jupyter notebook help配置檔案路徑 jupyter ...

mac安裝graphviz pycharm執行成功

1.安裝homebrew mac使用者建議直接用homebrew來安裝。當在終端執行 usr bin ruby e curl fssl failed to connect to raw.githubusercontent.com port 443 connection refused試著翻q操作也不...