How to Web Host Your Own Website Using Linux?

Knowing how to web host your own website using Linux may sound appealing to those who want their web server set up from scratch. In fact, that is the better choice, because this lightweight operating system easily adapts to nearly every need.

But Linux is not only for easy adaptation, knowing how to web host your own website is an advantage to those who want to cut costs in hardware and set up expenses. The only thing you need is excellent IT management in order to ensure that all programs are working properly and that how to web host your own website will be an opportunity for customization rather than a means of problem. Make sure that your web server won’t allow unacceptable downtime leading to revenue loss.

Web Host Your Own Website

Learning how to web host your own website became popular to business people who have the capacity to tinker on technology to their advantage. Such is the case of knowing how to web host your own website using the most common desktop environment.

Linux requires almost the same procedure when you try to learn how to web host your own website in Windows. There are certain differences though, and these include the use of a LAMP instead of a WAMP bundle, for the simple reason that it is Linux. Getting a LAMP will kickstart your quest on learning how to web host your own website. The bundle is still composed of the same Apache, MySQL and PHP.

Learning how to web host your own website may sound difficult for non-geeks, but this will surely bring the data control, customization and cost cut that you want. So, here are the steps on how to web host your own website in Linux:

1.         To retrieve the bundle, open up the terminal. The terminal will always be the start of every stage on how to web host your own website.

2.         Enter the following line: sudo apt install apache2 mysql-server php libapache2-mod-php7.0

3.         As you install the stack, use “root” as your username when prompted.

4.         Then, set a password of leave it blank. After completing the installation, restart the Apache web server. Note that you’ll need to do this any time you change the global configuration of Apache unless you do it using the local .htaccess files.

5.         Restart  by entering the command: sudo /etc/init.d/apache2 restart

6.         Check PHP as how we do in Windows to confirm if the PHP server works properly before proceeding to the next step. To do that, place a test file into the www folder which can be found at  “/var/www/html/”.

7.         Create a file with the following line and place it in the directory: sudo echo “” > /var/www/html/info.php

8.         Go to “http://localhost/info.php” and check if the page loads. It should show the PHP version, current configuration and installed modules there.

9.         Configure MySQL by opening the terminal, then entering the following line: service mysql status

10.       Check if the result would appear as this: $ service mysql status

 mysql.service – MySQL Community Server

[…]

mrt 15 16:02:14 host1 systemd[1]: Started MySQL Community Server.

11.       In some cases, the server isn’t working. If ever that happens, type in “sudo service mysql restart” to restart the MySQL server. It should work by then.

12.       Then, use the MySQL command line client to manage your databases. You just need to recall the credentials you entered when MySQL was installed and enter the following:

$ mysql -u root -p

13.       If you’re using CMS, it will install the database for you, though there are some things you can do manually like creating a backup of your databases. You can also find a more user-friendly way to do that by installing PHPMyAdmin, a database management tool circumventing the lines of code to manage your databases. Just enter the following line: sudo apt install phpmyadmin

14.       Configure Apache to allow it to accept incoming requests from the domain name in your DNS records. In case you need assistance in setting these records, contact your DNS hosting provider to provide you an online tool to configure them.

15.       To set up the directory for your domain, enter the following lines in the terminal:

sudo mkdir -p /var/www/html/example.com

sudo sh -c ‘echo “<title>example.com</title><h1>This is my self-hosted site example.com</h1>” > /var/www/html/example.com/index.html

sudo chmod -R 755 /var/www/html/example.com

16.       To set up a Virtual Host file for Apache in order to see the page, enter the following lines:

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf

And

sudo nano /etc/apache2/sites-available/example.com.conf

17.       Then, edit the Apache file to match this:

ServerAdmin admin@example.com

ServerName example.com

ServerAlias www.example.com

DocumentRoot /var/www/html/example.com

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined

18.       Reload Apache for these changes to take effect. Enter the following:

sudo a2ensite example.com.conf

sudo service apache2 reload

19.       Lastly, add your IP address and domain name to your machines hosts file to match it locally.

However, you choose to learn how to web host your own website, or what OS you will use, the only thing that matters is how convenient this will be for you as compared to simply paying for web hosting. So, how to web host your own website? Take courage in starting from scratch, learn, and enjoy the perks of your very own web server at home.

How to Host Your Own Website and Domain

Contact

601 Pittsburgh Avenue P.O. Box 1167
Mount Vernon, Ohio 43050

Sales: (740) 652-3780
Support: (301) 331-7774

Sales: info@nfolink.net
Support: itacw@nfolink.net

Send us a message