How to Fix the “Failed to start php7.4-fpm.service: Unit php7.4-fpm.service is masked” Error on Ubuntu

When working with Ubuntu and PHP, you may encounter an error message that says “Failed to start php7.4-fpm.service: Unit php7.4-fpm.service is masked.” This error indicates that the php7.4-fpm.service unit in systemd is masked, preventing it from being started or managed using systemd commands. In this article, we will guide you through the process of unmasking and starting the php7.4-fpm.service to resolve this issue.

Prerequisites

Before proceeding, make sure you have the following:

  • A terminal or SSH access to your Ubuntu server.
  • Root or sudo privileges to execute commands.

Step 1: Check the Status of the php7.4-fpm.service

To begin, we need to check the status of the php7.4-fpm.service to confirm that it is indeed masked. Follow these steps:

  1. Open a terminal or establish an SSH connection to your Ubuntu server.
  2. Run the following command to check the status of the php7.4-fpm.service:
systemctl status php7.4-fpm.service

This command will remove the mask from the service, allowing you to interact with it through systemd.

Step 2: Unmask the php7.4-fpm.service

If the php7.4-fpm.service is masked, you need to unmask it before you can start and manage it using systemd. Follow these steps to unmask the service:

In the terminal, execute the following command with sudo privileges:

sudo systemctl unmask php7.4-fpm.service

This command will remove the mask from the service, allowing you to interact with it through systemd.

Step 3: Start the php7.4-fpm.service

After unmasking the service, you can attempt to start it using systemd. Follow these steps to start the php7.4-fpm.service:

Execute the following command with sudo privileges to start the service:

sudo systemctl start php7.4-fpm.service

This command will initiate the PHP-FPM service and attempt to start it.

Step 4: Verify the Service Status

To ensure that the php7.4-fpm.service has started successfully without any errors, follow these steps:

Run the following command to check the status of the service again:

systemctl status php7.4-fpm.service

This command will display the current state of the service and any relevant error messages, if applicable.

  • If the service is active and running, without any errors or warnings, you have successfully resolved the issue.
  • If there are any errors or the service fails to start, review the error message for further troubleshooting.

Conclusion

By following the steps outlined in this article, you should be able to fix the “Failed to start php7.4-fpm.service: Unit php7.4-fpm.service is masked” error on Ubuntu. Remember to verify the status of the service after unmasking and starting it to ensure that it is running correctly. If you encounter any further issues, make sure to review any error messages for additional troubleshooting steps.

Leave a Comment