如何通过网络和本地主机在本地启用Wordpress网站 [英] How to enable wordpress website locally on network and via localhost

查看:155
本文介绍了如何通过网络和本地主机在本地启用Wordpress网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的wordpress网站在我的Mac上可以通过Xammp在本地主机上正常工作.我想在我的iPhone上查看该网站.所以我输入192.168.0.2和voila,它打开了我的本地主机目录.然后,我单击有问题的网站,那里的内容在那里,但没有样式或图像.我意识到这是因为所有资源的路径都被硬编码到wordpress数据库中.因此,当我通过iPhone上的192.168.0.2/mywebsitename访问URL时,它将使用localhost/mywebsitename的基本URL查找所有资源.我的iPhone上不存在Localhost路径,只有192.168.0.2存在.

My wordpress site works fine on my mac via localhost, using Xammp. I want to view the site on my iPhone. So I type in 192.168.0.2 and voila, it brings up my localhost directory. I then click on the site in question and the content is there but no styling or images. I realise that this is because the paths to all the resources is hardcoded into the wordpress database. So when I am accessing the url via 192.168.0.2/mywebsitename on my iPhone, it's looking for all the resources using a base url of localhost/mywebsitename. Localhost path doesn't exist on my iPhone, only 192.168.0.2 does.

那么有没有人找到这个小问题的解决方案?如何通过IP地址和本地主机访问权限查看wordpress安装?

So has anyone found a solution to this little issue? How can I see a wordpress installation by ip address and by localhost access?

推荐答案

在开发网站之前,针对此确切问题.您必须创建一个域(Apache中的VirtualHost)

For this exact issue, before developing a website. You must create a domain(VirtualHost in apache)

在文件httpd-vhosts.conf中添加以下内容,确保该文件包含在Apache Configuration中.此行(Include conf/extra/httpd-vhosts.conf)应该出现在httpd.conf

Add the following contents in the file httpd-vhosts.conf, make sure it is included in Apache Configuration. This line ( Include conf/extra/httpd-vhosts.conf ) should be present in httpd.conf

httpd-vhosts.conf的内容:

Contents of httpd-vhosts.conf:

NameVirtualHost 192.168.1.26:80
<VirtualHost 192.168.1.26:80>
<Directory "e:/program files/ampps/www/mywebsite">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
ServerName 192.168.1.26
ServerAlias 192.168.1.26
ScriptAlias /cgi-bin/ "e:/program files/ampps/www/mywebsite/cgi-bin/"
DocumentRoot "e:/program files/ampps/www/mywebsite"
ErrorLog "E:/Program Files/ampps/apache/logs/192.168.1.26.err"
CustomLog "E:/Program Files/ampps/apache/logs/192.168.1.26.log" combined
</VirtualHost>

(根据需要更改路径,ip等).现在添加内容之后. 重新启动Apache .现在,当您从网络中的另一台计算机或同一台计算机访问192.168.1.26(以我为例)时.您应该直接看到mywebsite文件夹的内容(或目录index.php,如果有的话).现在,使用您指定的ip(浏览器应在地址栏中输入该ip)来安装wordpress,在我的情况下为192.168.1.26.

(Change the path, ip, etc according to your need). Now after adding the contents. Restart Apache. Now when you access 192.168.1.26 (in my case) from other machine in your network or your same machine. You should see the contents of mywebsite folder directly(or contents index.php if it has any). Now install wordpress using the ip you specified(browser should have that ip in the address bar), in my case 192.168.1.26.

我使用AMPPS来避免这种头痛.它允许我在本地创建域.另外,如果我购买了说mywebsite.com的域名,并且想在其上添加自定义的wordpress网站,那么我会在AMPPS中使用相同的名称创建一个域名.因此,我的实时网站的网址与本地网址相同. :)然后,我只需通过FTP将文件直接放在服务器上,然后显然将数据库导入服务器上.

Well I use AMPPS to avoid this headache. It allows me to create domains locally. Also if I have bought a domain say mywebsite.com and i want to add a customized wordpress site on, I create a the domain in the AMPPS with the same name. So the URL of my live website and the local are same. :) Then I simply put the files directly on my server via FTP and obviously import the database on my server.

顺便说一句, AMPPS 允许单击安装WordPress.它具有简单的界面,您可以在其中指定AMPPS在创建的域上安装WordPress.

BTW, AMPPS allows to install WordPress in a single click. It has simple interface where you can specify AMPPS to install the WordPress on the created Domain.

这篇关于如何通过网络和本地主机在本地启用Wordpress网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