- Web Server Guides for Linux Beginners
- LAMP Installation Guides
- LEMP Installation Guides
- Apache Web Server Hardening and Security
- Apache Web Server Tips & Tricks
- Nginx Web Server Hardening and Security
- Nginx Web Server Tips & Tricks
- Hosting Websites with Web Server
- How to Host a Website on NGINX Web Server
- Install NGINX Web Server in Linux
- Host a Simple HTML Website on NGINX
- My website is live on NGINX!
- Manage NGINX Web Server in Linux
- How to Host a Website on an Apache Web Server
- Install Apache Web Server in Linux
- Host a Simple HTML Website on Apache
- Linux Shell Tips
- Manage Apache Web Server in Linux
Web Server Guides for Linux Beginners
This page covers everything about web server software installation and common configuration setups such as the LAMP (Linux, Apache, MySQL and PHP) and LEMP (Nginx, Apache, MySQL and PHP) environments in Linux server.
LAMP Installation Guides
LEMP Installation Guides
Apache Web Server Hardening and Security
- 5 Tips to Boost the Performance of Your Apache Web Server
- 13 Apache Web Server Security and Hardening Tips
- Install Varnish Cache to Boost Apache Performance on CentOS 7
- 25 Useful Apache ‘.htaccess’ Tricks to Secure and Customize Websites
- How to Change Apache HTTP Port in Linux
- How to Monitor Apache Performance using Netdata on CentOS 7
- How to Hide Apache Version Number and Other Sensitive Info
- How to Secure Apache with Free Let’s Encrypt SSL Certificate on Ubuntu and Debian
- How to Install Let’s Encrypt SSL Certificate to Secure Apache on CentOS 7
- How to Create Apache Virtual Hosts with Enable/Disable Options in CentOS 7
- How to Setup Standalone Apache Server with Name-Based Virtual Hosting with SSL Certificate
- How to Password Protect Web Directories in Apache Using .htaccess File
- How to Monitor Apache Web Server Load and Page Statistics
- How to Change Apache Server Name to Anything in Server Headers
- How to Redirect HTTP to HTTPS on Apache
- How to Change Default Apache ‘DocumentRoot’ Directory in Linux
- How to Secure Apache with SSL and Let’s Encrypt in FreeBSD
Apache Web Server Tips & Tricks
- How to Check Which Apache Modules are Enabled/Loaded in Linux
- Apache Virtual Hosting: IP Based and Name Based Virtual Hosts
- 3 Ways to Check Apache Server Status and Uptime in Linux
- Find Top 10 IP Addresses Accessing Your Apache Web Server
- How to Configure, Manage and Monitor “Apache Web Server” Using “Apache GUI” Tool
- How to Install Mod_GeoIP for Apache in RHEL and CentOS
- How to Sync Two Apache Web Servers/Websites Using Rsync
- lnav – Watch and Analyze Apache Logs from a Linux Terminal
- How to Limit User File Upload Size in Apache
- Redirect a Website URL from One Server to Different Server in Apache
- GoAccess – A Real Time Apache Web Server Log Analyzer
- 25 Apache Interview Questions for Beginners and Intermediates
Nginx Web Server Hardening and Security
- The Ultimate Guide to Secure, Harden and Improve Performance of Nginx Web Server
- Learn How to Speed Up Websites Using Nginx and Gzip Module
- Install Nginx with Ngx_Pagespeed (Speed Optimization) on Debian and Ubuntu
- Install Varnish Cache Improve Nginx Performance on Debian and Ubuntu
- Setup HTTPS with Let’s Encrypt SSL Certificate For Nginx on CentOS
- Secure Nginx with Free Let’s Encrypt SSL Certificate on Ubuntu
- How to Secure Nginx with SSL and Let’s Encrypt in FreeBSD
- Setting Up High-Performance ‘HHVM’ and Nginx/Apache with MariaDB on Debian/Ubuntu
- How to Change Nginx Port in Linux
- How to Hide Nginx Server Version in Linux
- How to Monitor Nginx Performance Using Netdata on CentOS 7
Nginx Web Server Tips & Tricks
Hosting Websites with Web Server
How to Host a Website on NGINX Web Server
NGINX (pronounced as Engine-X) is a free and open-source web server software, load balancer, and reverse proxy optimized for very high performance and stability. NGINX offers low memory usage and high concurrency — which is why it is the preferred web server for powering high-traffic websites.
In this tutorial, you will learn how to install an NGINX webserver to host a simple HTML website running on a Linux platform.
Install NGINX Web Server in Linux
On Ubuntu and Debian-based distributions, run the command below to install NGINX.
On Red Hat Linux and related distributions, you might need to first add the EPEL repository with the command below.
$ sudo yum install epel-release
Next, update the repository with:
Now, you may run the following command to install NGINX on Red Hat and related distributions.
Once installed, you can start and check the status of NGINX as follows.
$ sudo systemctl start nginx $ sudo systemctl status nginx
After you have successfully installed NGINX and confirmed that it is running, open a web browser and enter the IP address of your Linux server.
http://IP-Addresss OR http://localhost
You should see the test page for NGINX as shown in the images below.
Host a Simple HTML Website on NGINX
On Ubuntu and Debian-related distributions, the default website root is /var/www/html and this is where you should put your website content.
Change into the default website root with:
As for Red Hat, as indicated on the NGINX test page, the default website root is /usr/share/nginx/html and this is where you should put your website content.
Go into the default website root with:
Once you are in the default website root, run the command below to rename any existing index.html file.
$ sudo mv index.html index.html.bk
Note: On Ubuntu, you may get a message saying that the file does not exist. It’s okay to move on to the next step.
Now, run the following command to create your own index.html file.
Copy and paste the sample HTML code below into the text editor.
My website is live on NGINX!
Hello World!
Save and close the index.html file.
Finally, refresh your web browser to see your new website.
Manage NGINX Web Server in Linux
Here are some additional commands for the basic management of your NGINX web server.
To configure NGINX to automatically start when the Linux server is rebooted, run:
$ sudo systemctl enable nginx
To disable automatic starting of NGINX when the Linux server is rebooted, run:
$ sudo systemctl disable nginx
To restart NGINX, run:
$ sudo systemctl restart nginx
To reload NGINX configuration settings without restarting the service, run:
$ sudo systemctl reload nginx
To stop NGINX, run:
$ sudo systemctl stop nginx
Conclusion
In this guide, you have learned how to install NGINX on Ubuntu/Debian as well as Red Hat Linux distributions. We also showed you how to add your own website content.
How to Host a Website on an Apache Web Server
The Apache HTTP Server (commonly referred to simply as Apache), is a free and open-source web server software brought to you by the Apache Software Foundation. Apache has been around for more than 2 decades and is considered beginner-friendly.
In this tutorial, you will learn how to install an Apache webserver to host a simple HTML website running on a Linux platform.
Install Apache Web Server in Linux
On Ubuntu Linux and other Debian-based distributions such as Linux Mint, Apache can be installed with the following command.
$ sudo apt install apache2 -y
On Red Hat Enterprise Linux and related distributions such as CentOS, Fedora, and Oracle Linux, Apache can be installed with the following command.
On Ubuntu Linux and other Debian-based distributions, you can start and check the status of the Apache webserver by running the commands below.
$ sudo systemctl start apache2 $ sudo systemctl status apache2
On Red Hat Enterprise Linux and related distributions, run the following commands to start and check the status of Apache.
$ sudo systemctl start httpd $ sudo systemctl status httpd
Once you have confirmed that Apache is active, open a web browser and enter the IP address of your Linux server. You may also enter localhost in place of your server IP.
You should see a test page that confirms that Apache is up and running properly.
http://IP-Addresss OR http://localhost
Host a Simple HTML Website on Apache
After you have confirmed that Apache is working properly, you are now ready to add your website content. On Apache, the default location where publicly accessible web content is stored in /var/www/html. This is commonly referred to as the website root.
The first page that is loaded when users visit your website is called the index page. Let us create one as follows.
Firstly, change into the website root with the command below.
On Ubuntu Linux, run the command below to rename the default index page file.
$ sudo mv index.html index.html.bk
On Red Hat, there is nothing to rename here as the default index page file is not stored in this location.
Next, create a new index file with:
Copy and paste the sample HTML code below into the open text editor.
Linux Shell Tips
This website is hosted on Apache.
Save and close the index.html file.
Now, go back to your web browser and refresh the page. You should see your new website as shown in the image below.
Manage Apache Web Server in Linux
As we wrap up this tutorial, let us highlight some basic commands for managing Apache in addition to the ones that we have already used. As you may have noticed, the Apache web service is referred to as apache2 on Ubuntu while it is called httpd on Red Hat Linux.
To configure Apache to automatically start when the Linux server is rebooted, run:
$ sudo systemctl enable apache2 $ sudo systemctl enable httpd
To disable automatic starting of Apache when the Linux server is rebooted, run:
$ sudo systemctl disable apache2 $ sudo systemctl disable httpd
$ sudo systemctl restart apache2 $ sudo systemctl restart httpd
$ sudo systemctl stop apache2 $ sudo systemctl stop httpd
Conclusion
In this tutorial, we have described how to install Apache on Ubuntu Linux as well as Red Hat Linux. We also showed you how to replace the default Apache web page with your own content.