mac m1芯片搭建php開發環境 mnmp開發環境


mac部署php環境

最近才入手了macbook pro m1芯片系列的,發現環境配置和之前的不同,很多不兼容芯片,brew安裝路徑也需要更改,帶來了環境很多路徑不一致的問題;好在能避開的都避開了.

https://www.jianshu.com/p/8d0b42470679


不是m1芯片的都可以安裝的:
https://github.com/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,需要改變路徑;

參考博客:
https://www.cnblogs.com/qiaoyanlin/p/13397858.html

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

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

PHP

參考博客: 環境目錄並不相同,不可行!!!
https://blog.liuguofeng.com/p/4333
基本正確的,有些路徑需要根據項目跑

php-fpm 關閉命令

https://www.cnblogs.com/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 local.gaodian.com;
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 可以順利安裝-----有條活路了!!!!!

https://www.debug8.com/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

    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

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

    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

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  local.txsq.com; #域名名稱

    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 https://files.phpmyadmin.net/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
    <Directory /opt/homebrew/share/phpmyadmin/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        <IfModule mod_authz_core.c>
            Require all granted
        </IfModule>
        <IfModule !mod_authz_core.c>
            Order allow,deny
            Allow from all
        </IfModule>
    </Directory>
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  local.phpmyadmin.com; #域名名稱

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


}

  • 參考https://zhuanlan.zhihu.com/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.ustc.edu.cn/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
http://pecl.php.net/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

<?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();


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM