最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

【已解决】Mac中MAMP的本地WordPress首页出错:无法打开页面

Mac crifan 240浏览 0评论
折腾:
【记录】本地wordpress环境中测试xxx的效果
期间,
不论怎么去修改:
wp-config.php
中的各种数据库的配置和其他配置
结果都是:
https://localhost:8888/xxx/wp-admin/index.php
http://localhost:8888/xxx/
localhost:8888/xxx/
[Error] Failed to load resource: 无法连接到服务器。 (xxx, line 0)
[Error] Failed to load resource: 找不到使用指定主机名的服务器。 (xxx, line 0)
[Error] Failed to load resource: 无法连接到服务器。 (xxx, line 0)
wordpress mamp 无法打开页面
设置了:
define('WP_DEBUG', true);
没用。没有输出
看到.htaccess不一样:
去改为类似的:
还是不行。
难道之前的wordpress的文件下载的不全?
 
好像也不是。
然后现在有个诡异事件:
当数据库的用户名和密码错误的时候,是可以看到debug信息的:
( ! ) Warning: mysqli_real_connect(): (HY000/1045): Access denied for user ‘root’@’localhost’ (using password: YES) in /Users/crifan/dev/dev_root/crifan.com/mamp/wp_xxx/wp-includes/wp-db.php on line 1531
Call Stack
#
Time
Memory
Function
Location
1
0.0124
356040
{main}( )
…/index.php:0
2
0.0133
356328
require( ‘/Users/crifan/dev/dev_root/crifan.com/mamp/wp_xxx/wp-blog-header.php )
…/index.php:17
3
0.0135
356680
require_once( ‘/Users/crifan/dev/dev_root/crifan.com/mamp/wp_xxx/wp-load.php )
…/wp-blog-header.php:13
4
0.0160
358192
require_once( ‘/Users/crifan/dev/dev_root/crifan.com/mamp/wp_xxx/wp-config.php )
…/wp-load.php:37
5
0.0162
359304
require_once( ‘/Users/crifan/dev/dev_root/crifan.com/mamp/wp_xxx/wp-settings.php )
…/wp-config.php:112
6
0.0228
620584
require_wp_db( )
…/wp-settings.php:106
7
0.0233
633952
wpdb->__construct( )
…/load.php:404
8
0.0234
634736
wpdb->db_connect( )
…/wp-db.php:592
9
0.0239
636344
…/wp-db.php:1531

Error establishing a database connection

This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at localhost:8889. This could mean your host’s database server is down.
  • Are you sure you have the correct username and password?
  • Are you sure that you have typed the correct hostname?
  • Are you sure that the database server is running?
If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.
但是如果数据库名,数据库的用户和密码,都正确的话:
/Users/crifan/dev/dev_root/crifan.com/mamp/wp_xxx/wp-config.php
define('DB_USER', 'xxx');

