600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > macos nginx php mysql_mac环境下搭建nginx + php + mysql开发环境

macos nginx php mysql_mac环境下搭建nginx + php + mysql开发环境

时间:2021-07-14 08:28:09

相关推荐

macos nginx php mysql_mac环境下搭建nginx + php + mysql开发环境

1.安装homebrew(mac下好用的包管理器)

第一步,获取install文件

把官网给的脚本拿下来

curl -fsSL /Homebrew/install/master/install >> brew_install

/bin/zsh -c "$(curl -fsSL /cunkai/HomebrewCN/raw/master/Homebrew.sh)"

第二步,更改脚本中的资源链接,替换成清华大学的镜像

就是把这两句

BREW_REPO = “/Homebrew/brew“.freeze

CORE_TAP_REPO = “/Homebrew/homebrew-core“.freeze

更改为这两句

BREW_REPO = “https://mirrors./brew.git “.freeze

CORE_TAP_REPO = “https://mirrors./homebrew-core.git“.freeze

当然如果这个镜像有问题的话,可以换成别的

第三步,执行脚本

/usr/bin/ruby brew_install

然后可以看到这几句:

==> Tapping homebrew/core

Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...

fatal: unable to access '/Homebrew/homebrew-core/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

Error: Failure while executing: git clone /Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

Error: Failure while executing: /usr/local/bin/brew tap homebrew/core

liyuanbadeMacBook-Pro:~ liyuanba$ git clone /Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

出现这个原因是因为源不通,代码来不下来,解决方法就是更换国内镜像源:

执行下面这句命令,更换为中科院的镜像:

git clone git://mirrors./homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

就下载成功了

然后把homebrew-core的镜像地址也设为中科院的国内镜像

cd "$(brew --repo)"

git remote set-url origin https://mirrors./brew.git

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

git remote set-url origin https://mirrors./homebrew-core.git

执行更新,成功:

brew update

最后用这个命令检查无错误:

brew doctor

这样海外和已经有系统全局代理设置的朋友们就可以直接使用 brew 命令安装软件了。

接着换源:

直接使用 Homebrew 还需要更改默认源,不然谁用谁想打人,原因你懂的。以下是将默认源替换为国内 USTC 源的方法。

替换核心软件仓库

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

git remote set-url origin https://mirrors./homebrew-core.git

替换 cask 软件仓库(提供 macOS 应用和大型二进制文件)

cd "$(brew --repo)"/Library/Taps/caskroom/homebrew-cask

git remote set-url origin https://mirrors./homebrew-cask.git

替换 Bottles 源(Homebrew 预编译二进制软件包)

bash(默认 shell)用户:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors./homebrew-bottles' >> ~/.bash_profile

source ~/.bash_profile

zsh 用户:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors./homebrew-bottles' >> ~/.zshrc

source ~/.zshrc

2.安装nginx

brew search nginx

brew install nginx

2.1 nginx配置

cd /usr/local/etc/nginx/

vim nginx.conf

nginx.conf内容为:

#user nobody;

worker_processes 1;

#error_log logs/error.log;

#error_log logs/error.log notice;

#error_log logs/error.log info;

#pid logs/nginx.pid;

events {

worker_connections 1024;

}

http {

include mime.types;

default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '

# '$status $body_bytes_sent "$http_referer" '

# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;

#tcp_nopush on;

#keepalive_timeout 0;

keepalive_timeout 65;

#gzip on;

server {

listen 80;

server_name localhost;

index index.php index.html index.htm;

root /Applications/wangman/phpdemo/day1;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {

root /Applications/wangman/phpdemo/day1;

index index.html index.htm index.php;

}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html

#

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

#proxy the PHP scripts to Apache listening on 127.0.0.1:80

#

#location ~ \.php$ {

# proxy_pass http://127.0.0.1;

#}

#pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

location ~ \.php$ {

root/Applications/wangman/phpdemo/day1;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

# deny access to .htaccess files, if Apache's document root

# concurs with nginx's one

#

#location ~ /\.ht {

# deny all;

#}

}

# another virtual host using mix of IP-, name-, and port-based configuration

#

#server {

# listen 8000;

# listen somename:8080;

# server_name somename alias another.alias;

# location / {

# root html;

# index index.html index.htm;

# }

#}

# HTTPS server

#

#server {

# listen 443 ssl;

# server_name localhost;

# ssl_certificate cert.pem;

# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;

# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;

# ssl_prefer_server_ciphers on;

# location / {

# root html;

# index index.html index.htm;

# }

#}

}

include servers/*;

3.安装php-fpm

mac系统自带php\php-fpm

4.安装mysql

brew install mysql

启动nginx服务

sudo nginx

重启nginx服务

sudo nginx -s reload

停止nginx服务

sudo nginx -s stop

启动php服务

sudo php-fpm

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。