Mac系统下使用Homebrew配置PHP运行环境


php开发需要的集成环境 包含 nginx/apache (这里选择nginx)、phpmysql ,所以我们要依次安装这些软件。

 

1、安装 Homebrew

首先安装homebrew,安装后我们可以使用brew命令来安装我们需要的软件。安装方式请戳这里 https://upwqy.com/details/328.html

 

2、使用brew安装PHP

2.1 安装PHP

brew install php@7.4

2.2 启动php

brew services start php@7.4

2.3 重启php

brew services restart php@7.4

2.4 停止PHP

brew services stop php@7.4

 

3、使用brew安装php版本切换工具

3.1 安装PHP版本切换工具

brew install brew-php-switcher

3.2 切换PHP版本

brew-php-switcher 7.4

3.3 查看PHP版本

php -v

 

 

 

Nginx


 

安装nginx

brew install nginx

 

 

查看nginx版本

nginx -v

 

 

启动nginx

brew services start nginx

 

 

重启nginx

brew services restart  nginx

 

www目录:/opt/homebrew/var/www

配置文件:/opt/homebrew/etc/nginx/nginx.conf

扩展配置文件: /opt/homebrew/etc/nginx/servers/

 

MySql


 

安装mysql

brew install  mysql@5.7

启动mysql

brew services start  mysql@5.7

 

进入mysql控制台: mysql -u root -p

 

mysql安装包安装

 

可以直接去官网下载mysql安装包 直接安装,使用安装包安装的mysql就不可以直接使用brew命令启动了。

MySQL 默认安装在:/usr/local/mysql/bin 下。

想在终端直接使用 mysql 指令,还需配置路径,打开 .bash_profile 文件,添加PATH=$PATH:/usr/local/mysql/bin,在 .bash_profile 里设置别名,设置别名的目的是可以直接执行指令 mysql 或者 mysqladmin。

 

vim ~/.bash_profile

 

把下面代码写入 .bash_profile文件中

export PATH=$PATH:/usr/local/mysql/bin

alias mysql='/usr/local/mysql/bin/mysql'

alias mysqladmin='/usr/local/mysql/bin/mysqladmin'

 

执行如下命令激活文件:

source ~/.bash_profile

5.安装验证

执行命令 mysql -V,如果出现如下信息说明安装配置成功

 

 

配置多站点


 

server {
        listen        8080;
        server_name  dev.zsrd.cn;
        root   "/opt/homebrew/var/www/dev.zsrd.cn/public";
        location / {
            index index.php index.html error/index.html;
            error_page 400 /error/400.html;
            error_page 403 /error/403.html;
            error_page 404 /error/404.html;
            error_page 500 /error/500.html;
            error_page 501 /error/501.html;
            error_page 502 /error/502.html;
            error_page 503 /error/503.html;
            error_page 504 /error/504.html;
            error_page 505 /error/505.html;
            error_page 506 /error/506.html;
            error_page 507 /error/507.html;
            error_page 509 /error/509.html;
            error_page 510 /error/510.html;
            include /opt/homebrew/var/www/dev.zsrd.cn/public/nginx.htaccess;
            autoindex  off;
        }
        location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
}

 

 

 

发布时间 : 2023-02-27,阅读量:1174 , 分类: PHP MySql Nginx
本文链接:https://upwqy.com/details/418.html
enter your GitHub credentials to access private repos redis缓存雪崩,击穿,穿透