windows wamp
Hosting your own website doesn’t have to cost a monthly fee or require a lot of technical knowledge to setup. If you just need to host a small website that will only have a few visitors, you can turn your Windows PC into a WAMP server.
托管自己的网站不必每月支付费用,也不需要大量的技术知识即可设置。 如果您只需要托管一个只有几个访问者的小型网站,则可以将Windows PC变成WAMP服务器。
Should You Host Your Own Site?
您应该托管自己的网站吗?
While hosting your own website on your local computer is a lot of fun, if you want a website that people can actually access, you might want to get your own web hosting plan somewhere. Bluehost is offering unlimited web hosting for $3.95 per month, with full support for PHP and MySQL. It’s definitely an easy way to get started with a website, and they have simple 1-click installers to get you started with popular software like WordPress and others.
虽然在本地计算机上托管自己的网站很有趣,但是如果您希望人们可以实际访问的网站,则可能需要在某个地方获得自己的虚拟主机计划。 Bluehost提供无限的虚拟主机,每月3.95美元 ,并全面支持PHP和MySQL。 这绝对是一种入门网站的简便方法,并且他们具有简单的一键式安装程序,可让您开始使用WordPress等流行软件。
If you do host your own local site that you want people to access, you’re going to need to open up your firewall to your home computer, and that means you’re potentially opening up some security holes. It’s definitely worth thinking about getting a cheap hosting plan elsewhere, like Bluehost or Hostgator.
如果您确实托管了供人们访问的本地站点,则将需要向家用计算机打开防火墙,这意味着您可能在打开一些安全漏洞。 绝对值得考虑在其他地方(例如Bluehost或Hostgator)获得便宜的托管计划。
If you just want a local development server, then keep reading.
如果您只需要本地开发服务器,请继续阅读。
什么是“ WAMP”? (What is “WAMP”?)
WAMP is an acronym that stands for “Windows, Apache, MySQL, and PHP”. When you download a WAMP, you are just downloading a program that installs three different things. WAMPs are convenient because they allow you to download and install all of the packages you need for hosting dynamic web content in one fell swoop. Otherwise, you’d have to download the three packages separately.
WAMP是首字母缩写词,代表“ Windows,Apache,MySQL和PHP”。 当您下载WAMP时,您只是在下载一个安装三种不同程序的程序。 WAMP之所以方便,是因为它们使您能够一次下载并安装托管动态Web内容所需的所有软件包。 否则,您必须分别下载这三个软件包。
Windows – The “W” in WAMP is just there to specify that the program is compatible with Windows operating systems.
Windows – WAMP中的“ W”仅用于指定程序与Windows操作系统兼容。
Apache – This is the program that is used to actually host your website. With it alone, you can host HTML files and other static web content.
Apache –这是用于实际托管您的网站的程序。 仅凭它,您就可以托管HTML文件和其他静态Web内容。
MySQL – This provides a database for your web content. A lot of dynamic web pages need to store data (i.e. usernames and password for web accounts), which is where MySQL comes in.
MySQL –这为您的Web内容提供了一个数据库。 许多动态网页都需要存储数据(例如,网络帐户的用户名和密码),这就是MySQL的用武之地。
PHP – The most popular language for writing dynamic web content – by far. WordPress, Facebook, Joomla, and many other websites and content management systems utilize PHP. If you plan to host anything more than static web pages, PHP will be an essential companion.
PHP – 迄今为止,用于编写动态Web内容的最流行的语言 。 WordPress,Facebook,Joomla和许多其他网站和内容管理系统都使用PHP。 如果您打算托管除静态网页之外的任何其他东西,PHP将是必不可少的伴侣。
If you’re running Linux instead of Windows, you’ll need to install a LAMP. It’s also possible to host a website on Windows using IIS so you don’t have to install any third party software. Going the IIS route isn’t recommended for most purposes and it’s much more of a process to support dynamic web content – so stick with WAMP unless you have a unique circumstance requiring IIS.
如果您运行的是Linux而非Windows,则需要安装LAMP 。 也可以使用IIS在Windows上托管网站,因此您无需安装任何第三方软件。 不建议将IIS路由用于大多数目的,它更多是支持动态Web内容的过程–因此,除非有特殊情况需要IIS,否则请坚持使用WAMP。
Before we proceed, please understand that hosting a website on an everyday PC and a consumer-grade internet connection is not recommended for anything beyond testing purposes and/or hosting a small website for a few visitors. Remember, the next time Windows Update needs to restart your system, your website goes down along with it – not an ideal situation for a serious website.
在进行下一步之前,请理解,不建议在日常PC上托管网站和消费者级别的互联网连接,而不是出于测试目的和/或为少数访问者托管小型网站。 请记住,下次Windows Update需要重新启动系统时,您的网站会随之关闭-对于严重的网站而言,这不是理想的情况。
安装WAMP (Installing WAMP)
There are a lot of WAMP programs available, but we’ll be working with WampServer. Head over to their website and download the latest version of their program, then start the installation.
有许多WAMP程序可用,但我们将使用WampServer 。 转至他们的网站并下载其程序的最新版本,然后开始安装。
The installation prompts are self-explanatory; just keep everything at its default value and keep clicking Next. You can just click Open on this prompt to have WampServer use your default browser whenever you choose to look at your website:
安装提示不言自明; 只需将所有内容保持其默认值,然后单击“下一步”即可。 只要您选择查看您的网站,就可以在此提示上单击“打开”,以使WampServer使用默认浏览器:
Be sure to also add the security exception for Apache in Windows Firewall:
确保还为Windows防火墙中的Apache添加了安全例外:
When the installation completes, check the box that says “Start WampServer 2 now” before hitting Finish. You should see the program running in your notification area.
安装完成后,在单击“完成”之前,选中“立即启动WampServer 2”框。 您应该在通知区域中看到正在运行的程序。
Left click on the icon and hit “Localhost” at the top of the selection menu to open your website.
左键单击图标,然后单击选择菜单顶部的“ Localhost”以打开您的网站。
The default page currently just shows us a quick information page so we can confirm that all components are working properly. If you see this screen, then you’ve successfully installed a WAMP server.
默认页面当前仅向我们显示一个快速信息页面,因此我们可以确认所有组件均正常工作。 如果看到此屏幕,则说明您已经成功安装了WAMP服务器。
一些快速故障排除 (Some Quick Troubleshooting)
We did several test installs of this program and found that a few packages from Microsoft are absolutely essential to get WampServer working properly. If you’ve ran into any trouble up to this point, ensure that you have the following updates installed, uninstall WampServer, restart your PC, and reinstall WampServer.
我们对该程序进行了几次测试安装,发现Microsoft的一些软件包对于正常运行WampServer是绝对必要的。 如果到目前为止遇到任何麻烦,请确保已安装以下更新,卸载WampServer,重新启动PC,然后重新安装WampServer。
WAMP 32-bit required packages: Microsoft Visual C++ 2008 SP1 Redistributable Package (x86) Microsoft Visual C++ 2010 SP1 Redistributable Package (x86) Microsoft Visual C++ 2012 (select vcredist_x86.exe)
WAMP 32位必需软件包: Microsoft Visual C ++ 2008 SP1可再发行软件包(x86) Microsoft Visual C ++ 2010 SP1可再发行软件包(x86) Microsoft Visual C ++ 2012 (选择vcredist_x86.exe)
WAMP 64-bit required packages: Microsoft Visual C++ 2008 SP1 Redistributable Package (x86) (that’s not a typo – you need the x86 package) Microsoft Visual C++ 2008 Redistributable Package (x64) Microsoft Visual C++ 2010 SP1 Redistributable Package (x64) Microsoft Visual C++ 2012 (select vcredist_x64.exe)
WAMP 64位必需的程序包: Microsoft Visual C ++ 2008 SP1可再发行程序包(x86) (这不是错字-您需要x86程序包) Microsoft Visual C ++ 2008可再发行程序包(x64) Microsoft Visual C ++ 2010 SP1可再发行程序包(x64) Microsoft Visual C ++ 2012 (选择vcredist_x64.exe)
进一步的WAMP配置 (Further WAMP Configuration)
To change the page(s) that your web server displays, open the www directory by left clicking on the WAMP icon in the notification area.
要更改您的Web服务器显示的页面,请在通知区域中左键单击WAMP图标以打开www目录。
The folder that opens is where you need to put any files that you’d like to host on your website. Anything from WordPress installation files to static HTML files can be placed in here, and the changes will be reflected on your website at the same time (just click refresh).
在打开的文件夹中,您需要将要托管的任何文件放置在网站上。 从WordPress安装文件到静态HTML文件的任何内容都可以放在此处,更改将同时显示在您的网站上(只需单击刷新)。
Let’s look at a quick example for how you would drop content into that folder for it to be served up on your website. You can use a web development program or something as simple as Notepad to create a basic PHP page and put it on your website.
让我们看一个简单的示例,说明如何将内容拖放到该文件夹中以便将其投放到您的网站上。 您可以使用Web开发程序或诸如记事本之类的简单工具来创建基本PHP页面并将其放置在您的网站上。
The following code will be a good start:
以下代码将是一个好的开始:
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
Paste that code into Notepad and save your file as index.php inside of C:\wamp\www
将该代码粘贴到记事本中,然后将文件另存为C:\ wamp \ www中的index.php
Now return to your website (or hit refresh [F5] if you already have it opened) and you’ll see the page you just created.
现在返回您的网站(如果已经打开,请单击刷新[F5]),您会看到刚创建的页面。
By default, your website is currently only accessible by the computer that WampServer is installed on. That’s perfect for anyone who’s just using their WAMP server for testing or development purposes, but to make your website accessible to the rest of the world, click on the WampServer icon and click “Put Online”.
默认情况下,当前只有安装WampServer的计算机可以访问您的网站。 对于仅将WAMP服务器用于测试或开发目的的人来说,这是完美的选择,但是要使您的网站可以被世界其他地方访问,请单击WampServer图标,然后单击“上线”。
By default, the Apache configuration file is set to deny incoming connections from everyone except for the localhost, so you’ll also have to change two lines of code so other devices don’t see a “403 Forbidden” error whenever they try to load your site. Access httpd.conf (Apache configuration file) by left-clicking the WampServer menu and looking under the Apache folder.
默认情况下,Apache配置文件设置为拒绝除本地主机以外的任何人的传入连接,因此您还必须更改两行代码,以便其他设备每次尝试加载时都不会看到“ 403 Forbidden”错误您的网站。 左键单击WampServer菜单并在Apache文件夹下查看,以访问httpd.conf(Apache配置文件)。
Scroll down until you see some code that says:
向下滚动,直到看到显示以下代码的代码:
Order Deny,Allow
Order Deny,Allow
Deny from all
Deny from all
Delete this code and replace it with:
删除此代码并将其替换为:
Order Allow,Deny
Order Allow,Deny
Allow from all
Allow from all
Save the changes to the httpd.conf and restart all services.
将更改保存到httpd.conf并重新启动所有服务。
Your site should now be accessible from the World Wide Web. If not, ensure that you have forwarded port 80 to your computer on your router.
现在应该可以从万维网访问您的站点。 如果不是,请确保已将端口80转发到路由器上的计算机 。
翻译自: https://www.howtogeek.com/177129/beginner-geek-how-to-host-your-own-website-on-windows-wamp/
windows wamp