LinuxAndUbuntu - Linux News | Apps Reviews | Linux Tutorials HowTo
  • Home
    • Linux >
      • Ubuntu
      • Linux Mint
      • Fedora
      • Arch Linux
      • Open Suse
      • Other Linux Distros
  • Linux Store
  • Video Tutorials
  • Linux Themes
  • FAQs
  • Advertise
  • Contact Us
  • Donate
  • Block Adblock
  • Favorites
  • Ubuntu Releases
  • Linux Mint Releases

How To Setup A Web Server And Host Website On Your Own Linux Computer

30/6/2016

Comments

 
how to setup a web server
Welcome to small tutorial series of hosting website on Linux machine. This series of articles will teach how to setup a web server on Linux computer and make it available online. The website we'll host on our personal computer can be accessed from around the globe. In this article(Part 1), we are going to install all the required tools to setup web server. So let's get started and start our own setup web server. ​
The Linux distro we'll be using for this setup is Ubuntu OS. However, this can be implemented in any linux distro. At the end of this tutorial you will be able to host your php and mySQL based website on your own Linux machine. The tutorial is divided into two parts. In first part, we discuss about basic components and their installation part. In next section, we shall write sample php code for basic website and host it under apache2 web server.

How To Setup Linux Web Server And Host Website On Your Own Computer [Part - 2]

Prerequisites To Setup Web Server

To setup web server on your own Linux computer, we'll require the following three components to be installed -
  • Apache2 : apache2 is open-source HTTP server. It is still most popular web-server used worldwide today.
  • php and php sqlite component: PHP is server side scripting language. PHP and its component will help you to interact with backend mySQL database for your website.
  • mySQL: mySQL is database solution in which you shall be storing your data in table.
If you have installed the above components, you can skip this part and move to the next part here( add link here).

​How To Setup A Web Server

Install Apache2

Apache is open source web-server software that powers much of the web today. It is maintained by apache-http-project. Explore more here :https://httpd.apache.org/
​

Open your terminal and type in commands -
sudo apt-get update

sudo apt-get install apache2
setup web server apache running
To check if apache2 is installed properly -
sudo service apache2 restart
Open your web-browser and open link using ip--address of your server. If you are practicing locally, you can type in localhost or 127.0.0.1.

By default, apache runs on port 80 and hence you need not provide the port number in your browser.
127.0.0.1

Or ip-address of your server. For example

198.162.12.52
It should show message like it works!


To change port address, you need to edit the configuration file at /etc/apache2/ports.conf  and change the Listen 80 to your desired port number. After edit you need to restart the apache2 server.
edit apache2 port 80
​To restart apache2 web server -​​
sudo service apache2 restart

Install mySQL

mySQL is the database management solution that helps you to store and retrieve data in tables.
Since in this tutorial we shall be using php, we will also need to install php5-mysql component.
sudo apt-get install mysql-server php5-mysql
To check if mySQL is installed properly, open mysql on terminal with command -
mysql -uroot
If you set the password during installation open with -p parameter -
mysql -uroot -p
setup mysql for setup web server

Install PHP

PHP is open source web server scripting language. It is back-end scripting language that will help you to interact with the mySQL database. For example, if you want to show the tabular employee list stored in your mySQL database in your website, with the help of PHP you can interact with mySQL, retrieve the employee list and render in html page. Php5-mysql library helps you in this regard. PHP provides multiple auxiliary libraries for different needs. Php5-mysql is one among them and we shall use that in our tutorial.
​

To search the libraries that are available.
apt-cache search php5-
search libraries php5
To install PHP and php5-mysql
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

sudo apt-get install php5-sqlite
setup php5-sqlite website
To check if php is installed correctly, make file /var/www/html/info.php and add the following content to this file -

​
<?php
phpinfo();
?>

create php file in /var/www/html

Restart apache2
sudo service apache2 restart
​Open web browser and navigate to
127.0.0.1/info.php


If you are using remote server replace ip with server’s ip address.


Upon success, you should see following webpage -
web server running successfully
Well that’s it, you are ready with the basic setup required for this tutorial. In next section we code sample webpage in php that would store and retrieve the information in mySQL table. Then we host it under apache2. If you like this tutorial, share ittutorial with your friends and let them set up their own web server. We'll publish the next part very soon so keep visiting. Thank you! 

​How To Setup Linux Web Server And Host Website On Your Own Computer [Part - 2]


Related articles
Comments
comments powered by Disqus

    Most Read Articles

    5 Lightweight Linux For Old Computers
    20 Best Themes For Ubuntu In 2017

    8 Best IDEs Or Code Editors For Linux
    8 Best IDEs Or Code Editors For Linux

    3 best twitter clients for linux
    [How To] Install Latest NVIDIA Drivers In Linux

    Ubuntu Vs. Linux Mint - Which Is Better in 2016?
    5 Lightweight Linux For Old Computers

    dual boot ubuntu and windows
    10 Basic Linux Commands That Every Linux Newbies Should Remember

    dual boot ubuntu and windows
    6 Best Linux Distributions For Programming


    Translate Our Site





    Notice : Please be careful, after translation commands will change.

About LinuxAndUbuntu

​​LinuxAndUbuntu.com  focuses on open source projects but  specific on debian based distributions. We also give value to other linux distributions.

Links

Ubuntu.com
Video Tutorials
Tutorials & HowTos
Privacy Policy
Contact us

Like Us

More From LinuxAndUbuntu

Contribute  Your Work
Advertise
Donate Us

RSS Feed

Picture
Ubuntu is a registered trademark of  Canonical Ltd.

Any material in this site can not be reproduced without permission.
  • Home
    • Linux >
      • Ubuntu
      • Linux Mint
      • Fedora
      • Arch Linux
      • Open Suse
      • Other Linux Distros
  • Linux Store
  • Video Tutorials
  • Linux Themes
  • FAQs
  • Advertise
  • Contact Us
  • Donate
  • Block Adblock
  • Favorites
  • Ubuntu Releases
  • Linux Mint Releases
✕