【发布时间】:2018-12-27 16:15:33
【问题描述】:
上下文:我正在尝试在 Ubuntu 上本地复制我的 Wordpress - WP 网站。我的最终目标是将其迁移到 Django-CMS。
我正在使用带有 Virtualbox - VB 的 Vagrant。 Lamp stack 安装在带有 Apache/2.4.29、Ubuntu 18.04.1 LTS 和 PHP 7.2 的 VB 中。
当我加载以下 PHP ('bonjour.php') 页面时:
<html>
<head>
<title>Test PHP</title>
</head>
<body>
<?php echo '<p>Bonjour le monde depuis ' . dirname( __FILE__ ) . '</p>'; ?>
</body>
</html>
一切都很好。我将页面呈现为:
Bonjour le monde depuis /var/www/math-wp
但是,当我尝试从 Wordpress 加载 index.php 页面时:
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
到达localhost 页面时,我收到错误消息ERR_CONNECTION_REFUSED。
错误的根本原因是什么?我该如何调查?是否有有用的日志文件?
一些额外的元素:
- MySQL 已安装且运行良好。
- 我可以通过用户正确访问 wp-config.php 中列出的 WP DB 和密码列在同一个文件中。
- 我将 WP DB site_url 和 home_url(使用 wp CLI)更改为
http://localhost。
谢谢!
如果有用的话,我使用的 Apache2 配置文件是:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
#
ServerAdmin webmaster@localhost
# ServerName math-wp.com
# ServerAlias www.math-wp.com
DocumentRoot "/var/www/math-wp"
DirectoryIndex bonjour.php
<Directory "/var/www/math-wp">
Options +FollowSymLinks
AllowOverride all
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.math-wp.com.log
CustomLog ${APACHE_LOG_DIR}/access.math-wp.com.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
【问题讨论】:
-
切换后你重启apache了吗? sudo systemctl restart apache2
-
是的,我确实重新启动了 Apache。感谢您的照顾!
-
您的 vhost 文件或 /etc/apache2/ports.conf 中是否有“监听”指令?您应该有类似于以下内容的行:Listen 80
-
另外,尝试运行此命令并检查您的问题是否已解决:sudo a2endmod ssl && sudo a2enmod rewrite && sudo /etc/init.d/apache2 restart
-
@PatrickSimard 感谢帕特里克接受。我确实在
/etc/apache2/ports.conf中有一个Listen 80指令,并且我启用了您在cmets 中提到的模块。但是,这并不能解决问题。但是,我用一些元素更新了这个问题。