600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > m1芯片 mysql_mac m1芯片搭建php开发环境 mnmp开发环境

m1芯片 mysql_mac m1芯片搭建php开发环境 mnmp开发环境

时间:2019-10-06 04:58:48

相关推荐

m1芯片 mysql_mac m1芯片搭建php开发环境 mnmp开发环境

mac部署php环境

最近才入手了macbook pro m1芯片系列的,发现环境配置和之前的不同,很多不兼容芯片,brew安装路径也需要更改,带来了环境很多路径不一致的问题;好在能避开的都避开了.

/p/8d0b42470679

不是m1芯片的都可以安装的:

/shivammathur/homebrew-php

php7.0 以下都已经停止了更新,可能都安装不了了!!!!!

We've installed your MySQL database without a root password. To secure it run:

mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:

mysql -uroot

mysql@5.7 is keg-only, which means it was not symlinked into /opt/homebrew,

because this is an alternate version of another formula.

If you need to have mysql@5.7 first in your PATH run:

echo 'export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc

For compilers to find mysql@5.7 you may need to set:

export LDFLAGS="-L/opt/homebrew/opt/mysql@5.7/lib"

export CPPFLAGS="-I/opt/homebrew/opt/mysql@5.7/include"

For pkg-config to find mysql@5.7 you may need to set:

export PKG_CONFIG_PATH="/opt/homebrew/opt/mysql@5.7/lib/pkgconfig"

To have launchd start mysql@5.7 now and restart at login:

brew services start mysql@5.7

Or, if you don't want/need a background service you can just run:

/opt/homebrew/opt/mysql@5.7/bin/mysql.server start

==> Summary

🍺 /opt/homebrew/Cellar/mysql@5.7/5.7.32: 318 files, 233.1MB, built in 4 minutes 5 seconds

mysql --- mysql安装,需要brew安装好了,否则会重启就丢掉,m1芯片安装brew,需要改变路径;

参考博客:

/qiaoyanlin/p/13397858.html

brew install --build-from-source mysql@5.7

alter user 'root'@'localhost' identified with mysql_native_password by '123456';

PHP

参考博客: 环境目录并不相同,不可行!!!

/p/4333

基本正确的,有些路径需要根据项目跑

php-fpm 关闭命令

/gazeon/p/5421906.html

通过进程来关闭有时候不方便

brew 也可以关闭开启php-fpm

zb@zbdeMacBook-Pro etc % brew services stop php@7.1

Stopping `php@7.1`... (might take a while)

==> Successfully stopped `php@7.1` (label: homebrew.mxcl.php@7.1)

zb@zbdeMacBook-Pro etc % brew services start php@7.1

==> Successfully started `php@7.1` (label: homebrew.mxcl.php@7.1)

nginx.conf 测试用的配置,注意php-fpm配置开启的是9999 端口----用mac自带的php,需要新开启端口

#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;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {

root /Users/zb/www/gaodian;

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 html;

# fastcgi_pass 127.0.0.1:9000;

# fastcgi_index index.php;

# fastcgi_param SCRIPT_FILENAME /scripts$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;

#}

location ~ \.php$ {

root /Users/zb/www/gaodian;

fastcgi_pass 127.0.0.1:9999;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

}

# 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/*;

}

用自带php,配置nginx.conf ---- 如果加上最下面正确解决pathinfo问题的,相信也可以跑起来,不过有的说自带的php很多扩展没打开;

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;

# add zb

server_names_hash_bucket_size 64;

#gzip on;

server {

listen 80;

server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

#location / {

# root html;

# index index.html index.htm;

#}

location / {

root /Users/zb/www;

index index.php;

}

location ~ \.php$ {

root /Users/zb/www;

fastcgi_pass 127.0.0.1:9999;

fastcgi_index index.php;

# add later

#fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;

fastcgi_split_path_info ^(.+\.php)(/.+)$;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

# add later

fastcgi_param PATH_INFO $fastcgi_path_info;

fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

include fastcgi_params;

}

#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 html;

# fastcgi_pass 127.0.0.1:9000;

# fastcgi_index index.php;

# fastcgi_param SCRIPT_FILENAME /scripts$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/*;

}

