Have you ever thought of maintaining your websites with your own web server? So why not Apache, see how to install and configure Apache Web Server. It is used widely for the purpose of running various servers, especially in Ubuntu, as it is pretty much cost effective as compared to using it with any web hosting provider services.
Apache is an open source web server based on HTTPD, here the suffix “D” with HyperText Transfer Protocol stands for Daemon. The HTTP Daemon, as the name suggests, runs in the background, and it is with HTTP that enables to operate a web server and handle requests. There are several benefits of using your own web server, some of them are as follows:
- Handling your own web server is much easier to maintain, as changes can only be done by you.
- It’s free to use, not including the charges of an additional software, internet charges or electricity bill. I think, it does not matter, if you have decided to run your own server.
- You can use the server for various purposes such as email and media server.
- You can configure and customize it according to your suitability.
Previously Apache was designed to run the server in Linux based systems only, but later on, it got modified for Unix, Solaris, Windows and many others Operating System. As Ubuntu is one of the trendy distribution of Linux operating system, so many people prefer to setup web server in this system.
Steps to Install and Configure Apache Web Server in Ubuntu
Step 1: To install Apache using the Terminal, open up the Terminal using “Ctrl + Alt + T”. Then write the following command: “sudo apt-get install apache2” and press enter.
Step 2: Enter the password of your Ubuntu Machine, and after this, you may see a statement that an “additional space is required”, to proceed further write “y” to say yes.
Step 3: It will take few minutes to complete the Installation process. When completed, look for the default “ServerName” for the Apache.
Step 4: Type the IP address in the range of the “ServerName” of Apache, i.e., 127.0.1.1 on any Web Browser. I have done the same, look at the default page of “Apache”, from which you”ll get assured that it is successfully installed on the system OR simply type localhost.
The output of it will be visible to you. Some information is also available on the page, notice one thing that the default file, i.e., index.html resides in the folder as highlighted.
Step 5: So let’s check it once, Type ‘ls’ followed by the directory name, each separated by forward slash i.e. “ls /var/www/html” and press enter.
“/var/www” is the folder where web servers reside in Linux system (Ubuntu). All the web traffic comes on port number 80 which is assigned to “www”.
Step 6: Result of the above command will be on your screen, it’s “index.html”, a default page to access your web page. You can change it by the domain name of your site.
Step 7: Suppose you want to edit the content of this page, you have to open it by using nano, gedit or vim editor, whichever suits you.
For the time being, open it using nano: write “sudo nano /var/www/html/index.html” then press enter.
Step 8: According to the version of your Ubuntu and Apache server, the default page may differ. You can perform the changes as required. Just for testing, change the Title of the page to “Ubuntu14 Homepage” then press ctrl +X to exit, then you will be asked to Save changes or not, type “y” for yes.
Step 9: When done with the changes, look for it, by refreshing the Web Page. Here, in the figure you can see that the “Title” of the page is changed.
Step 10: Now, if you wish to stop the web server, type “sudo /etc/init.d/apache2 stop” and press enter. This command will stop the Apache server, in the same way, you can write “restart” or “start”.
The restart will force the server to check for the changes made into the library of Apache. Whereas start is used to simply start the server if you have freshly logged in to the system. Here, you may notice that the directory “/etc/init.d” is accessed as it contains the script regarding when to start, stop and restart a particular service. You might have heard about “init”, it is the first program that initiates when the kernel has completed the entire initializing process.
Leave a Reply