Before diving deep into the process of web hosting on a computer, let’s first talk about what web hosting is. In short, the process through which your website is made visible to everyone via the World Wide Web is known as web hosting. If you are the one hosting a website, you will inevitably provide for all the necessary features and services required to host and run it smoothly.
Do remember, even though Web Hosting is easy, it still requires you to invest a lot. Good hosting means your website is fast and easy to access. Whereas bad hosting will be the exact opposite.
Like mentioned before, it is extremely easy to host a website. You either do it on your own from scratch or by using a content management system or you pay someone else to do it for you. How you choose to do it ultimately depends on how experienced you are. Those well versed in coding usually choose to build their website from scratch. But seeing many aren’t familiar with coding, it only makes sense hosting websites via content management systems. This is understandable as well. If you are not really familiar with the technical aspect of things, it is better to sign up with a hosting provider.
1# SELECT A WEB HOSTING SITE
Inevitably, the first step is to explore the various hosting sites and content management systems available. Compare them based on your technical needs and budget and decide which one is best for you. The hosting site will take care of everything related to the hosting of your website for you. They do this in exchange of a monthly fee. Most of these sites are cheap and efficient and will take care of every technical aspect of your website.
With this you can focus more on your website’s content and how you want to expand it. Once you choose a hosting site, choose the plan you can afford, then choose the domain name for your website. When choosing do keep in mind your hosting needs. Some important things to keep in mind while choosing a hosting site include, the support provided, possibility of WordPress integration and whether the domain name is available for free.
WEB HOSTING SITES
- A2 Hosting
and many more. Which hosting site you choose ultimately is up to you and your needs. On a side note, Blue Host is especially good when it comes to WordPress websites. Something to remember in case that is one of your priorities.
Now when choosing a plan, keep in mind, choose one that will fully suffice your needs. While some hosting sites are good in all aspects of hosting, some specialize in certain areas only. To be able to choose the correct size and plan, you need to go ensure you understand your needs and requirements well.
As mentioned above, after choosing a plan, it’s time to choose a domain name. Domain also referred to as your digital address, is the direct link through which people can find your website. In general, almost all web hosting sites will provide a domain name as part of their plans. The only thing that might differ is whether or not the domain name is for free. Sometimes it’s provided for free with the monthly pack you choose whilst other times it asks for an additional payment for the domain name.
While all this can be taken care of via any device, mobile or tablet, or a computer, many people prefer to host a website via a computer.
2# WEB HOSTING USING WINDOWS
While hosting a website on your computer, do remember it is better to opt for this if you wish to have a local development server. When hosting on Windows, you will need a WAMP server. A WAMP server is capable of installing three different applications at once, its full form being Windows, Apache, MySQL, and PHP.
A server like this will easily let you install all the necessary packages for hosting any content. It serves multiple purposes individually as well. Windows ensures that AMP is compatible with your device using Windows. On the other hand, Linux has LAMP. Moving on, Apache is the core program that will perform all your hosting-related services efficiently in HTML specifically. But if Apache manages hosting services, what about MySQL and PHP?
MySQL is your database that stores all your web content like passwords, emails, and more. On the other hand, PHP is a code language on which the majority of web pages run. For instance, Facebook.
To get a WAMP server on your computer supporting Windows, you have to follow a few simple steps.
Go to the WAMP server website and download the latest version available. This version will also come with the latest versions of Apache, MySQL, and PHP. Once you run the .exe file in this setup, it is a straightforward installation process from there. Moving on, choose the browser of your choice. Do remember, the farther you go on with the installation process, you are more likely to have certain Apache features rejected by the Windows firewall. Make an exception when you receive security alerts. When the installation process seems to end, select the box which will be labeled as Start WampServer 2 Now and then click the Finish button.
To change the pages shown, go to the www directory. You can do this directly by touching the WAMP icon. The www directory is created on its own during installation. To locate it, go to local disk C. Additionally, you can also create subdirectories. These are referred to as projects in the WAMP server. These help you store HTML and PHP data-based files. You can update changes by clicking the refresh button.
CREATING HTML AND PHP PAGES
If you are familiar with coding, open any web development program like notepad and create a simple HTML or PHP page. Save under any name with the extension .php. Now set c:\\wamp\\www as the final destination of the saved file. Return to the web server and refresh the page to update the changes you just made. To check whether this change is now saving the data in the www directory, go to http://localhost/name.php via your set browser. You should be able to see the details of the PHP you installed. This process lets you check whether or not your server is fully working.
Open the phpMyAdmin panel in your menu. From here you can directly configure MySQL databases. You will be asked to provide a password after opening a new browser window and setting the admin username to Root. Leave the password field empty and move on the customize your MySQL databases based on your preferences. Do remember, if you are using a content management system like WordPress, you will be provided by a database by default.
MAKE THE WEBSITE PUBLIC
Right now, only your computer has access to the website. Now, if this WebServer and website were meant just for test practices and development, it would be okay to leave it like this. But based on the context of this article and what you are probably looking for, the website and its contents need to be visible to everyone around the world. It’s a one-step process. Click on the WAMP server icon and select Put Online. But this is not where it ends. Apache is programmed to prohibit all connections outside localhost. Hence, anyone clicking the URL to your website will receive an error message. To solve this, look for the httpd.conf file in the WAMP server menu. It should be visible inside the Apache folder.
Following the necessary steps, restart all the services in Webserver. After this, your site will be visible to everyone.
3# WEB HOSTING USING A LINUX MACHINE
As mentioned in the previous section, the biggest change is Linux. Other than that, you will need to install Apache, MySQL, and PHP. Just like before, you don’t need to install it separately. LAMP WebServer will definitely provide you with a package that will install it all.
Set up the WebServer in the PC and install AMP in any version of Linux OS. Since it’s an entire package, the installation process might take longer since it’s a huge amount of data. During all of this, do remember to set up a password for the MySQL root users and confirm it. Why? Because if you don’t do that and leave the field empty, you can not change it later when LAMP is installed. The password is necessary for you to update the database or when you want to add more users.
One very useful feature provided by LAMP is the ability to test PHP operation and check the availability of modules. In the WebServer root directory, /var/www/html/, insert the test PHP file. Create a test PHP page, name it anything, for example, name, and enter the code in the WebServer root directory
sudo echo “” > /var/www/html/name.php
Now go to your browser and enter http://localhost/name.php and press Enter. If this displays your test PHP file along with the running version of PHP, configuration and available modules your PHP is working fine.
TEST MySQL AND BIND ADDRESS
After PHP you need to ensure MySQL was also successfully installed. For this, run the following command to test the function of MySQL: service MySQL status. If it’s working, it will run properly the moment you press Enter after typing in the command. If it doesn’t, restart the server using the code: sudo service mysql restart.
Now to check whether the bind-address resembles that of your system, type in the command:
cat /etc/hosts | grep localhost
Multiple results will appear and among these should be your IP address. Now in the MySQL configuration file scroll till you find the bind-address. Compare to see if it matches. If they don’t, change it to finish the test.
MySQL is now fit to be used as a tool to manage your databases. The set admin credentials will provide you access to your server. Do remember, majority of content management systems provide you with a database. However, if you still install MySQL, it can be used to backup files. For this, you are open to using tools like PHPMyAdmin.
To install it, type in the command:
sudo apt-get install phpmyadmin
In case the installation process fails, you can not directly repeat the process. You will have to reconfigure other repositories first. A new prompt will appear which will ask you to confirm PHPMyAdmin as the default database. Select yes. Enter Admin username, password, and following that restart Apache.
Now login by entering the following website on your browser:
Again, enter username and password and select GO.
Now if you want your local webserver to have a personal domain name, go to Apache settings to accept requests from the internet. To configure DNS, ensure your domain name of choice points towards a specific IP address. Since your DNS records are automatically updated, to check whether the configuration was successful, use the dig tool. It will return details like your domain name and IP address.
APACHE CONFIGURATION FOR WEB HOSTING
Once the latest version of the LAMP server is installed Apache will be automatically optimized to host websites on Linux OS. To configure, firstly disable Apache virtual host default by running the command:
sudo a2dissite *default
Now go to the storage directory by running the command:
Now make a new folder that will now run your site. Additionally, change the domain name to your desired name using the command:
sudo mkdir desiredname.com
Open the folder you just created and make four other subfolders to it and tun the command:
sudo mkdir -p desiredname.com/public_html
sudo mkdir -p desiredname.com/log
sudo mkdir -p desiredname.com/backups
Now using the following command open a new virtual host file for your site:
sudo nano /etc/apache2/sites-available/desiredname.com.conf
Use the below-mentioned block code to create a configuration for your virtual host.
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)
Custom_Log /var/www/html/desiredname.com/log/access.log combined
Save the changes with Ctrl+X then Y. Now press Enter to finish the process.
Now with the following command and after completing the follow-up steps you will be able to enable your site:
sudo a2ensite desiredname.com.conf
Hopefully, this guide was able to explain the process of web hosting via your computer in a simple and detailed way.