myol
myol

Reputation: 9838

Change apache2 php path

I am using https://github.com/wilmoore/php-version to switch between php versions on my local machine, installed within ~/php/versions. Currently setting up separate VMs with different versions of php installed is not an option.

When I switch php version through the command line using the linked tool, I see it listed as php 7. This also works when using php -v. I have restarted terminal and the machine and it still says php 7.

I have updated composer.json to require php 7.0.2 and greater. Yet when I use phpinfo() in my laravel application, it always states the default PHP Version 5.5.9-1ubuntu4.14.

Where is laravel pointing to the php distribution in my Ubuntu 14.04.3 machine and where can I change this path?

EDIT: I am using Apache. I can see in the phpinfo() output that it is reading the ini file from /etc/php5/apache2/php.ini. I have looked in this file but cannot see where to point to the php distribution.

Upvotes: 2

Views: 7375

Answers (3)

Moshe Maor
Moshe Maor

Reputation: 11

Had the same issue on ubuntu16.

ls -l /etc/apache2/mods-available/php7* , 
showed 2 versions - 
/etc/apache2/mods-available/php7.0.conf
/etc/apache2/mods-available/php7.2.conf

Deleted the /etc/apache2/mods-available/php7.0.conf, restarted apache2, and phpinfo() via apache2 showed php7.2

Upvotes: 1

Ibrahim Mohammed
Ibrahim Mohammed

Reputation: 21

first make sure that php7.*.conf and php7.*.load files are exist in /etc/apache2/mods-available directory.

then use sudo a2enmod php7.* to enable the mod

use sudo a2dismod php5.* to disable the mod

after running the two commands restart your apache2 server

using sudo systemctl restart apache2

Upvotes: 2

Fiete
Fiete

Reputation: 1332

The Apache loads the php5_module library in /etc/apache2/mods-available/php5.load.

LoadModule php5_module /usr/lib/apache2/modules/libphp5.so

If you know the loactions of your alternative libraries you can change them in this file.

After editing you need to restart your apache. sudo service apache2 restart or sudo systemctl restart apache2.service

Upvotes: 1

Related Questions