简体   繁体   English

Apache虚拟服务器wordpress

[英]Apache Virtual Server wordpress

I am new to both Apache and wordpress. 我是Apache和wordpress的新手。 I am using Apache 2.2. 我正在使用Apache 2.2。 I have mapped a public IP address to the server on which wordpress is located (192.168.0.99). 我已将公共IP地址映射到wordpress所在的服务器(192.168.0.99)。 From anywhere on the same net it is possible to type the public IP address into a browser and get the default Apache page, or type in [public IP address]/wordpress, and get the wordpress page I have set up. 在同一网上的任何地方,都可以在浏览器中键入公共IP地址并获取默认的Apache页面,或者键入[公共IP地址] / wordpress,并获取我已设置的wordpress页面。

When I attempt the same test from outside the network (eg using Safari on a Vodafone 3G), the public IP address brings up the default Apache page, but [public IP address]/wordpress refuses to load anything. 当我从网络外部尝试相同的测试时(例如,在Vodafone 3G上使用Safari),公共IP地址将显示默认的Apache页面,但是[公共IP地址] / wordpress拒绝加载任何内容。

I have set up /etc/httpd/conf/httpd.conf as follows: 我已经按照以下步骤设置了/etc/httpd/conf/httpd.conf:

LogLevel debug

DocumentRoot "/var/www/html"

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot "/var/www/html"
    ServerName localhost
    ErrorLog /var/log/httpd/my_error_log
    CustomLog /var/log/httpd/my_custom_log common
</VirtualHost>

In MySQL, 在MySQL中,

wordpress.wp_options: option_id: 1,
option_name: siteurl,
option_value: http://192.168.0.99/wordpress,
autoload: yes

my_error_log and my_custom_log both receive sprays of messages, indicating that the Virtual host is gathering requests. my_error_log和my_custom_log都收到大量的消息,表明虚拟主机正在收集请求。 When I try to access wordpress from the Vodafone mobile the only entry seen in my_custom_error is: 当我尝试从Vodafone手机访问wordpress时,在my_custom_error中看到的唯一条目是:

[Mobile network provider's IP] - - [Date and Time] "GET /wordpress/ HTTP/1.1" 200 99982

There are no entries in my_error_log. my_error_log中没有任何条目。

What have I missed? 我错过了什么?

The problem is that wordpress expects to be hosted on the address that's set in the database. 问题在于,wordpress希望托管在数据库中设置的地址上。 If you happen to access it on a different address, wordpress will redirect you to the address in the database. 如果您碰巧在其他地址上访问它,则wordpress会将您重定向到数据库中的地址。 In your case, the public address will result in wordpress trying to serve the local address. 在您的情况下,公共地址将导致wordpress尝试提供本地地址。

option_value: http://192.168.0.99/wordpress,

Solution 1: use a hostname. 解决方案1:使用主机名。 Set up a hostname to point to your public address and enter that as your wordpress's site address. 设置主机名以指向您的公共地址,然后输入该地址作为您的wordpress的站点地址。

option_value: http://myhostname.somedomain.com/wordpress,

You can have the hostname point to the local address internally by using hosts file entries or setting up an internal DNS server with the local entry for your chosen hostname. 您可以使用主机文件条目或在内部DNS服务器中使用所选主机名的本地条目来设置主机名指向内部地址。 There are services such as noip.com that will provide you with a hostname for free. 有诸如noip.com之类的服务可以免费为您提供主机名。

Solution 2: Another thing you could do, if you don't mind losing LAN access to the site, is to just update wordpress so that it's using the public rather than private ip address, and it should work as you expect from outside your network. 解决方案2:如果您不介意失去对站点的LAN访问权限,则可以做的另一件事是仅更新wordpress,以便它使用公共ip地址而不是私有ip地址,并且它应该可以从网络外部按预期工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM