测试您正在开发的新网站的最佳方法之一是在您的计算机上安装 WordPress 测试站点。在本地进行测试,确保一切看起来和工作正常,然后一次将其上传到实时站点。
对于WordPress,在本地运行时需要考虑几件事。您将需要一个工作的WordPress安装、一个可用的SQL数据库和一个本地 Web 服务器来运行一切。
您可以使用下面概述的过程在本地计算机上轻松设置所有三个。
安装本地 Web 服务器
运行本地WordPress(WordPress)测试站点需要的第一件事是在本地计算机上运行的 Web 服务器。运行 Web 服务器涉及确保正确的端口正在运行、安装PHP和Perl编程语言库,以及 Web 服务器软件可以正确地为您的浏览器提供页面。
与设置 FTP 服务器(setting up an FTP server)或本地 Minecraft 服务器(local Minecraft server)类似,Windows应用程序也可用于运行本地 Web 服务器。其中最受欢迎的之一是XAMPP。
XAMPP 是一个开源的Apache Web 服务器,您可以安装在Windows 10、Linux或 macOS 上。它在一个包中包含您需要的一切。
要开始使用,只需将XAMPP软件下载并安装到您的台式机或笔记本电脑上。
1. 运行安装程序,确保所有组件均已启用,然后选择下一步(Next)继续。
2. 为您的网络服务器选择一个位置。最好的选择是在 C: 驱动器的根目录中选择默认文件夹,在该文件夹中正确设置权限。选择下一步(Next)继续。
3. 选择您的语言并选择下一步(Next)。保持启用Bitnami,这将帮助您在安装后安装WordPress。选择下一步(Next)。最后,再选择Next one time 来安装 XAMPP。
安装大约需要五分钟。完成后,XAMPP控制面板将打开。暂时关闭它。
(Install WordPress)在您的 XAMPP Web 服务器上(Your XAMPP Web Server)安装 WordPress
通过选择Start(Start),键入XAMPP,右键单击XAMPP应用程序并选择Run as administrator 以管理员(Run as administrator)身份再次启动控制面板。当Windows(Windows)询问您是否希望应用程序以管理员权限运行时,您可能需要确认。
启动后,选择Apache和MySQL右侧的Start以启动(Start)WordPress测试站点正常工作 所需的 Web 服务器和SQL数据库。(SQL)
您可以通过查看安装XAMPP的位置来查看 Web 服务器的文件结构。在本例中,XAMPP安装在 C: XAMPP中。这是您所有的网络文件都将放在哪里,可以从您的网络浏览器中查看。
XAMPP 附带Bitnami ,它可以让您在当前 XAMPP Web 服务器上 快速安装WordPress 。
1. 打开网络浏览器并在 URL 字段中输入localhost 。按Enter。当XAMPP仪表板出现时,向下滚动到页面底部,您将在其中看到Bitnami部分。
2. 选择页面底部的WordPress图标。(WordPress)在Bitnami网站上,向下滚动到WordPress部分并选择Windows链接以下载 WordPress。
3. 下载完成后,双击文件启动安装包。根据需要选择下一步(Next)以逐步完成Bitnami WordPress 模块(Bitnami WordPress Module)。确保(Make)为安装指定的文件夹与XAMPP安装的文件夹匹配。
4. 在下一步中,配置您要用于 WordPress 测试站点的管理员登录名、姓名、电子邮件地址和密码。(Admin)
5. 完成后选择Next,输入WordPress测试站点的名称并选择Next。在下一页上,您可以配置电子邮件支持,以便您的测试站点可以向您的电子邮件发送通知。这是可选的。
6. 您可以取消选择使用 Bitnami 在云中启动 wordpress,(Launch wordpress in the cloud with Bitnami)因为这只是您计算机上的本地WordPress测试站点。选择下一步(Next)继续。再次选择下一步(Next)以启动安装。安装完成后,选择完成(Finish)以启动Bitnami WordPress模块。
这将启动您的默认 Web 浏览器并加载新的本地WordPress测试站点。(WordPress)该链接将包括您的本地主机 IP 地址(您的计算机的 IP 地址),最后是 /wordpress/,您的站点存储在其中。
这些WordPress文件的路径是 C:XAMPPappswordpresshtdocs
现在您已准备好配置您的WordPress测试站点并开始使用它。
使用您的 WordPress 测试站点
要访问您的本地WordPress管理页面,请在浏览器URL字段中输入(URL)http://localhost/wordpress/wp-admin并使用您在上面安装WordPress(WordPress)期间设置的凭据登录WordPress。
您可以使用这个新的本地WordPress测试站点做一些事情。
导入您的实时站点的副本
您可以导出您的实际在线网站并将其加载到此安装中进行测试。
为此,您需要备份 WordPress 站点和 WordPress 数据库(backup your WordPress site and WordPress database)。这将为您提供一个包含所有WordPress文件的压缩文件夹,以及一个 *.gz 文件,该文件是您的 mySQL 数据库的备份(backup of your mySQL database)。
您可以将备份的WordPress文件直接复制到本地WordPress文件夹中。您还可以使用 phpMyAdmin 将 mySQL *.gz 数据库文件导入本地 mySQL 数据库。
1.使用浏览器访问http://localhost/phpmyadmin/
2. 选择导入(Import)选项卡,然后选择要导入的文件下的(File to import)选择文件(Choose File)按钮。
3.浏览(Browse)到您备份的 *.gz 数据库文件,phpMyAdmin 会将所有帖子和WordPress设置导入您的测试WordPress站点。
完成后,使用与上面相同的链接重新打开本地WordPress安装,您将看到您的原始在线站点现在在本地计算机上运行。(WordPress)
您可以使用WordPress(Things)测试站点(WordPress Test Site)执行的其他操作
除了在本地机器上运行实时站点之外,您还可以使用本地WordPress测试站点做很多其他有用的事情。
您可以在本地WordPress测试站点的安全中执行所有这些操作,因为您所做的每项更改都只发生在您的计算机上,而不是网络上。
How to Install a WordPress Test Site on Your Computer
One of the best ways to test a new website yoυ’re dеveloping is by installing a WordPress test site on your computer. Tеst it lоcally, make sure everything looks and wоrks good, and then upload it to the live site all at once.
When it comes to WordPress, there are several things to consider when running locally. You’ll need a working WordPress installation, an available SQL database, and a local web server for everything to run on.
You can set up all three on your local computer without too much effort, using the process outlined below.
Install a Local Web Server
The first thing you’ll need to run a local WordPress test site is a web server running on your local computer. Running a web server involves ensuring the right ports are running, PHP and Perl programming languages libraries are installed, and that the web server software can properly serve pages to your browser.
Similar to setting up an FTP server or a local Minecraft server, there are Windows applications available to run a local web server as well. One of the most popular of those is XAMPP.
XAMPP is an open-source Apache web server you can install on Windows 10, Linux, or macOS. It includes everything you need all in one package.
To get started, just download and install the XAMPP software to your desktop or laptop PC.
1. Run the installer, make sure all components are enabled, and select Next to continue.
2. Choose a location for your web server. The best option is to choose the default folder at the root of the C: drive where permissions will be set properly. Select Next to continue.
3. Select your languages and select Next. Keep Bitnami enabled, which will help you with installing WordPress after installation. Select Next. Finally, select Next one more time to install XAMPP.
Installation will take about five minutes. Once finished, the XAMPP control panel will open. Close it for now.
Install WordPress on Your XAMPP Web Server
Launch the control panel again as admin by selecting Start, typing XAMPP, right-clicking the XAMPP application and choosing Run as administrator. You may need to confirm when Windows asks if you want the application to run with admin rights.
Once it launches, select Start to the right of Apache and MySQL to launch the web server and the SQL database needed for your WordPress test site to work properly.
You can see the web server’s file structure by looking at the location where you’ve installed XAMPP. In this example, XAMPP is installed in C:\XAMPP. This is where all of your web files will go that’ll be viewable from your web browser.
XAMPP comes with Bitnami, which lets you quickly install WordPress on top of your current XAMPP web server.
1. Open a web browser and type localhost in the URL field. Press Enter. When the XAMPP dashboard comes up, scroll down to the bottom of the page where you’ll see the Bitnami section.
2. Select the WordPress icon at the bottom of the page. On the Bitnami site, scroll down to the WordPress section and select the Windows link to download WordPress.
3. Once the download is complete, double-click the file to launch the installation package. Select Next as needed to step through the Bitnami WordPress Module. Make sure the folder specified for installation matches that of the XAMPP installation.
4. On the next step, configure the Admin login, name, email address, and password that you want to use with your WordPress test site.
5. Select Next when you’re done, type a name for the WordPress test site and select Next. On the next page, you can configure email support so your test site can send notifications to your email. This is optional.
6. You can deselect Launch wordpress in the cloud with Bitnami since this will just be a local WordPress test site on your computer. Select Next to continue. Select Next again to initiate the installation. Once the installation is done, select Finish to launch the Bitnami WordPress module.
This will launch your default web browser with your new local WordPress test site loaded. The link will include your localhost IP address (your computer’s IP address), with /wordpress/ at the end, where your site is stored.
The path to these WordPress files is C:\XAMPP\apps\wordpress\htdocs\
Now you’re ready to configure your WordPress test site and start using it.
Using Your WordPress Test Site
To access your local WordPress admin page, type http://localhost/wordpress/wp-admin into the browser URL field and log into WordPress using the credentials you set up during the WordPress installation above.
There are a few things you can do with this new local WordPress test site.
Import a Copy of Your Live Site
You could export your actual online website and load it into this installation for testing.
To do this, you’ll need to backup your WordPress site and WordPress database. This will provide you with a zipped folder with all of the WordPress files, as well as a *.gz file which is the backup of your mySQL database.
You can copy the backed up WordPress files directly into your local WordPress folders. You can also import your mySQL *.gz database file into your local mySQL database using phpMyAdmin.
1. Open phpMyAdmin by visiting http://localhost/phpmyadmin/ with your browser.
2. Select the Import tab, and select the Choose File button under File to import.
3. Browse to your backed up *.gz database file and phpMyAdmin will import all posts and WordPress settings into your test WordPress site.
Once you’re done and you reopen the local WordPress installation using the same link as above, you’ll see your original online site now running on your local computer.
Other Things You Can Do With a WordPress Test Site
In addition to running your live site on your local machine, there are a lot of other useful things you can do with your local WordPress test site.
- Install and test any WordPress theme
- Test making code changes to your WordPress site
- Install and test WordPress plugin configurations
- Play around with WordPress configurations to see how it changes your site
You can do all of these things in the safety of your local WordPress test site because every change you make only happens on your computer, rather than the web.