If you’re thinking of running a website, you’re more likely to go with Apache or have support for Apache on web hosting companies than other web servers. Apache provides powerful features which can be extended by a wide variety of modules. If you’re a student or new user learning Linux, the easiest place to start learning is on Ubuntu Linux. Ubuntu is the modern, open-source Linux operating system for desktops, servers, and other devices. To get started with installing the Apache HTTP server on Ubuntu Linux, follow the steps below.

How to use Apache HTTP server on Ubuntu Linux

As mentioned above, Apache is widely used across the internet. If you want to learn how to install and use it on Ubuntu Linux, then continue below. Apache is available in Ubuntu repositories so we can easily install it using the apt package management tool. To install Apache, run the commands below: The commands above will install the Apache HTTP server. Now, to find out if Apache is installed and running, use the status check command below. The command will output similar lines below when Apache is running.

How to allow Apache through the Ubuntu firewall

If you’re running Ubuntu in protected mode with a firewall enabled, then you’ll have to allow HTTP (80) and HTTPS (443) to the Apache web server. In most cases, Ubuntu servers are running without a firewall enabled. However, run the commands below if you’re not sure. If you’re using UFW to manage the Ubuntu firewall, then run the commands below to allow traffic. That will allow full traffic to Apache. With the firewall opened, simply browse to the server hostname or IP address to see if the Apache default page is up. You should see Apache default welcome page.

How to configure Apache on Ubuntu Linux

Now that Apache is installed, there are important folders and locations that you should be aware of. Other Linux systems might have different folder structures and configuration files. On Ubuntu Linux, these are Apache directory structures and configuration files. All Apache configuration files are located in the /etc/apache2 directory. This is considered the Apache home directory. Apache’s main configuration file is /etc/apache2/apache2.conf. Global configuration settings are done in the file, but this file is rarely ever touched. Port configurations, including changing the default listen ports are specified in this file /etc/apache2/ports.conf. The ports in here are what Apache listens to for traffic. Apache Virtual Hosts files are stored in /etc/apache2/sites-available directory. This is the directory where individual websites are defined. Website configurations are not used by Apache until they’re activated. Once activated, they are then linked to the /etc/apache2/sites-enabled directory. To activate websites so they’re linked to the /etc/apache2/sites-enable directory, these are the command below. (replace example.com.conf with your VirtualHost file) The command above will create a symlink of the website configuration files found in the sites-available directory to the sites-enabled directory. To deactivate a virtual host using the command below. (replace example.com.conf with your website VirtualHost file). Apache uses modules to enhance and add additional functionalities and they are located in the /etc/apache2/mods-available/ directory. Modules are only available to load with Apache when they’re enabled and symlinked to the /etc/apache2/mods-enable/ directory. The a2enconf and a2disconf commands can enable or disable modules. Once modules are activated and linked to the mod-enable directory, they’re then made available to Apache to load. Apache also has log files (access.log and error.log) located in the /var/log/apache/ directory. You can view access and error logs in these files on Ubuntu. There are other Apache configuration files that might be available in Ubuntu that are not listed above. For more Apache configurations and how to use them, we’ll continue posting a valuable tutorial here. Conclusion: This post showed you how to install and use Apache on Ubuntu Linux. If you find any error above or have something to add, please use the comment form below.

How to Install Apache on Ubuntu Linux - 49How to Install Apache on Ubuntu Linux - 19