How to Use Wamp Server to Create Website
How to Use Wamp Server to Create Website
So you want host your own website, well you found the right post. If you have a spare Windows machine and some time, I will show you how to host your own website using WAMP server from your home or office. In this post I will show you the steps I took to configure WAMP to start my web server and host my own website for testing and personal projects.
You may have one or several reasons why you would want to host your own website, perhaps you want to:
- host a small personal blog.
- host a portfolio site.
- host your resume.
- test a web application.
- or just simply learn how to setup your own web server, of course.
Any of these project can be easily hosted from your own web server without having to pay a company for web hosting. However, I would NOT recommend this approach if you are doing anything complex, like a business or eCommerce site, or generally a site that you expect to grow and get a lot of traffic, as most ISP would not allow this and even if they do you will probably end up having to invest more time and money on better software and hardware to keep up. Rather, I recommend using a good web host, like SiteGround or GreenGeeks, to do these types of projects.
In my case, I want to test a tool like MainWP without the restrictions of a web host and I do not want to spend a lot of money for VPS hosting, so for me it makes sense to run this on my own web server. I have an HP ProLiant mini server which is a nice and small eco-friendly machine that is always on. Hosting my website on it will not only save me money but it will allow me to change any parameters typically not allowed in shared hosting plans, like memory limits and max execution timeouts (ugh!).
The mini HP ProLiant machine runs Windows Home Server 2011 and it is ideal as a personal or even as a small business web server. But technically, you may do this on any reliable machine running Windows 7, 8 or even on another operating system, although this post is geared towards Windows users. The HP mini server runs quiet and cool, so you may want to consider how loud and how hot your machine gets if you plan on using it as an 'always on' server.
In my case, I will need to consider any roles my server has before adding WAMP to serve my web pages. Currently, my server is running IIS to allow me to view, save, and retrieve files from my home network as well as from the outside world via a web browser. If I want to use WAMP Server, I will need to disable the IIS service.
Once you have taken the above into consideration you should be ready to begin. Well enough talk and lets get started.
Install WAMP Server
I have a separate post on how to do this if you need help with this step. Simply download wamp server from wampserver.com/en/ and take the defaults. Once it is installed you will notice the green light on the wamp icon on your system tray.
If the icon is red or orange, you have a conflict with another application. In my case, most of the time I encounter this issue is if IIS is running on the machine. You can check what service is using port 80 if you want to confirm this. Go to Apache –> Service –> Test Port 80 and see which service is using port 80. If IIS is using the port, you will want to disable the following service: IIS Admin Service and World Wide Web Publishing Service.
You can check out my post on troubleshooting the orange status light in WAMP Server for additional help with the orange status light.
Set WAMP Server to run on automatic
Configure the 'Startup Type' under Window services to automatic for both wampapache64 and wampmysqld64 services.
Now you will want to make wampmanager.exe start when Windows starts. So in case you re-start your server, or it re-starts itself due to Windows updates, power surges, or other unpredictable cause, your are covered.
Check out my post on Configuring WAMP Server on Windows for WordPress local development for further details on how to do this step.
Configure Windows Firewall to allow wampmanager, port 80 and 443
Port 80 and 443 must be allow for both TCP and UDP packets. To do this, create 2inbound rules for TPC and UDP on Windows Firewall for port 80 and 443.
Also, allowwampmanager.exe found in the wamp installation folder, in my case that is C:\wamp.
Set the MySQL root password
This is a very important step. I suggest making a strong password with upper and lower case letters and numbers, throw in a couples of symbols too. There are a few ways to do this, one is by going to the MySQL console and typing the appropriate commands, another way is via the GUI (graphical user interface) using SQL Buddy or PHPMyAdmin. Go to my post on how to set the Root password for MySQL for steps by steps instructions on how to do this.
Configure PHPMyAdmin
Configure phpMyAdmin to require a password. Open the config.inc.php file found in C:\wamp\apps\phpmyadmin[version#] and edit the following:
On the following lines..
$cfg['Servers'][$i]['auth_type'] = 'config';
Change 'config' to 'http'.
$cfg['Servers'][$i]['user'] = 'root';
Delete user root and just leave the quotation marks empty, like so = ' ';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
Change true to false.
Create a Log Out URL by adding the following line..
$cfg['Servers'][$i]['LogoutURL'] = 'http://your-external-ip-address/';
Now, if you have a static IP, you should be ok entering it here. But in case you do not, like most of us, then you will want to enter the domain you plan on using for your website (recommended).
Save your file and go to http://localhost/phpmyadmin – You should be prompted for a user name and password now.
Configure Apache
Now we need to make Apache listen to port 80 on our host machine. For this, open your httpd.conf file found under C:\wamp\bin\apache\apache[version#]\conf and edit the following lines:
Listen 0.0.0.0:80 ServerName localhost:80
Change it to..
Listen youripaddress:80 ServerName youripaddress
where youripaddress is equal to the local ip address of your web server.
Find <Directory "c:/wamp/www/"> and enter:
Order Allow,Deny Allow from all
right before </Directory>
Save the file.
Configure PHPMyAdmin Alias file
This will allow us to access PHPMyAdmin from the web. Open phpmyadmin.conf found inC:\wamp\alias and edit the following line:
Require local
and replace it with..
Require all granted
Save the file. You should now be able to access the site via http://youripaddress and PHPMyAdmin via http://youripaddress/phpmyadmin
Enhancing Security
Please note that WAMP Server is commonly used for local development, and not as a hosting platform for production as it is inherently un-secure. However, you can take some measures to secure it like the ones I am going to suggest here.
Here are a few things to check for: Open your httpd-default.conf file found under C:\wamp\bin\apache\apache[version#]\conf\extra and make sure you set the following parameters..
ServerTokens Prod
This directive configures what WAMP returns as the Server HTTP response, setting it to prod returns the least info.
ServerSignature Off
This will stop Apache from broadcasting the server signature, which includes server version and virtual host name and other possibly sensitive information.
TimeOut 60
This will help prevent DoS attacks. It should be 60 by default but check just in case.
Re-start all services if you haven't been doing so by clicking on 'Restart all services'.
You are almost done, next step is to remove the files in the www folder. You can delete them or move them to another folder outside www.
You can now place your website files in here.
For additional security, I suggest placing an index file in the root and any sub directory of your website.
Adding an htaccess file with an unauthorized directory browsing rule would be ideal. You can drop this line in the .htaccess file:
#to disable directory browsing
Options All -Indexes
and place it in your root (www) and that should take care of things. To create an .htacces file in Windows check out this post on StackOverFlow. Also, check out Perishablepress htaccess tricks page for some cool things you can do with htaccess files to greatly enhance your websites security.
I wrote this tutorial based on my own experience with WAMP and what I have learned from others on the internet. I am not a security expert so if you have any suggestions on how to further secure WAMP or you have some best practices please feel free to let me know in the comments below.
Forward web traffic to your web server's IP.
If you are reading this, I am going to assume you are somewhat familiar with port forwarding . But if you need help, just type 'port forwarding' in Google and you will get many sites that will show you how to forward a port. Basically, you want to forward any web traffic on port 80 to your machines local IP address. If you plan on using ssl, you may also want to forward port 443. On my router, it looks something like this:
Put WAMP Server online
The last step is to put WAMP server online.
You did it! Now sit back, enjoy some tea and watch your web server do what its meant to do, serve your web pages to the world!
Hopefully this will help you in your current and future web projects. If you have any questions about this setup please leave me a comment below and I will be happy to help.
Thank you for stopping by.
Disclosure: Please note some of the links in this post are affiliate links, which will allow me to get a small commission if you end up purchasing/or using the recommended product. You will be helping me out and the cost of the product will still be the same. Thank you!
Source: https://blog.hsnyc.co/development/how-to-host-your-own-website-using-wamp-server/
Posted by: bardonwearprapart.blogspot.com
0 Response to "How to Use Wamp Server to Create Website"
Post a Comment