55

I can find the php5 mod in the mods-available directory, but I'm not sure how to get it into the mods-enabled directory.

Also, I just wanted to check that this is the way to enable php on my device...I know that PHP is installed, but another dev has disabled it (and is uncontactable)!

1
  • 1
    Newer versions of apache disable php from inside user folders. Check the end of phpX.conf on mods-enable, comment out the end of it (as it says) Commented Apr 10, 2018 at 19:00

4 Answers 4

89

You can use a2enmod or a2dismod to enable/disable modules by name.

From terminal, run: sudo a2enmod php5 to enable PHP5 (or some other module), then sudo service apache2 reload to reload the Apache2 configuration.

Sign up to request clarification or add additional context in comments.

3 Comments

Yeeeeeeeeeeeeeeeeeeeees. This is it.
For the fools like me that blindly copied the code, use sudo a2enmod phpX.X where X.X is the current version of php
Well, first there need to be modules to enable. They must be downloadable or installable from somewhere. Where???
84

If anyone gets

ERROR: Module phpX.X does not exist!

just install the module for your current php version:

apt-get install libapache2-mod-phpX.X

Comments

7

You have two ways to enable it.

First, you can set the absolute path of the php module file in your httpd.conf file like this:

LoadModule php5_module /path/to/mods-available/libphp5.so

Second, you can link the module file to the mods-enabled directory:

ln -s /path/to/mods-available/libphp5.so /path/to/mods-enabled/libphp5.so

Comments

6
  1. apt-get install libapache2-mod-phpX.X
  2. sudo a2enmod phpx.x
  3. if there is any other mods conflicts whit it, use thissudo a2dismod xxx
  4. sudo service apache2 reload
  5. if you integrate html with php, you must write it in a .php file, rather than .html, or the php text won`t be displayed.
  6. by the way, in the folder /etc/apache2, you might find something you need

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.