This tutorial will help you learn how to create a free web host using a web server or a virtual computer. Overall, based on your skill-level and internet speed, setting up a Ubuntu web host server should take you no longer than 30 minutes.
Updating the Server
First, you must log in to the server (you may use SSH). Then, you should check to see if your system is up to date. To do so, enter the following: (Note: This method is for apt systems only.)
1 2 |
sudo apt-get update sudo apt-get upgrade |
sudo apt-get update sudo apt-get upgrade
The previous commands will update the server repository list as well as upgrade your server with the latest updates.
Once complete, you should restart the server. To do this enter:
1 |
sudo reboot |
sudo reboot
Now that the server has rebooted, let’s begin to start up your web host.
Installing Apache
First you will need to know that you will have to install a few services (or daemons). The first service you will install is Apache2 (also known as HTTPd). This is the backbone behind HTML and all web hosting servers. The current version for HTTPd is 2.2.17, but the latest version for Ubuntu is 2.2.16.
To install Apache2 or HTTPd on your server, enter the following line:
1 |
sudo apt-get install apache2
|
sudo apt-get install apache2
Changing Owners & Path
Now your server is getting the HTTPd you need to know that your site’s folder will be in /var/www by default. If you’re going to add files to it you will need to change the user it is owned by, this next command will help you to fix the folder’s owner (or user:group):
1 2 3 |
sudo chown user:group /var sudo chown user:group /var/www sudo chown user:group /var/www/index.html |
sudo chown user:group /var sudo chown user:group /var/www sudo chown user:group /var/www/index.html
This will change the path to www to your user and group. So lets say my user and group on my server is test1, It would look something like this:
1 2 3 |
sudo chown test1:test1 /var sudo chown test1:test1 /var/www sudo chown test1:test1 /var/www/index.html |
sudo chown test1:test1 /var sudo chown test1:test1 /var/www sudo chown test1:test1 /var/www/index.html
FTPd
Now since you have set up /var/www to let you mod the folder and index.html, to delete it or edit it we need to get you an FTP service. The one I use is Pure-FTPd. Its a simple and easy to use FTPd service.
To get it, you would have to type the following command:
1 |
sudo apt-get install pure-ftpd |
sudo apt-get install pure-ftpd
PHP & MySQL
Now that it’s set up, let’s get PHP5 and MySQL set up on your server.
Just a few notes to know the PHP5 ver that is out on Ubuntu is 5.3.3. Don’t worry this will work just fine for sites and will work on all browsers. MySQL ver is 5.1.49
First what we will do is get MySQL set up for PHP5. For this the command will be:
1 |
sudo apt-get install mysql-server |
sudo apt-get install mysql-server
Now you might notice your putting in server not client. It’s because your going to host your own MySQL server for both easy use and it will consume only a fraction of your bandwidth.
Once it’s done downloading, you will see that you need to put in a password for the user ROOT. Add your own personal pass and make it complex as you can for protection.
Now let’s get PHP5 installed on your web server
As said before the current PHP5 System that is set up on Ubuntu for download is PHP 5.3.3 and there is no problem with it as it’s stable to use so we will use it. Type the following command to get it:
1 |
sudo apt-get install php5 libapache2-mod-php5 |
sudo apt-get install php5 libapache2-mod-php5
Testing PHP
Now once the server is done with installing the PHP5 system. The server will restart the Apache2 to get PHP5 going. To test and see if PHP is working on your server, you can make a simple file:
1 |
<?php phpinfo(); ?> |
<?php phpinfo(); ?>
This will show all the info for PHP Apache2 and MySQL at the same time. Now you can save the file as phpinfo.php or have it any other name you want it to be.
MySQL Admin Controls
Time for a MySQL admin control system for your MySQL server. For this we can use either phpMyAdmin or SQLBuddy. Now phpMyAdmin can be gotten by downloading it to your server with this command:
1 |
sudo apt-get install phpmyadmin
|
sudo apt-get install phpmyadmin
That will get you phpMyAdmin on your system and the url will look something like this:
1 |
http://example.com/phpmyadmin |
http://example.com/phpmyadmin
Now if you want to use SQLBuddy instead of phpMyAdmin you would need to go to SQLBuddy’s homepage and download the .zip file. You will need to un-zip it on your computer and upload via ftp to /var/www and your url should look something like this:
1 |
http://example.com/sqlbuddy |
http://example.com/sqlbuddy
Now you can change the folder to anything you want it to be, but for this document we will leave it as /sqlbuddy
Conclusion
There you go. You now got your own web-host running on your own. Just a note: SSL connection is NOT enabled by default so you would have to enable it by doing a few commands and they are:
1 2 3 4 |
sudo a2enmod ssl sudo /etc/init.d/apache2 restart sudo a2ensite default-ssl sudo /etc/init.d/apache2 reload |
sudo a2enmod ssl sudo /etc/init.d/apache2 restart sudo a2ensite default-ssl sudo /etc/init.d/apache2 reload
Now this is a self assigned cert. What that means your browser will not trust the site unless you say it’s ok and the URL will look like this:
1 |
https://example.com/ |
https://example.com/
Read the original article by clicking here.












