Resource icon

PHP script not executing on Apache server

PHP script not executing on Apache server

Apache 2:
One of the most common web server which is admin-friendly and easier to manage & configure is known as Apache 2.

If there is a situation, your PHP files were not executing properly because of apache-2 web server. What would be your next step? Let us find out the solution!

Viewing the PHP code in browser and to get website page from the drive or using .php extension to see the page – you might be running out apache 2 as one perfect web server. But, to configure all these functionalities you have to run the apach 2 web server more than 3 or 4 times. Is this healthy habit for your website? This would give you a fluctuation in security terms.

We have a quick solution to fix this problem. You can work casually with Apache 2 and PHP while fixing this problem.

Solution 1:

.conf files modification:

The first step is to modify the .conf file. Just type the command like below:
Code:
sudo nano /etc/apache2/apache2.conf
By now, your apache2.conf file will be opened. And then add below statements:
<FilesMatch \.php$>
SetHandler application/x-httpd-phd
</FilesMatch>
That’s it! Close the apache2.conf file and don’t forget to save the file.

Solution 2:

Apache 2 restart:

In solution 2, we have disabled and enabled the modules. So, for restarting it would be easier for apache 2. To start the restart just run the command like below:

Code:
sudo service apache2 restart
Overall, now you can see the code displayed in browser, website execution properly and it won’t save in drive.

Solution 3:

Get module disable or enable:

From the window terminal type the command as

Code:
sudo a2dismod mpm_event && sudo a2enmod mpm_prefork && sudo a2enmod php7.0
After running this command, you can see the enablement of php7 and mpm_prefork. Disable the module mpm_event.

Solution 4:

Apache 2 restart:

In solution 2, we have disabled and enabled the modules. So, for restarting it would be easier for apache 2. To start the restart just run the command like below:

Code:
sudo service apache2 restart
Overall, now you can see the code displayed in browser, website execution properly and it won’t save in drive.

These 3 solutions would give you best results.
Author
bhawanisingh
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from bhawanisingh

Top