Web hosting is a service that enables companies and people to make their website accessible via the World Wide Web. A web host provides the infrastructure and services that a website needs to operate on the web.
If you are planning on starting a website, you will need to invest in your own domain name and web hosting. Depending on your hosting needs, the costs could run from just $50 (shared hosting) to over $10,000 a year (dedicated server).
If you are developing a new website, hosting your own site on a local machine may be the best option.
In this article, I will provide you with a detailed review of how to host your site either on a Windows or Linux system.
It is, however, important to note that hosting your site yourself comes with quite a few disadvantages. I will expose you to some of these shortcomings and the available options for solving them.
How to host a Website using Windows
Hosting a website on your PC can be very interesting. It is recommended that you only opt for this if you want a local development server. A WAMP server is the primary necessity to consider for hosting a website on your Windows operating system.
What is a WAMP Server?
WAMP is the contracted form of Windows, Apache, MySQL, and PHP. A WAMP server, therefore, installs three different applications simultaneously. These servers are considered to be quite convenient because they allow you to download and install all the packages necessary for hosting any web content. The elements of WAMP can be explained as follows:
Windows- it shows that the AMP applications are compatible with Windows devices. Other platforms such as Linux, for instance, will have it as LAMP.
Apache– this is the core program that performs the hosting services. Apache program is very efficient in hosting HTML files as well as other static web documents.
MySQL– it offers a database that will contain all your web content. Dynamic web pages need to store data from time to time thus require a database. Examples of such data include usernames, passwords, and emails.
PHP– this is perhaps the widest spread language for creating dynamic web content. Some of the popular websites known to run on PHP code are Facebook and WordPress.
Step 1: Installing the WAMP Software
Visit the WampServer website and download the latest version. Choose either 32 or 64 bit depending on your operating system. The package comes with the most recent installments of Apache, MySQL, and PHP. Run the .exe file in the WAMP setup you have downloaded. You will receive installation prompts that are straightforward. Click “next” while maintaining the default values to continue with the installation. Choose the browser of your choice or just hit “open” and the Web Server will use your default PC browser.
As you carry out this process, windows firewall may reject some features of Apache. Therefore, make sure to make an exception when you receive a security alert pop up. After the installation is complete, mark the box labeled “Start WampServer 2 now” before eventually clicking the “Finish” button.
Step 2: Navigating the WAMP Server
If you’d like to change the pages displayed by the web server, go to the www directory by clicking the WAMP icon in the notification pane. The directory is automatically created during installation and can be found in local disk C (c:\\wamp\\www). You also have the option of creating subdirectories referred to as projects in WampServer. These will come in handy in storing HTML or PHP files. If you install WordPress for instance, its installation files will be saved in the directories. You can update any changes within the application by clicking the refresh button.
Step 3: Create an HTML or PHP Page
This section shows you how to test the WebServer. Use a web development program such as Notepad to develop a simple PHP or HTML page. Go to ‘save as’ and give it any name and add the extension .php (e.g. “name.php”). Set c:\\wamp\\www to be the destination of the saved file. Return to WebServer and click refresh to update these changes. Your data will be updated in the www directory. To test it, go to http://localhost/name.php through your browser. You will be taken to your new web page where you will see the details of your PHP installation.
Step 4: Configuring MySQL
You can begin configuring your MySQL databases by opening the phpMyAdmin panel in the menu. Through here, you can open a new browser window. The admin username automatically sets to “root” after which you are prompted to provide a password. For now, you can leave the password field empty. You can also customize the MySQL databases or create new ones based on your preference. If you are using CMS software such as WordPress, they provide you with a database by default.
Step 5: Setting the Site to be Publicly Visible
At this stage, your website is accessible just to the computer in which you installed the WebServer application. This can be great if you want to use the Web Server for web development and testing practices. In this case, however, you want the rest of the world to see the contents of your site. To make it public, hit the WampServer icon and select the “Put Online” option.
Note that the Apache settings file is programmed to deny access to connections from outside which aren’t the localhost. People clicking on your URL will, therefore, receive a “403 Forbidden” message. To rectify this problem, you need to change some two lines of code within the Apache configuration file. Locate the httpd.conf file in the WampServer menu inside the Apache folder. Scroll down further till you come across a code shown below:
Order Deny, Allow Deny from all
Delete it then replace it with:
Order Allow, Deny Allow from all
Restart all the services in WebServer through the dedicated button in the menu, and your site will now be accessible to anyone from the internet. Make sure to change any PC firewall settings that block web requests. Also, forward the port 80 to your PC on your router.
How to Host your Website on a Linux Machine
Just like on the Windows OS, to host a website on a Linux machine, you need to install Apache, MySQL, and PHP. Rather than installing them separately, LAMP WebServer provides you with a package that carries all the three important web-hosting applications.
Step 1: install LAMP Software
AMP can be installed in any versions of the Linux OS. You should be able to set up the WebServer in the PC whether you prefer the command-line only Ubuntu or a standard Ubuntu desktop. To do that, enter the following simple line of command into the terminal:
sudo apt install apache2 mysql-server php libapache2-mod-php7.0
The installation process may take a while due to the download of large volumes of data contained in the package. In the next step, ensure that you set up a password for the MySQL root user then confirm it. Otherwise, if you leave the field empty, you won’t be able to change the password after the LAMP installation process. The password will also come in handy when you want to create other users or update your database.
Another important thing worth noting is that whenever you change the Apache configuration, you have to restart Apache by executing the command sudo /etc/init.d/apache2 restart. However, there is an exception when you carry out the process using the local .htaccess files.
Step 2: Test the PHP Operation
LAMP provides a test that can verify whether the PHP server is operational as well as check the available modules. To execute it, insert the test PHP file into the WebServer root directory, /var/www/html/. As an example, create a test PHP web page called “name” then enter the following code into the web server root directory:
sudo echo "" > /var/www/html/name.php
After that, go to your browser and type http://localhost/name.php then hit enter. When it loads, it should show you your test PHP file. The running PHP version, configuration, and available modules will be displayed on your window too. You can add new PHP modules later through the Ubuntu package manager in case you come across an application that requires it.
The graphical package manager contains the available modules. You can also access it through the command line by entering the following code: apt search php | grep module. I find the latter much simpler.
Step 3: Test MySQL and its Bind Address
At this stage, you need to confirm whether MySQL installation was successful. This is because CMS systems such as WordPress won’t run without it. Enter the following command to execute the test: service MySQL status. It should be running upon clicking enter, but if it doesn’t, restart the MySQL server through the following code: “sudo service mysql restart.”
Also, check whether the bind address of MySQL resembles that of your system. Do this by typing this simple command: cat /etc/hosts | grep localhost. Several results will show on your screen among which include your IP address. Open the MySQL configuration file and check whatever is listed there. Scroll until you see the bind address of your PC. The figures displayed on that line should match those you saw earlier. In case they do not match, change it to finish the test.
You can now use MySQL command line client as a tool for the management of your databases. The admin credentials you had set during the MySQL installation process will give you access to your server. You are now free to manipulate the MySQL environment and can create a database.
Most CMS usually create a database by default. However, you may need to do something extra like backup files or reconfigure tables. For that, you will need a database management tool. PHPMyAdmin is one of the most user-friendly tools used by experts for this job. It offers an interface for the MySQL administration which provides a soft landing spot for those who aren’t well conversant with MySQL and its commands. The next section shows you how to install PHPMyAdmin.
Step 4: PHPMyAdmin Installation Process
Type the command “sudo apt-get install phpmyadmin” to install it. If the installation fails, you will have to reconfigure other repositories before repeating the process. For instance, when you encounter a blue screen inquiring which web server you’d like to configure, press the space bar (the red cursor should be next to the “apache2”). When an asterisk appears, hit the enter button.
A new prompt comes to your monitor inquiring whether phpMyAdmin should create a default database for its exclusive use, click yes. Now you will need to enter your admin username and password to create the database. Restart the Apache to complete the process.
To log into phpMyAdmin, type the following address on your browser: http://localhost/phpmyadmin/. Enter the username and password in the fields provided then click go. It is important to note that the passwords you set for this entire process should be powerful because the web server software gives other people access to your PC.
Step 5: DNS Configuration
You may want to configure your local web server to have a personal domain name such as exmple.com. To accomplish this, you should change the Apache settings to accept requests from the internet. Below are the particular steps for configuring your DNS:
Make sure that your domain name of choice has an A record; it should point to a specific IP address. Your DNS records are updated automatically by your DNS hosting service provider. To check whether the configuration was successful, use the dig tool which will return details containing your IP address, domain name, and an authority section.
Step 6: Configuring of Apache
After downloading and installing the latest version of the LAMP server, Apache will be fully optimized to start hosting websites on your Linux PC. Here are the steps of a simple hosting configuration. They are specifically for name-based virtual hosts which you will use to support sites on your directory.
First, disable the Apache virtual host default by entering the command sudo a2dissite *default. Go to the default storage directory called /var/www/html by typing this command line: “cd /var/www/html”. Establish a new folder that will host your site. Make sure to change your domain name from exmple.com to your desired name. Use the command line: sudo mkdir desiredname.com.
Open the folder you just launched and create other four sub-folders or directories in it. These will serve the purpose of keeping your weblogs, files, and backups. Type this command:
sudo mkdir -p desiredname.com/public_html sudo mkdir -p desiredname.com/log sudo mkdir -p desiredname.com/backups
After that, open a new virtual host file for your site through this command:
sudo nano /etc/apache2/sites-available/desiredname.com.conf
Note that your domain name “desiredname.com” has been replaced by “desiredname.com.conf”.
At this stage, you now need to create a configuration for your virtual host. Use the block of code below to help you perform the procedure. You can copy paste it but remember to replace our arbitrary desiredname.com domain with your own as well as insert the error log command.
<virtualhost> ServerAdmin [email protected] Server_Name desiredname.com Server_Alias www.desiredname.com located) Directory_Index index.html index.php (this is the folder in which the files are saved) Document_Root /var/www/html/desiredname.com/public_html (contains the name of your php or htm file) LogLevel warn Custom_Log /var/www/html/desiredname.com/log/access.log combined </virtualhost>
To save these changes, press the control button + X followed by Y then Enter button to add the changes to the virtual host configuration file.
Finally, enable your site through this command: sudo a2ensite desiredname.com.conf. You will receive a prompt to restart Apache to apply your new settings. These simple steps will have prepared your Apache to hold your site. You can repeat the procedure for any other websites you would like to host on your LAMP server on your Linux PC.
What are the Advantages of Hosting a Website on your machine?
Hosting of websites through virtual hosting is a workable solution for most websites today. However, there are numerous reasons why you would want to shift to in-house hosting. Here are some of these factors:
It offers more control and flexibility
Once you host a website on your PC, you will be able to manage all its aspects from the web server installed on your PC. With virtually hosted servers, many permissions and constraints are tying you to use only what the web hosting service provider offers. In the case of technological changes or perhaps when you want to change your domain name, you have to contact the host provider. This hinders most web managers from making proactive decisions that would otherwise make their websites perform better.
Still, on flexibility, you can choose to offset some of your server expenditure by subletting space to small companies within your community, making you a small virtual server.
Note that cost can be both an advantage and a disadvantage. The good side of it is that you can host a website on most DSL connections. The only extra hardware needed is a switch and a web server. These equipment are readily available and can be found on second-hand terms for roughly $100. However if you already have a stable DSL connection, you need not spend on any additional connectivity infrastructure. A monthly saving of $10 will remit your capital in less than a year, allowing your in-house hosting to be self-sufficient. On the virtual hosting side, the expenditure increases as your website expands. That is attributed to the fact that you have to purchase more system admin services.
Learning of new skills
With in-house hosting, you can acquire new tricks and maneuvers for setting up your site. This allows you to effect changes promptly.
There may be no reputable web hosting companies within your geographical location. The use of different currencies and limited access to online payment methods may also deny you the chance of contracting a reliable web hosting company overseas.
The Cons of Hosting a Website on Your PC
In-house hosting has its downsides too. Here are the major ones:
Lack of access to additional services
Virtual web hosting providers usually have a robust infrastructure that offers more space and bandwidth. Additionally, they offer extra inventory for backup, security audit, load balancing, database management services and technical support. Most of these services are either too expensive or inaccessible through in-house hosting.
This is the most serious threat to in-house hosting. As soon as you install the web server software in your PC, you allow other internet users to access your computer. Consequently, using your work computer may expose you to hackers and automated malware that will either siphon or corrupt your data. With virtual hosting companies, this problem can be evaded. They usually provide software patches and robust firewalls to handle any security vulnerabilities on your web server. Therefore, it is important to perform an in-depth security audit before opting for either of these hosting services.
Your PC isn’t dedicated specifically to web hosting services; rather the web server software gives it the capability to perform the service. This means that you lack room for expansion in case your site’s traffic increases. More bandwidth, storage space, power, and cooling systems may be more of a far cry for in-house hosted sites.
Ability and Skills
Web hosting companies are endowed with trained personnel. You, on the other hand, may have just a little knowledge on setting up web servers. The hiring of staff or training yourself bring about additional costs that lower the feasibility of in-house hosting.
Internet service providers usually put restrictions on the amount of data that their subscribers can use. Web hosting requires a lot of bandwidth which may exceed the one provided by your ISP through broadband connections. Virtual hosting companies, on the other hand, have the necessary internet connectivity to fulfill the demands of their numerous clients. Also, note that when your PC is undergoing a software upgrade, and you need to restart it severally, your web server software will be going down with it too. In the case of power outages, you will also receive a down time.
To improve the reliability of your services, you may need to spend extra on equipment such as UPS, backup systems, software patch handling systems, and maintenance services among others. A web hosting company can avail all these services in any of their packages.
It is therefore evident that self-hosting your site still has some serious downsides. Therefore, choose it after considering all its downsides.
Once your site begins to expand, you may have to find alternatives to in-house hosting. I’ve outlined some of the best options in the following section.
Alternatives to Self-hosting a Website
There are different forms of web hosting other than in-house or self-hosting. Here, we’ll look at virtual hosting and dedicated hosting.
These are companies that host several sites on the same server. They are readily available and can offer services to simple websites for as little as $10 per month. Virtual hosting providers provide free backup, technical support, several email addresses and a user-friendly interface. They also provide a scalability advantage. At an extra fee, their packages may also come with e-commerce tools such as a shopping cart and customer loyalty programs.
Despite being cheap, they have downsides too. You have minimum or no control over the operation of the server on which you are hosted. This means that you have to rely on the activities of the host and their staff for any changes you’d like to implement.
Dedicated hosting companies allow you to have a server dedicated solely to your site. They can offer you either a network connectivity for the server you bought or a menu with an array of services like backup and monitoring. It is slightly expensive since you pay for space, bandwidth, and power consumed in the data center. At an extra cost, they will provide you with firewall management, engineering time, bandwidth statistics info, and technical support.
The primary advantage of dedicated hosting is that the processing power and speed are unlimited. They experience very little downtime as compared to VPS hosting.
Having learned how to host a website on your computer, you can decide which option is best for you. However, for serious projects requiring cutting-edge infrastructure, I would recommend that you opt for either dedicated or VPS hosting.
Latest posts by Jamie (see all)
- The Best Christmas Gifts For Nerds & Geeks Online – 2020 - December 2, 2020
- 106 Ways to Make Money Online & From The Comfort Of Your Own Home - November 23, 2020
- Cheap Domain Names – Where To Find Them And Buy Them! – 2020 Guide - October 20, 2020