启用 PHP Apache2
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42654694/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Enable PHP Apache2
提问by SE_1991
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.
我可以在 mods-available 目录中找到 php5 mod,但我不确定如何将它放入 mods-enabled 目录。
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)!
另外,我只是想检查一下这是在我的设备上启用 php 的方法……我知道 PHP 已安装,但另一个开发人员已禁用它(并且无法联系)!
回答by JHoerbst
If anyone gets
如果有人得到
ERROR: Module phpX.X does not exist!
错误:模块 phpX.X 不存在!
just install the module for your current php version:
只需为您当前的 php 版本安装模块:
apt-get install libapache2-mod-phpX.X
回答by Patrick Moore
You can use a2enmod
or a2dismod
to enable/disable modules by name.
您可以使用a2enmod
或a2dismod
按名称启用/禁用模块。
From terminal, run: sudo a2enmod php5
to enable PHP5 (or some other module), then sudo service apache2 reload
to reload the Apache2 configuration.
从终端运行:sudo a2enmod php5
以启用 PHP5(或其他一些模块),然后sudo service apache2 reload
重新加载 Apache2 配置。
回答by Lucas Mendes
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:
首先,您可以像这样在 httpd.conf 文件中设置 php 模块文件的绝对路径:
LoadModule php5_module /path/to/mods-available/libphp5.so
Second, you can link the module file to the mods-enabled directory:
其次,您可以将模块文件链接到 mods-enabled 目录:
ln -s /path/to/mods-available/libphp5.so /path/to/mods-enabled/libphp5.so