Creating Your
Webserver and Hosting A Website from Your Linux Box
Many of you would be web programmer. Some of you might be owing
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 a very little knowledge and could even host it using your Linux box. Things could be as simple as
that.
Requirements:
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 shows you how to install a operating system.
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.
Content Management Framework – Drupal with KompoZer, or
you can use WordPress orJoomla.(But
here I used Drupal as my Content Management System (CMS)).
An Internet Connection with
static IP (Preferred) connected through a modem
having 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 System. Check if it is installed on your system or not.
# apt-cache policy apache2 (On Debian based OS)
Sample Output
apache2:
Installed: 2.2.22-13
Candidate: 2.2.22-13
Version table:
*** 2.2.22-13 0
500 http://ftp.iitm.ac.in/debian/ wheezy/main i386 Packages
500 http://ftp.debian.org/debian/ wheezy/main i386 Packages
100 /var/lib/dpkg/status
# yum search httpd (On Red Hat based OS)
Sample Output
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 following
link.
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
Sample Output
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 mysql mysql-server mysql-client (On Debian based OS)
# service mysql start
# yum install mysql mysql-server mysql-client (On Red Hat based OS)
# service mysqld 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)
Sample Output
[info] /usr/bin/mysqladmin Ver 8.42 Distrib 5.5.31, for debian-linux-gnu on i686
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Server version 5.5.31-0+wheezy1
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/run/mysqld/mysqld.sock
Uptime: 11 min 58 sec
Threads: 1 Questions: 106 Slow queries: 0 Opens: 467 Flush tables: 1 Open tables: 115 Queries per second avg: 0.147.
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 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 php5 libapache2-mod-auth-mysql php5-mysql (On Debian based OS)
# yum install php php-mysql (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 yourApache directory, however it is not always a
good idea to reinvent a wheel again and again. For this, there exists 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 framework, however we will be using Drupal in our examples.
o
Drupal : https://drupal.org/project/drupal
o
Joomla: http://www.joomla.org/download.html
o
WordPress: http://wordpress.org/download/
No comments:
Post a Comment