wordpress droplet doesn't run php after reinstalling apache

September 21, 2015 2.6k views
WordPress Ubuntu PHP Apache

we are using wordpress one-click install ubuntu 14.04 x64 droplet.. we couldn’t restart apache2 after installing Curl we read a solution about reinstalling apache but the result is really bad.. wordpress doesn’t work and all php scripts in var/www/html doesn’t work, adding these lines to .htaccess doesn’t work too
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php

can anyone please help us to fix this issue, thank you in advance.

1 Answer

My guess would be that by un-installing the apache2 package on your droplet you also removed the php5 module. I would suggest you try the following:

apt-get update;
apt-get install php5 php5-mysql libapache2-mod-php5

The WordPress one-click provides a pretty standard set up packages. Apart from WordPress itself they are all installed via apt.

  • great that’s it I forget to install libapache2-mod-php5
    now all php scripts work perfectly but still a little problem all wordpress pages show 404 error

    • That should be another easy fix. WordPress uses rewrites located in a .htaccess file in order to provide it’s permalinks. You’ll need to re-enable this module.

      First, check your virtualhost configuration in /etc/apache2/sites-enabled

      If this already includes the line:

      AllowOverride All

      Then you are good. If it still says AllowOverride None then update this file.

      Now you can enable the rewrite module in apache with the command:

      a2enmod rewrite

      and restart apache to make sure your changes are applied:

      service apache2 restart

      Also, in order to prevent problems later on, I would recommend ensuring that the right user account owns your WordPress files. Assuming Wordpress is still located in the default location (/var/www/html) you can run the following:

      chmod -Rf www-data.www-data /var/www/html
      • thank you so much for your help… it works after using this command a2enmod rewrite

        I read that setting global permission to www/html is not recommanded for potential security problem, I don’t know I will try to read more about it

        you are so nice, thx again for your help.

        • Setting global permissions on /var/www/html is indeed a security concern. This means setting those permissions to 755 or 777 globally.

          I just noticed the typo in my previous message. The command should be

          chown -Rf www-data.www-data /var/www/html
Have another answer? Share your knowledge.