项目nginx 配置路径

···

zb@zbdeMacBook-Pro servers % pwd

/opt/homebrew/etc/nginx/servers

server {

listen 80;

server_name ;

index index.html admin.php index.php;

root /Users/zb/www/gaodian/store/Public;

location / {

root /Users/zb/www/gaodian/store/Public;

index index.html index.htm index.php;

}

location ~ \.php$ {

root /Users/zb/www/gaodian/store/Public;

fastcgi_pass 127.0.0.1:9999;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

location /nginx_status

{

stub_status on;

access_log off;

}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

{

expires 30d;

}

location ~ .*\.(js|css)?$

{

expires 12h;

}

location ~ /\.

{

deny all;

}

#access_log /home/wwwlogs/access-gaodian.log;

}

brew 安装php,用mac自带的php,发现很多配置文件找不到

就用brew来安装php,发现brew list中的7.2 7.3 安装都发现m1 芯片的问题

结果brew install php@7.1 可以顺利安装-----有条活路了!!!!!

/php/t_77676.html

安装php7.1成功提示:

Caveats

To enable PHP in Apache add the following to httpd.conf and restart Apache:

LoadModule php7_module /opt/homebrew/opt/php@7.1/lib/httpd/modules/libphp7.so

SetHandler application/x-httpd-php

Finally, check DirectoryIndex includes index.php

DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:

/opt/homebrew/etc/php/7.1/

php@7.1 is keg-only, which means it was not symlinked into /opt/homebrew,

because this is an alternate version of another formula.

If you need to have php@7.1 first in your PATH, run:

echo 'export PATH="/opt/homebrew/opt/php@7.1/bin:$PATH"' >> ~/.zshrc

echo 'export PATH="/opt/homebrew/opt/php@7.1/sbin:$PATH"' >> ~/.zshrc

For compilers to find php@7.1 you may need to set:

export LDFLAGS="-L/opt/homebrew/opt/php@7.1/lib"

export CPPFLAGS="-I/opt/homebrew/opt/php@7.1/include"

To have launchd start shivammathur/php/php@7.1 now and restart at login:

brew services start shivammathur/php/php@7.1

Or, if you don't want/need a background service you can just run:

php-fpm

==> Summary

🍺 /opt/homebrew/Cellar/php@7.1/7.1.33: 513 files, 63.6MB

==> Caveats

==> php@7.1

To enable PHP in Apache add the following to httpd.conf and restart Apache:

LoadModule php7_module /opt/homebrew/opt/php@7.1/lib/httpd/modules/libphp7.so

SetHandler application/x-httpd-php

Finally, check DirectoryIndex includes index.php

DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:

/opt/homebrew/etc/php/7.1/

php@7.1 is keg-only, which means it was not symlinked into /opt/homebrew,

because this is an alternate version of another formula.

If you need to have php@7.1 first in your PATH, run:

echo 'export PATH="/opt/homebrew/opt/php@7.1/bin:$PATH"' >> ~/.zshrc

echo 'export PATH="/opt/homebrew/opt/php@7.1/sbin:$PATH"' >> ~/.zshrc

For compilers to find php@7.1 you may need to set:

export LDFLAGS="-L/opt/homebrew/opt/php@7.1/lib"

export CPPFLAGS="-I/opt/homebrew/opt/php@7.1/include"

To have launchd start shivammathur/php/php@7.1 now and restart at login:

brew services start shivammathur/php/php@7.1

Or, if you don't want/need a background service you can just run:

php-fpm

设置php7.1 为默认版本,启动php7.1 服务

sudo vim ~/.bash_profile

export PATH="$(brew --prefix php@7.1)/bin:$PATH"

source ~/.bash_profile

注意:在运行下面命令之前先把原先的PHP服务关闭,避免端口冲突,启动失败!

brew services start php@7.2

关闭之前php-fpm 可以直接sudo kill ....; 加上-USR2 为平滑重启

设置php7.1 开机自动启动

原本brew 路径没变情况下的安装

mkdir -p ~/Library/LaunchAgents

cp /usr/local/opt/php@7.2/homebrew.mxcl.php@7.2.plist ~/Library/LaunchAgents/

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php@7.2.plist

brew在新路径下的安装

mkdir -p ~/Library/LaunchAgents

cp /opt/homebrew/opt/php@7.1/homebrew.mxcl.php@7.1.plist ~/Library/LaunchAgents/

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php@7.1.plist

项目可以跑起来终结nginx.conf 配置----主要解决了nginx的pathinfo问题;

#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;

# add zb 此处解决了,在servers下单独配置***.conf 文件;

server_names_hash_bucket_size 64;

#gzip on;

server {

listen 80;

server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {

root html;

index index.html index.htm index.php;

#下面主要是解决在url地址中省略"index.php"时使用的规则

if ( -f $request_filename) {

break;

}

#如果请求既不是一个文件,也不是一个目录,则执行一下重写规则

if (!-e $request_filename) {

#地址作为将参数rewrite到index.php上

rewrite ^/(.*)$ /index.php?s=/$1 last;

}

}

location ~ \.php$ {

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

fastcgi_split_path_info ^(.+\.php)(.*)$; #新加第一句

fastcgi_param PATH_INFO $fastcgi_path_info;#新加第二句

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

#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 html;

# fastcgi_pass 127.0.0.1:9000;

# fastcgi_index index.php;

# fastcgi_param SCRIPT_FILENAME /scripts$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;

# }

#}

server {

listen 80; #监听端口

server_name ; #域名名称

root /Users/zb/www/txsq/tortoise/Public; #网站根目录

index index.html index.htm index.php; #默认打开文件

#access_log logs/xsxcx.access.log main;

location / {

#下面主要是解决在url地址中省略"index.php"时使用的规则

if ( -f $request_filename) {

break;

}

#如果请求既不是一个文件,也不是一个目录,则执行一下重写规则

if ( !-e $request_filename) {

#地址作为将参数rewrite到index.php上

rewrite ^/(.*)$ /index.php?s=/$1 last;

}

}

location ~ \.php$ {

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

fastcgi_split_path_info ^(.+\.php)(.*)$; #新加第一句

fastcgi_param PATH_INFO $fastcgi_path_info;#新加第二句

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

# 此处解决了pathinfo的问题,路径必须指向项目!

location ~ \.php/?.*$ {

root /Users/zb/www/txsq/tortoise/Public;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

#加载Nginx默认"服务器环境变量"配置

include fastcgi.conf;

#设置PATH_INFO并改写SCRIPT_FILENAME,SCRIPT_NAME服务器环境变量

set $fastcgi_script_name2 $fastcgi_script_name;

if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {

set $fastcgi_script_name2 $1;

set $path_info $2;

}

fastcgi_param PATH_INFO $path_info;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2;

fastcgi_param SCRIPT_NAME $fastcgi_script_name2;

}

}

include servers/*;

}

brew 安装phpmyadmin

* brew search phpmyadmin

* brew install phpmyadmin

phpmyadmin.config.inc.php 路径

The configuration file is /opt/homebrew/etc/phpmyadmin.config.inc.php

由于brew安装路径改变了,博文上phpmyadmin 的路径不同了;

zb@zbdeMacBook-Pro share % cp -rf phpmyadmin /Users/zb/www/

zb@zbdeMacBook-Pro share % pwd

/opt/homebrew/opt/phpmyadmin/share

zb@zbdeMacBook-Pro nginx % brew search phpmyadmin

==> Formulae

phpmyadmin

zb@zbdeMacBook-Pro nginx % brew install phpmyadmin

Updating Homebrew...

==> Auto-updated Homebrew!

Updated 3 taps (shivammathur/php, homebrew/core and homebrew/cask).

==> New Formulae

htmltest mpdecimal

==> Updated Formulae

Updated 56 formulae.

==> New Casks

digital slippi-dolphin

==> Updated Casks

Updated 163 casks.

==> Deleted Casks

oni project-slippi-dolphin

==> Downloading /phpMyAdmin/5.0.4/phpMyAdmin-5.0.4-all-languages.tar.gz

######################################################################## 100.0%

==> Caveats

To enable phpMyAdmin in Apache, add the following to httpd.conf and

restart Apache:

Alias /phpmyadmin /opt/homebrew/share/phpmyadmin

Options Indexes FollowSymLinks MultiViews

AllowOverride All

Require all granted

Order allow,deny

Allow from all

Then open http://localhost/phpmyadmin

The configuration file is /opt/homebrew/etc/phpmyadmin.config.inc.php

==> Summary

🍺 /opt/homebrew/Cellar/phpmyadmin/5.0.4: 3,200 files, 43.8MB, built in 3 seconds

我是单独给phpmyadmin配置域名访问的

server {

listen 80; #监听端口

server_name ; #域名名称

root /Users/zb/www/phpmyadmin; #网站根目录

index index.html index.htm index.php; #默认打开文件

#access_log logs/xsxcx.access.log main;

location / {

#下面主要是解决在url地址中省略"index.php"时使用的规则

if ( -f $request_filename) {

break;

}

#如果请求既不是一个文件,也不是一个目录,则执行一下重写规则

if ( !-e $request_filename) {

#地址作为将参数rewrite到index.php上

rewrite ^/(.*)$ /index.php?s=/$1 last;

}

}

location ~ \.php$ {

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

fastcgi_split_path_info ^(.+\.php)(.*)$; #新加第一句

fastcgi_param PATH_INFO $fastcgi_path_info;#新加第二句

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

# 此处解决了pathinfo的问题,路径必须指向项目!

location ~ \.php/?.*$ {

root /Users/zb/www/phpmyadmin;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

#加载Nginx默认"服务器环境变量"配置

include fastcgi.conf;

#设置PATH_INFO并改写SCRIPT_FILENAME,SCRIPT_NAME服务器环境变量

set $fastcgi_script_name2 $fastcgi_script_name;

if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {

set $fastcgi_script_name2 $1;

set $path_info $2;

}

fastcgi_param PATH_INFO $path_info;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2;

fastcgi_param SCRIPT_NAME $fastcgi_script_name2;

}

}

参考/p/107969816

brew 安装redis

一开始安装博客安装redis@3.2 redis@4.0的,结果都报错提示;

brew install redis

Warning: Treating redis as a formula. For the cask, use homebrew/cask/redis

==> Downloading https://mirrors./homebrew-bottles/bottles/redis-6.0.10.arm64_big_sur.bottle.tar.gz

######################################################################## 100.0%

==> Pouring redis-6.0.10.arm64_big_sur.bottle.tar.gz

==> Caveats

To have launchd start redis now and restart at login:

brew services start redis

Or, if you don't want/need a background service you can just run:

redis-server /opt/homebrew/etc/redis.conf

==> Summary

🍺 /opt/homebrew/Cellar/redis/6.0.10: 13 files, 4MB

博客配置:

If you need to have redis@3.2 first in your PATH run:

echo 'export PATH="/usr/local/opt/redis@3.2/bin:$PATH"' >> ~/.zshrc

brew 路径被更改后,路径实际情况:

echo 'export PATH="/opt/homebrew/opt/redis/bin:$PATH"' >> ~/.zshrc

/opt/homebrew/etc 下修改redis.conf找到

daemonize no改成yes 以守护进程的方式启动

安装php-redis

下载php-redis

/package/redis

解压

cd redis-4.*/

通过phpize生成编译configure配置文件

phpize

找到自己安装php路径,加上\

./configure --with-php-config=/opt/homebrew/Cellar/php\@7.1/7.1.33/bin/php-config

编译

make

make install

配置 php.ini文件 -- 通过phpinfo找到php.ini 位置

加上:

extension="redis.so"

测试 访问 localhost/redis.php

//实例化redis对象

$redis = new redis();

//连接redis,第一个参数是redis服务的IP127.0.0.1是自己的,6379是端口号

$redis->connect('127.0.0.1', 6379);

echo "Server is running: " . $redis->ping();

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