[英]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
.我正在使用https://github.com/wilmoore/php-version在本地机器上的 php 版本之间切换,安装在
~/php/versions
。 Currently setting up separate VMs with different versions of php installed is not an option.当前设置不同版本的 php 的单独 VM 不是一种选择。
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
.当我使用链接工具通过命令行切换 php 版本时,我看到它被列为 php 7。这在使用
php -v
时也有效。 I have restarted terminal and the machine and it still says php 7.我已经重新启动了终端和机器,它仍然显示 php 7。
I have updated composer.json
to require php 7.0.2 and greater.我已更新
composer.json
以要求 php 7.0.2 及更高版本。 Yet when I use phpinfo()
in my laravel application, it always states the default PHP Version 5.5.9-1ubuntu4.14
.然而,当我在 laravel 应用程序中使用
phpinfo()
时,它总是声明默认的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? laravel 在哪里指向我的 Ubuntu 14.04.3 机器中的 php 发行版,我可以在哪里更改此路径?
EDIT: I am using Apache.编辑:我正在使用 Apache。 I can see in the
phpinfo()
output that it is reading the ini
file from /etc/php5/apache2/php.ini
.我可以在
phpinfo()
输出中看到它正在从/etc/php5/apache2/php.ini
读取ini
文件。 I have looked in this file but cannot see where to point to the php distribution.我查看了这个文件,但看不到指向 php 发行版的位置。
The Apache loads the php5_module library in /etc/apache2/mods-available/php5.load
. Apache 在
/etc/apache2/mods-available/php5.load
加载 php5_module 库。
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.编辑后,您需要重新启动 apache。
sudo service apache2 restart
or sudo systemctl restart apache2.service
sudo service apache2 restart
或sudo systemctl restart apache2.service
Had the same issue on ubuntu16.在 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删除
/etc/apache2/mods-available/php7.0.conf
,重新启动 apache2,通过 apache2 phpinfo()
显示 php7.2
first make sure that php7.*.conf
and php7.*.load
files are exist in /etc/apache2/mods-available
directory.首先确保
php7.*.conf
和php7.*.load
文件存在于/etc/apache2/mods-available
目录中。
then use sudo a2enmod php7.*
to enable the mod然后使用
sudo a2enmod php7.*
启用 mod
use sudo a2dismod php5.*
to disable the mod使用
sudo a2dismod php5.*
禁用 mod
after running the two commands restart your apache2 server运行这两个命令后重启你的 apache2 服务器
using sudo systemctl restart apache2
使用
sudo systemctl restart apache2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.