Showing posts with label wampserver. Show all posts
Showing posts with label wampserver. Show all posts

Friday, 18 November 2016

Virtual Hosting with the new WampServer 3.0.6

Have you ever wondered how you can work on your local server without having to type localhost/example in your browser? well if you have or not it is very possible and even easier with the new WampServer 3.0.6 through what is known as Virtual Host (Vhost).

Most web developers are familiar with this term , but let me make some clarification for you newbies out there, virtual host refers to the practice of running more than one website such as  gigzweb.com and gigzweb2.com on the same physical machine. virtual Host can be either IP-Based or Named -Based . For IP- Based virtual host you have different IP address for every website while the Named- Based virtual host just en-tells that you have multiple names running on each IP address.





The benefits of enabling virtual hosting in a local environment are enormous;

1.It helps you testing the behaviour of each site you develop

2.It comes in very handy when your working with PHP frame works like codeigniter ,CakePHP, Zend frame work and the rest which requires a base URL configuration, since  almost all the PHP frame works out there use the MVC architecture of programming it becomes very necessary.

3 Most importantly it enables you to work on different projects at the same i.e having multiple projects in your WWW directory.

4.virtual host generally makes URLs cleaner - localhost/gigzweb.com  vs  gigzweb.com

With the release of WampServer 3.0.6 the problems which were involved in enabling virtual  host in Apache was handled. Previous  versions of WampServer required editing and modification of the Apache config files to enable  virtual host,I personally had to uninstall my Wamp 2.5 three times while trying to enable Virtual Host because of the changes I made to my config files  , previous versions   also required writing rules for IP address in your windows host files which you shouldn't try unless you know what  your doing.

follow these steps to configure a virtual Host in WampServer 3.0.6;


1.Download and install the  latest version of WampServer which at the time  I was writing this post was 3.0.6. from  the WampServer official page .



  NOTE Wamp 3.0.6 was developed using visual studio 2015, so to be able to run the programme you need to download  and install visual studio redistributable 2015 from the official Microsoft site if you have any problem while installing the package  try running a complete  windows update.

2.launch the application .check to see if the green icon


is showing in your task bar, if not know that all the services  are not running.if you get this error " msvcr110.dll missing" message while launching  the application  try uninstalling  and reinstalling your vc_redist 2015 and make sure your windows is up to date.



3. visit "localhost " in your browser and you should see the WampServer default homepage


4.clik on  add "a virtual host" a the bottom of the page.

6.  In the next page add the name of your virtual host you wish to create, for this tutorial I will be creating "www.mynewsite.com" as my virtual Host name .Next add the directory to the folder which contains your site files this should be a sub directory under your C:\wamp\www directory which is your main http directory. the directory should have a forward slash instead of a backward slash example;   "C:/wamp/www/www.mymynewsite.com

Note:the virtual Host name does no have o be the same with the site directory.

5.  click on "start creation of virtual host".

6. Restart your WampServer to effect the changes by right clicking on your wampserver icon and selecting tools,under tools select restart DNS.

7.  Finally go to www.mynewsite.com on your browser to view your newly created virtual host.



Hey guys, I hope this post was helpful, do drop your comments and I will get back to you.Bye for now till my next post.
.

Saturday, 12 November 2016

How to host your website using Wamp server

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.


The steps required are as followes

INSTALL WAMPSERVER 2.5


I have a separate post on how to do this if you need help with this step. Simply download wamp server from WampServer 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 trouble shooting  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 wampapache and wampmysql 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 developmentfor 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 2 inbound rules for TPC and UDP on Windows Firewall for port 80 and 443.
Also, allow wampmanager.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-mysql-root-password-in-localhost-using-wamp 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 C:\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 youipaddress

where youipaddress 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 in C:\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 from 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.

Sunday, 30 October 2016

How to configure wampserver for local development

 

Most people who are new to web development  always find  it difficult working with a testing server to test their programs.
wampserver is a local development server which enables programmers to test and debug their programs before deployment . even though wampserver can be used to host website in a LAN (local area network) it is not advisable to host very important sites like an e-commerce site or an application portal because of the security risks involved.

In this post i will walk you through the processes required to set  up wampserver 2.5 on a windows machine running either  windows 7,8 or 10 OS .While in a separate post I will be demonstrating how to configure MAMP and LAMP which are the alternatives to wamp for persons running Linux or Mac OS.

This tutorial will be in Two simple steps;
  1. downloading  and installing Wamp server 
  2. Configuring WampServer for local development
Which won't take more than 15 minutes to complete.

So lets get started ,first thing is to go over to the official Wampserver site an download wamp 2.5 depending on your systems architecture either a 32bits or a 64 bits. If your not sure you can check by going to your control panel and clicking on the system tab under systems and and security.You can also simply do this by pressing the windows key and  the "x" key together.
Once your download is complete you must confirm that you have Visual studio 2012 redistributable installed in your computer before proceeding to intall or else you will get an error will the installation is in progress or when you lunch the application, so do this just go over to  your control panel and click on programs  features under program.You should she Microsoft visual C++ 2012 otherwise head over Microsoft and download the redistributable. If every  thing is in order your ready to proceed with installation. Make  sure  your installation path is in the root directory example "C:\wamp"  and avoid installing the program  under another directory.