我正在运行macOS Catalina,并尝试将WP CLI与MAMP结合使用,将iTerm2和Oh My Zsh作为命令行。
但是,当我输入wp
在命令行中,然后按q
要退出,我会遇到以下错误:
PHP Notice: Undefined index: SERVER_NAME in phar:///usr/local/Cellar/wp-cli/2.4.0/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1197) : eval()\'d code on line 5
Notice: Undefined index: SERVER_NAME in phar:///usr/local/Cellar/wp-cli/2.4.0/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1197) : eval()\'d code on line 5
PHP Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /Users/mattpjennings/Desktop/projects/mj/build/mj.net/wp-includes/wp-db.php on line 1626
Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /Users/mattpjennings/Desktop/projects/mj/build/mj.net/wp-includes/wp-db.php on line 1626
然后当我进去的时候
wp plugin list
我还得到以下错误:
Error: Error establishing a database connection.
当我进入时
wp --info
我得到:
PHP binary: /usr/local/Cellar/php/7.4.6/bin/php
php.ini used: /usr/local/etc/php/7.4/php.ini
我已经尝试将下面的行添加到
~/.oh-my-zsh/custom/aliases.zsh
更改
php
或
php.ini
输入时的路径
wp --info
:
#MAMP Madness export
PATH=/Applications/MAMP/Library/bin:$PATH
PHP_VERSION=`ls /Applications/MAMP/bin/php/ | sort -n | tail -1` export
PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH
我还试着在
wp-config.php
文件,该文件不起作用:
define(\'DB_HOST\', \'127.0.0.1:8889\');
任何帮助都将不胜感激。我真的很想在Mac上本地使用WP-CLI。