Many of you would be a web programmer. Some of you might be owing to a website and would certainly be editing and updating it frequently. While a few having no adequate knowledge of web technologies would still be planning to have one.
Through this article, I will make know how you could develop a working website with very little knowledge and could even host it using your Linux box. Things could be as simple as that.
Linux Box (However, You can use Windows but things surely won’t be as much simple and perfect as it will be on Linux Machine, Debian has been used here for example citing). If you don’t have an operating system installed, or you don’t know how to install a Linux operating system, then here are few guides that show you how to install a Linux operating system.
- How to Install a Debian 10 (Buster) Minimal Server
- How to Install Ubuntu 20.04 Server
- Installation of “CentOS 8.0″ with Screenshots
Apache, PHP, and MySQL (having a prompt knowledge of any other SQL, you can use it but examples in the article will be using MySQL.
- How to Install LAMP on Debian 10 Server
- How to Install LAMP Stack in Ubuntu 20.04
- How to Install LAMP Server on CentOS 8
Content Management Framework – Drupal with KompoZer, or you can use WordPress or Joomla.(But here I used Drupal as my Content Management System (CMS)).
Install WordPress on Linux
- How to Install WordPress Alongside LAMP on Debian 10
- How to Install WordPress with Apache in Ubuntu 20.04
- Install WordPress 5 with Apache, MariaDB 10, and PHP 7 on CentOS 8/7
Install Drupal on Linux
- How to Install Drupal on Debian 10
- How to Install Drupal on Ubuntu
- How to Install Drupal on CentOS 8
Install Joomla on Linux
- How to Install Joomla on Debian 10
- How to Install Joomla on Ubuntu
- How to Install Joomla on CentOS 8
Setting Up Own Webserver and Hosting A Website in Linux
An Internet Connection with Static IP (Preferred) connected through a modem having a virtual hosting facility (In Reality it is not as much complex as it sounds here).
What is Apache?
Apache is a web server program. It comes installed and configured on most of the Systems. Check if it is installed on your system or not.
# apt-cache policy apache2 (On Debian based OS)
apache2: Installed: (none) Candidate: 2.4.38-3+deb10u3 Version table: 2.4.38-3+deb10u3 500 500 http://httpredir.debian.org/debian buster/main amd64 Packages 2.4.38-3 -1 100 /var/lib/dpkg/status 2.4.25-3+deb9u9 500 500 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
# yum search httpd (On Red Hat based OS)
Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile * base: ftp.iitm.ac.in * epel: mirror.smartmedia.net.id * extras: ftp.iitm.ac.in * updates: ftp.iitm.ac.in Installed Packages httpd.i686 2.2.15-28.el6.centos @updates
From the above output, it is clear that Apache is installed on the box, if it is not in your case you can ‘apt‘ or ‘yum‘ the required package. Once the Apache is installed start it as.
# apt-get install apache2 (On Debian based OS) # service apache2 start
# yum install httpd (On Red Hat based OS) # service httpd start
Note: You might have to type ‘httpd‘ and not ‘apache‘ on some server Viz., RHEL. Once the ‘apache2‘ or ‘http‘ aka ‘httpd‘ server is started you could check it in your browser by going to any of the following links.
http://127.0.0.1 http://localhost http://your-ip-address
This link will open into a hosted page which means Apache has been successfully installed and started.
What is MySQL?
MySQL is a database server program. It comes packed with a number of distros. Check if it installed on your system or not and where it is installed.
# whereis mysql
mysql: /usr/bin/mysql /etc/mysql /usr/lib/mysql /usr/bin/X11/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
From the above output, it is clear that MySQL is installed along with the location of binary files. If in case it’s not installed, do ‘apt‘ or ‘yum‘ to install it and start it.
# apt-get install mariadb-server mariadb-client (On Debian based OS) # service mysql start
# yum install mariadb-server mariadb-client (On Red Hat based OS) # service mariadb start
Note: You might have to type “mysqld” in place of mysql, obviously without quotes, in some distro viz., RHEL. Check the status of MySQL, run.
# service mysql status (On Debian based OS)
● mariadb.service - MariaDB 10.3.23 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2020-01-08 01:05:32 EST; 1min 42s ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Process: 2540 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS) Process: 2537 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) Process: 2457 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSREP_STAR Process: 2452 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) Process: 2450 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS) Main PID: 2506 (mysqld) Status: "Taking your SQL requests now..." Tasks: 30 (limit: 4915) CGroup: /system.slice/mariadb.service └─2506 /usr/sbin/mysqld
The above output shows that MySQL is running for 11 min 58 sec.
What is PHP?
PHP is the server-side scripting language designed for web development and is commonly used as a general-purpose programming language. You have to just deploy the php script after installing php. As I said above use ‘apt‘ or ‘yum‘ to install the required package for your box.
# apt-get install php php-mysql (On Debian based OS)
# yum install php php-mysqlnd (On Red Hat based OS)
If you successfully installed the php in your system, you could check if it is working correctly or not by creating a file “info.php” in your ‘/var/www/html‘ or ‘/var/www‘ directory (which is your Apache directory) with the content given below.
<?php phpinfo (); ?>
Now navigate to your browser and type any of the following link.
http://127.0.0.1/info.php http://localhost/info.php http://your-ip-address/info.php
Which means php is installed and working correctly. Now you can build your website in your Apache directory, however, it is not always a good idea to reinvent a wheel again and again.
For this, there exists the Content Management Framework (CMF), viz., Drupal, Joomla, WordPress. You could download the latest framework from the link provided below and can use any of these frameworks, however, we will be using Drupal in our examples.
- Drupal: https://drupal.org/project/drupal
- Joomla: http://www.joomla.org/download.html
- WordPress: http://wordpress.org/download/
Download Drupal from the above link which would be a tar archive. Move the tar archive to your Apache directory ‘/var/www/html‘ or ‘/var/www‘. Extract it to the root of the apache directory. Where ‘x.xx‘ would be version number.
# mv drupal-x.xx.tar.gz /var/www/ (mv to Apache root directory) # cd /var/www/ (change working directory) # tar -zxvf drupal-7.22.tar.gz (extract the archieve) # cd drupal-7.22 (Move to the extracted folder) # cp * -R /var/www/ (Copy the extracted archieve to apache directory)
If everything goes OK, again open your browser and navigate to the below links and you will be greeted with.
http://127.0.0.1 http://localhost http://your-ip-address
Choose Your language settings.
Checking for requirements and file permission. Provide proper permission to the required files and folders. You may need to create certain files manually, which is not a big deal.
Setup Database, the backend process.
If the Database setting goes perfect profiles are installed automatically.
Configuring means setting ‘Site Name‘, ‘Email‘, ‘User Name‘, ‘Password‘, ‘Time Zone‘, etc.
And if everything goes smoothly, you will get a screen something like this.
Open Your page by referring to the address http://127.0.0.1.
What is Kompozer?
Kompozer is a tool that lets you work in GUI for designing a website in html and you can insert a php script anywhere you want. Kompozer made it too easy to create a web page.
- Kompozer: http://www.kompozer.net/download.php
well you don’t need to install it on most of the Linux system. Just download, extract, and run Kompozer.
If are creative, kompozer is right there for you.
What is IP?
A Few Words about Internet Protocol (IP) Addresses.
It is generally called loopback IP address or localhost, and it always points to the machine on which it is browsed. All the machines on a network referring to the above address will loop back to its own machine.
Ipconfig/ifconfig: Run this in your terminal to know your machine local address.
eth0 Link encap:Ethernet HWaddr **:**:**:**:**:** inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: ****::****:****:****:****/** Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:107991 errors:0 dropped:0 overruns:0 frame:0 TX packets:95076 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:76328395 (72.7 MiB) TX bytes:20797849 (19.8 MiB) Interrupt:20 Memory:f7100000-f7120000
Search for the inet addr:192.168.1.2 here 192.168.1.2 is my local IP. Any computer on your LAN including you could refer to your hosted web page using this address.
However a computer outside of your LAN won’t be able to access your web page using this IP address. You will have to ask your Internet service provider to provide you with a static IP (That doesn’t change with time). Once you got your static IP address, the easiest way to find your IP is to type “My IP is” at google and note-down the result.
You won’t be able to access this IP from your own machine nor any other machine on your LAN. However, you can use a proxy server (www.kproxy.com) to access your hosted page using your static IP. But before that, you need to set up a virtual server and your service provider will surely be helpful in this regard.
How to Setup Virtual Server
Hmmm! That’s not difficult at all. First, you need to know the port apache is using, which in most of the case is 80.
# netstat -tulpn
the output would be something like:
tcp6 0 0 :::80 :::* LISTEN 6169/apache2
Now go to your router which generally is http://192.168.1.1 and the user name/password would be admin-admin, however, it could be different in your case based on service provider and area.
Next, go to the Virtual server tab. Fill the port number, service name, and local IP address, inform, and save. Ask for assistance from your ISP.
Remember You will only be able to access this webserver from your machine, any other machine on your LAN, or a computer on the Internet when your machine is UP and running MySQL and Apache simultaneously.
With great power, comes a big responsibility. And now it’s your responsibility to safeguard your machine. Never give your IP address to any unknown person till you know your ways in and out.
We surely will try to cover the issues related to security and how to safeguard it. Feel free to give your valuable comments and share them with your friends. You know ‘Sharing is Caring‘. Your Positive comment encourages and motivates us.