![安装 apache2 php 模块](https://linux22.com/image/1185304/%E5%AE%89%E8%A3%85%20apache2%20php%20%E6%A8%A1%E5%9D%97.png)
我的 apache2 安装混乱了。我无法安装 apache2 的 php 模块。如何安装 Apache2 的 php 模块?
我已尝试过:
$ sudo apt reinstall libapache2-mod-php
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-5.11.0-44-generic linux-hwe-5.11-headers-5.11.0-44 linux-image-5.11.0-44-generic
linux-modules-5.11.0-44-generic linux-modules-extra-5.11.0-44-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 3 not upgraded.
Need to get 2.836 B of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://aw.archive.ubuntu.com/ubuntu focal/main amd64 libapache2-mod-php all 2:7.4+75 [2.836 B]
Fetched 2.836 B in 1s (4.938 B/s)
dpkg: warning: files list file for package 'firefox-mozilla-build' missing; assuming package has no files
currently installed
(Reading database ... 333225 files and directories currently installed.)
Preparing to unpack .../libapache2-mod-php_2%3a7.4+75_all.deb ...
Unpacking libapache2-mod-php (2:7.4+75) over (2:7.4+75) ...
Setting up libapache2-mod-php (2:7.4+75) ...
和
$ sudo apt purge libapache2-mod-php
$ sudo apt install libapache2-mod-php
模块未安装:
$ ls /etc/apache2/mods-available
access_compat.load cgi.load log_debug.load ratelimit.load
actions.conf charset_lite.load log_forensic.load reflector.load
actions.load data.load lua.load remoteip.load
alias.conf dav_fs.conf macro.load reqtimeout.conf
alias.load dav_fs.load md.load reqtimeout.load
allowmethods.load dav.load mime.conf request.load
asis.load dav_lock.load mime.load rewrite.load
auth_basic.load dbd.load mime_magic.conf sed.load
auth_digest.load deflate.conf mime_magic.load session_cookie.load
auth_form.load deflate.load mpm_event.conf session_crypto.load
authn_anon.load dialup.load mpm_event.load session_dbd.load
authn_core.load dir.conf mpm_prefork.conf session.load
authn_dbd.load dir.load mpm_prefork.load setenvif.conf
authn_dbm.load dump_io.load mpm_worker.conf setenvif.load
authn_file.load echo.load mpm_worker.load slotmem_plain.load
authn_socache.load env.load negotiation.conf slotmem_shm.load
authnz_fcgi.load expires.load negotiation.load socache_dbm.load
authnz_ldap.load ext_filter.load proxy_ajp.load socache_memcache.load
authz_core.load file_cache.load proxy_balancer.conf socache_redis.load
authz_dbd.load filter.load proxy_balancer.load socache_shmcb.load
authz_dbm.load headers.load proxy.conf speling.load
authz_groupfile.load heartbeat.load proxy_connect.load ssl.conf
authz_host.load heartmonitor.load proxy_express.load ssl.load
authz_owner.load http2.conf proxy_fcgi.load status.conf
authz_user.load http2.load proxy_fdpass.load status.load
autoindex.conf ident.load proxy_ftp.conf substitute.load
autoindex.load imagemap.load proxy_ftp.load suexec.load
brotli.load include.load proxy_hcheck.load unique_id.load
buffer.load info.conf proxy_html.conf userdir.conf
cache_disk.conf info.load proxy_html.load userdir.load
cache_disk.load lbmethod_bybusyness.load proxy_http2.load usertrack.load
cache.load lbmethod_byrequests.load proxy_http.load vhost_alias.load
cache_socache.load lbmethod_bytraffic.load proxy.load xml2enc.load
cern_meta.load lbmethod_heartbeat.load proxy_scgi.load
cgid.conf ldap.conf proxy_uwsgi.load
cgid.load ldap.load proxy_wstunnel.load
答案1
对于我来说,libapache2-mod-php
由于某种原因,没有启用安装的 php 版本。
所以我不得不跑去a2enmod
看看我有什么可用的。就我而言,我有这些:
php7.0 php7.2 php7.3 php7.4 php8.0 php8.1
我仔细检查了已安装的版本apt list php | grep installed
。就我而言,我有:
php/focal,focal,now 2:8.1+92+ubuntu20.04.1+deb.sury.org+2 all [installed]
这意味着,我有版本 8.1(带有 ubuntu 补丁,但这与此无关)。
所以我只需要跑a2enmod php8.1
,问题就解决了!