/**
* Ersetze passwort_hier_einfuegen mit deinem MySQL-Passwort.
*/
define('DB_PASSWORD', 'xxx');
或:
define('DB_USER', 'root’);
define('DB_PASSWORD', 'root');
然后就彻底无法显示页面了:
无法访问此网站
localhost 拒绝了我们的连接请求。
* 请在 Google 中搜索“localhost xxx”
ERR_CONNECTION_REFUSED
Safari 浏览器无法打开页面 “‎localhost/wp_xxx/”,因为无法连接到服务器“localhost”。
wordpress localhost 拒绝了我们的连接请求
本地服务:无法访问此网站 localhost 拒绝了我们的连接请求。ERR_CONNECTION_REFUSED – CSDN博客
(tomcat一闪而过)localhost拒绝了我们的连接请求原因及解决方案 – CSDN博客
此处,之前好像也有一闪而过的感觉
难道是:
之前改动了Mac的网络访问配置,导致了localhost无法访问 -》 但是又无法弹框问是否允许访问,所以就无法访问了了?
不对,因为另外一个localhost的wordpress是可以正常打开的:
XAMPP中,更改了Apache的端口, 无法打开localhost 的解决方法 – CSDN博客
【已解决】LNMP安装后DNS域名生效后访问出错:无法访问此网站,拒绝了我们的连接请求 – 在路上
试试:
http://localhost/wp_xxx/
http://localhost:8888/wp_xxx/
问题依旧。
Web —— 在自己电脑搭建网站,发布到公网,并使用域名访问 – BensonLaur – 博客园
http://127.0.0.1/wp_xxx/
http://127.0.0.1:8888/wp_xxx/
“无法访问此网站
127.0.0.1 拒绝了我们的连接请求。
请试试以下办法:
* 检查网络连接
* 检查代理服务器和防火墙
ERR_CONNECTION_REFUSED”
wordpress localhost ERR_CONNECTION_REFUSED
试了:
http://localhost:8888/MAMP/wp_xxx/
“Not Found
The requested URL /MAMP/wp_xxx/ was not found on this server.”
Topic: HELP ERR_CONNECTION_REFUSED | WordPress.org
https://wordpress.org/support/topic/help-err_connection_refused/
难道是:
此处的mysql中的数据有问题,导致了被拒绝?
本地的phpinfo是正常的:
http://localhost:8888/MAMP/index.php?page=phpinfo&language=English
http://localhost/wp_xxx/wp-activate.php
也是:
无法访问此网站
localhost 拒绝了我们的连接请求。
* 请在 Google 中搜索“localhost xxx activate”
ERR_CONNECTION_REFUSED
WordPress site experiencing ERR_CONNECTION_REFUSED | DigitalOcean
mac中,没有:iptables
“Delete the .htaccess File
In some cases, the .htaccess file used by Apache and created by WordPress can create issues. The easiest thing to do in such a potential case is to simply delete it and them login to the WordPress Admin and simply save your permalinks. By clicking save, it’ll generate a new .htaccess file for you with the correct parameters.”
去删除.htaccess试试
问题依旧。
通过:
看到nginx是7888
所以试试:
http://localhost:7888/wp_xxx/
问题依旧。
看到:
https://www.digitalocean.com/community/questions/wordpress-site-experiencing-err_connection_refused
“Check Server Logs”
以及后续的:
WordPress WP-Cron cURL connection refused | DigitalOcean
Nginx Error 111: Connection refused | DigitalOcean
why is my site saying “connection refused” ?? | DigitalOcean
Help me to fix “ERR_CONNECTION_REFUSED” | DigitalOcean
找找是否有wordpress(或此处apache)的log
通过:
http://localhost:8888/MAMP/index.php?page=phpinfo&language=English
找到:
error_log
/Applications/MAMP/logs/php_error.log
/Applications/MAMP/logs/php_error.log
去找找看
但是去访问:
http://localhost/wp_xxx/
结果上面几个log都没变化
所以去重启MAMP再去试试
然后
/Applications/MAMP/logs/apache_error.log
[Thu Jun 28 21:26:16 2018] [notice] caught SIGTERM, shutting down
[Thu Jun 28 21:26:52 2018] [notice] Digest: generating secret for digest authentication ...
[Thu Jun 28 21:26:52 2018] [notice] Digest: done
[Thu Jun 28 21:26:52 2018] [notice] FastCGI: process manager initialized (pid 34122)
[Thu Jun 28 21:26:52 2018] [notice] Apache/2.2.32 (Unix) mod_wsgi/3.5 Python/2.7.13 PHP/7.1.6 mod_ssl/2.2.32 OpenSSL/1.0.2j DAV/2 mod_fastcgi/2.4.6 mod_perl/2.0.9 Perl/v5.24.0 configured -- resuming normal operations
[Thu Jun 28 21:27:17 2018] [error] [client ::1] client denied by server configuration: /Users/crifan/dev/dev_root/crifan.com/mamp/.DS_Store
[Thu Jun 28 21:27:19 2018] [error] [client ::1] client denied by server configuration: /Users/crifan/dev/dev_root/crifan.com/mamp/.DS_Store
【无需解决】Mac中MAMP中log显示错误:error client 1 client denied by server configuration mamp .DS_Store
然后发现了:
当mysql用户名和密码(故意)错误时,每次显示phplog页面:
Warning: mysqli_real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in /Users/crifan/dev/dev_root/crifan.com/mamp/wp_xxx/wp-includes/wp-db.php on line 1531
就会有对应log输出:
/Applications/MAMP/logs/php_error.log
[28-Jun-2018 13:48:50 UTC] PHP Warning: mysqli_real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in /Users/crifan/dev/dev_root/crifan.com/mamp/wp_xxx/wp-includes/wp-db.php on line 1531
[28-Jun-2018 13:48:50 UTC] PHP Stack trace:
[28-Jun-2018 13:48:50 UTC] PHP 1. {main}() /Users/crifan/dev/dev_root/crifan.com/mamp/wp_xxx/index.php:0
[28-Jun-2018 13:48:50 UTC] PHP 2. require() /Users/crifan/dev/dev_root/crifan.com/mamp/wp_xxx/index.php:17
[28-Jun-2018 13:48:50 UTC] PHP 3. require_once() /Users/crifan/dev/dev_root/crifan.com/mamp/wp_xxx/wp-blog-header.php:13
[28-Jun-2018 13:48:50 UTC] PHP 4. require_once() /Users/crifan/dev/dev_root/crifan.com/mamp/wp_xxx/wp-load.php:37
[28-Jun-2018 13:48:50 UTC] PHP 5. require_once() /Users/crifan/dev/dev_root/crifan.com/mamp/wp_xxx/wp-config.php:113
[28-Jun-2018 13:48:50 UTC] PHP 6. require_wp_db() /Users/crifan/dev/dev_root/crifan.com/mamp/wp_xxx/wp-settings.php:106
[28-Jun-2018 13:48:50 UTC] PHP 7. wpdb->__construct() /Users/crifan/dev/dev_root/crifan.com/mamp/wp_xxx/wp-includes/load.php:404
[28-Jun-2018 13:48:50 UTC] PHP 8. wpdb->db_connect() /Users/crifan/dev/dev_root/crifan.com/mamp/wp_xxx/wp-includes/wp-db.php:592
[28-Jun-2018 13:48:50 UTC] PHP 9. mysqli_real_connect() /Users/crifan/dev/dev_root/crifan.com/mamp/wp_xxx/wp-includes/wp-db.php:1531
但是之后,如果mysql用户名和密码是正确的话,就找不到后续的log了。
mamp wordpress  localhost refused our request
migrating wordpress to new host, localhost refused to connect – Stack Overflow
localhost refused to connect ERR_CONNECTION_REFUSED
果然像是:
这人说的:
去:
http://localhost/phpmyadmin
中,把option_value中的
your previous site URI
换成:
localhost
去看看:
看到了:
去把:
https://xxx
改为:
http://localhost
然后继续搜索看看:
好像和配置就关系不大了,暂时应该可以忽略。
结果问题依旧。
然后再去换成:
http://localhost:8888
结果:
终于可以打开页面了:
激动万分啊。。。
然后再继续去解决别的问题:
css丢失的问题。
【总结】
此处终于可以在:
正确配置了mysql的数据库的用户名和密码的情况下,不再显示:
Failed to load resource: 无法连接到服务器
无法打开页面

无法访问此网站
localhost 拒绝了我们的连接请求。
* 请在 Google 中搜索“localhost xxx”
ERR_CONNECTION_REFUSED
原因是:
在mysql数据库正确连接后,就去访问:
mysql中的xxx_options(其中xxx是wp-config.php中配置的$table_prefix的值)中的siteurl和home的值(option_value的部分)
而此处的siteurl和home的值(option_value)都是:
那是因为此处的mysql是之前从线上环境:
https://xxx
导出下载下来的
解决办法是:
把xxx_options的siteurl和home的值(option_value),都改为本地localhost的地址:
注意:
不仅仅是:http://localhost
否则默认打开的是80端口,而不是此处MAMP的默认8888端口,还是无法访问的。

转载请注明:在路上 » 【已解决】Mac中MAMP的本地WordPress首页出错:无法打开页面

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.112 seconds, using 20.77MB memory