How to check if the exec() function is enabled in my PHP install

Posted February 20, 2021 3.4k views

I am NOT a technical person, so im trying to download a backup manager extension for my app on the droplet but it requires:

the exec() function enabled in your PHP install since it will call a few command line commands to create the backups.
Additionally, this only works on a linux environment where the “tar” and “mysqldump” commands are available (99% of linux servers have them)

is there detailed steps on how i can do this in putty or winscp? i have a lamp on ubunutu 20.04 using php version 7.4.3

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hello, @adamSar

If you’ve already configured the LAMP stack (Linux, Apache, MySQL, PHP) setup using our tutorial:

How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 20.04

then PHP is already configured as you mentioned the version is 7.4.3

You can create a PHP info file and check if the exec function is enabled/disabled. You can create a file named phpinfo.php (the name doesn’t really matter) and put the following content in the file:


The file must be present inside your public_html folder so you can then access the file via your browser and check the PHP information. Once the file is added go to your browser and access the file using your domain name or IP address, e.g or IPaddress/phpinfo.php

You can search for disable_functions and if exec is listed it means it is disabled. To enable it just remove the exec from the line and then you need to restart Apache and you will be good to go.

If exec is not listed in the disable_functions line it means that it is enabled.

Hope that this helps!

by Erika Heidi
A “LAMP” stack is a group of open-source software that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym which represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL database, and dynamic content is processed by PHP. In this guide, we will install a LAMP stack on an Ubuntu 20.04 server.

Hi @adamSar,

If you already have PHP installed on your droplet, you can SSH to it, create a new file, for example test_exec.php like so

touch test_exec.php

Then inside of it, add the following

if(function_exists('exec')) {
    echo "exec is enabled";

Save the file and execute it like so

php test_exec.php

If it returns an output of exec is enabled, you’ll know you have exec enabled.

Now, if you don’t have PHP installed.


sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update

Install PHP 7.3 for Apache

sudo apt install php7.3

Install PHP 7.3 for Nginx

sudo apt install php7.3-fpm

Install PHP 7.3 Extensions

You can use the following command to install the most needed PHP extensions

sudo apt install php7.3-common php7.3-mysql php7.3-xml php7.3-xmlrpc php7.3-curl php7.3-gd php7.3-imagick php7.3-cli php7.3-dev php7.3-imap php7.3-mbstring php7.3-opcache php7.3-soap php7.3-zip php7.3-intl -y