How to Enable PHP in Apache2
In this tutorial, we will learn you how to enable PHP in apache2. normally we use the ubuntu server. so we will see an example of how to enable PHP in apache2 on ubuntu.
If you want to know php is installed or not then you can open the terminal and type the php -v.
php5 enable or install in apache2
If you want to install php5 then you can use the following command:
1 | sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt php5-mysql |
If you want to enable php5 then you can use the following command:
1 2 | sudo a2enmod php5 sudo service apache2 restart |
Then restart the Apache webserver to enable the module.
php7 enable or install in apache2
If you want to install php7 then you can use the following command:
1 | sudo apt-get install php7.2 libapache2-mod-php7.2 php7.2-mcrypt php7.2-mysql |
If you want to enable php7 then you can use the following command:
1 2 | sudo a2enmod php7.2 sudo service apache2 restart |
Then restart the Apache webserver to enable the module.
php8 enable or install in apache2
If you want to install php8 then you can use the following command:
1 | sudo apt-get install php8.0 libapache2-mod-php8.0 php8.0-mcrypt php8.0-mysql |
If you want to enable php8 then you can use the following command:
1 2 | sudo a2enmod php8.0 sudo systemctl restart apache2 |
Then restart the Apache web server to enable the module.