Search for:
Apache Web Server

How to Install Apache Web Server (Ubuntu/Debian)

Apache is one of the most widely-used open-source web servers, powering millions of websites worldwide. It’s commonly used to serve PHP applications, WordPress sites, and static content on Linux servers.

Follow these steps to install and configure Apache on Ubuntu/Debian:

Step 1: Install Apache

sudo apt-get install apache2 -y

This installs the Apache2 package. The -y flag automatically confirms the installation prompt.

Step 2: Enable the Rewrite Module

sudo a2enmod rewrite

mod_rewrite allows URL rewriting — essential for clean URLs and .htaccess support, which most CMS platforms (like WordPress) rely on.

Step 3: Restart Apache

sudo systemctl restart apache2

Restarting applies the module changes.

Step 4: Verify Apache Is Running

If the status shows “active (running),” Apache is working. You can also visit your server’s IP address in a browser — you should see Apache’s default “It works!” page.

Common issues:

If the install fails, run sudo apt update first
If port 80 is already in use, check with sudo lsof -i :80 — another service (like Nginx) might be using it

PHP 7.4

php-7.4

Step 1 :- sudo apt update

Step 2 :- sudo apt-get -y install php php-cgi libapache2-mod-php php-common php-pear php-mbstring && sudo apt install -y php7.4 libapache2-mod-php7.4 php7.4-common php7.4-gmp php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-mysql php7.4-gd php7.4-bcmath php7.4-xml php7.4-cli php7.4-zip && sudo a2enmod rewrite && sudo apt-get install -y php7.4-{cli,bcmath,bz2,intl,gd,mbstring,mysql,zip,opcache,intl,bcmath,xsl,zip,bz2}

Step 3 :- php -v

Install MariaDB 10+

Step 1 :- sudo apt update

Step 2 :- sudo apt install mariadb-server

Step 3 :- sudo systemctl start mariadb.service

Step 4 :- sudo mysql_secure_installation

then press Y set new password press Y,Y,Y

Set User and Password

Step 5 :- sudo mariadb

Then run This command

GRANT ALL ON *.* TO ‘root’@’localhost’ IDENTIFIED BY ‘Use last password‘ WITH GRANT OPTION;

FLUSH PRIVILEGES;

exit

sudo systemctl status mariadb