To install Apache on Ubuntu, follow the steps below. Apache is a popular web server software that allows you to host websites and web applications.
Prerequisites
Before installing Apache, make sure you have the following prerequisites:
- Ubuntu server installed
- SSH access to your server
- Superuser or sudo privileges
Step 1: Update Package Lists
First, update your package lists to ensure you have the latest packages available:
sudo apt update
Step 2: Install Apache
Now, install Apache by running the following command:
sudo apt install apache2
Once the installation is complete, Apache will automatically start.
Step 3: Check Apache Status
To verify that Apache is running, check its status using the following command:
sudo systemctl status apache2
You should see a status indicating that Apache is active (running).
Step 4: Test Apache Installation
Open a web browser and enter your server's IP address or domain name. You should see the Apache default welcome page.
If you see the welcome page, it means Apache is installed and working correctly.
Step 5: Configure Apache
To configure Apache, you need to edit the default configuration file. Run the following command to open the file:
sudo nano /etc/apache2/apache2.conf
Locate the ServerName
directive and set it to your server's IP address or domain name. For example:
ServerName example.com
Step 6: Enable Mod Rewrite
To enable mod_rewrite, which is essential for many web applications, run the following command:
sudo a2enmod rewrite
Step 7: Restart Apache
After making changes to the Apache configuration, restart the service to apply the changes:
sudo systemctl restart apache2
Step 8: Test Configuration
Return to your web browser and enter your server's IP address or domain name. You should now see a confirmation message indicating that the configuration has been successfully updated.
Congratulations! You have successfully installed and configured Apache on your Ubuntu server. For further information and tutorials, visit our Apache documentation.