Fix Apache Web Server Refusing To Start Or Restart
On this page, you will learn how to simply Fix Apache Web Server refusing to start or restart after carrying out some tasks in your server.
Apache web server as the name implies is a hosting server software which function is to serve web contents to site visitors, it is open-source and free powering about 40% of websites around the world.
If Apache web server encounters a problem due to misconfiguration or whatever; the hosted website will go offline until the problem is fixed properly.
Here, I am going to show you how to Fix the Apache web server whenever it refuses to start or restart after upgrading your server apache from one version to another. The issue of Apache, not starting can also be encountered after disabling the default configuration file of the virtual hosts in Apache using the command sudo a2dissite 000-default.conf while installing laravel in the server.
Kindly follow the below guidelines to successfully Fix Apache Web Server Refusing To Start Or Restart.
SEE ALSO:
How To Fix Apache Web Server Refusing To Start Or Restart
This is usually caused by the absence of PHP.conf and Php.load files in the mods-enabled directory of the apache2 under the etc directory, follow the below steps to create these two files to enable the Apache web server to run.
Using Web Hosting Control Panel To Fix
Let’s assume you are using a hosting control panel such as Virtualmin or Cpanel all you have to do is to:
- Proceed to the File Manager.
- Go to the root directory /etc/apache2/mods-enabled/
- Select the ‘file’ option and create a new file with the name php8.0.conf or php7.4.conf depending on the PHP version installed in the server (in the codes below I am using php8.0 as an example, you must change the 8.0 to the version installed in your server), then type the below code in the file and save.
<FilesMatch “.+\.ph(ar|p|tml)$”> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch “.+\.phps$”> SetHandler application/x-httpd-php-sourceRequire all denied </FilesMatch> <FilesMatch “^\.ph(ar|p|ps|tml)$”> Require all denied </FilesMatch><IfModule mod_userdir.c> <Directory /home/*/public_html> php_admin_flag engine Off </Directory> </IfModule> |
Select the ‘file’ option and create a new file with the name php8.0.load or php7.4.load depending on the PHP version installed in the server, then type the below code in the file into the file and save.
LoadModule php_module /usr/lib/apache2/modules/libphp8.0.so |
Now restart the apache web server and it will start.
Using Terminal SSH To Fix
Log into your server through the terminal using your SSH login and run the following codes accordingly to create the php8.0.conf and php8.0.load files (always replace 8.0 with the PHP version in your server).
- cd /etc/apache2/mods-enabled/
- nano php8.0.conf
- Type the below code.
<FilesMatch “.+\.ph(ar|p|tml)$”> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch “.+\.phps$”> SetHandler application/x-httpd-php-sourceRequire all denied </FilesMatch> <FilesMatch “^\.ph(ar|p|ps|tml)$”> Require all denied </FilesMatch><IfModule mod_userdir.c> <Directory /home/*/public_html> php_admin_flag engine Off </Directory> </IfModule> |
- Press Ctrl and X button to save.
- nano php8.0.load
- Type the below code.
LoadModule php_module /usr/lib/apache2/modules/libphp8.0.so |
- Press Ctrl and X button to save.
- Restart apache by running # /etc/init.d/apache2 restart
OR
- $ sudo /etc/init.d/apache2 restart
OR
- $ sudo service apache2 restart