John Davidson

ubuntu - Set default PHP version of apache2 to a specific version

0 comments
Message:


Currently the PHP version showing if I call phpinfo() is 8.0.19.
I need to change it to 8.0.15.


I already build 8.0.15 from source and changed the CLI PHP version successfully by using update-alternatives.


php -v


PHP 8.0.15 (cli) (built: Jun  7 2022 10:21:21) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.15, Copyright (c) Zend Technologies

But phpinfo still shows 8.0.19.


How can I set it to 8.0.15 globally?




I'am using Ubuntu 22.04




/etc/apache2/mods-enabled


lrwxrwxrwx 1 root root   36 Jun  1 14:30 access_compat.load -> ../mods-available/access_compat.load
lrwxrwxrwx 1 root root 28 Jun 1 14:30 alias.conf -> ../mods-available/alias.conf
lrwxrwxrwx 1 root root 28 Jun 1 14:30 alias.load -> ../mods-available/alias.load
lrwxrwxrwx 1 root root 33 Jun 1 14:30 auth_basic.load -> ../mods-available/auth_basic.load
lrwxrwxrwx 1 root root 33 Jun 1 14:30 authn_core.load -> ../mods-available/authn_core.load
lrwxrwxrwx 1 root root 33 Jun 1 14:30 authn_file.load -> ../mods-available/authn_file.load
lrwxrwxrwx 1 root root 33 Jun 1 14:30 authz_core.load -> ../mods-available/authz_core.load
lrwxrwxrwx 1 root root 33 Jun 1 14:30 authz_host.load -> ../mods-available/authz_host.load
lrwxrwxrwx 1 root root 33 Jun 1 14:30 authz_user.load -> ../mods-available/authz_user.load
lrwxrwxrwx 1 root root 32 Jun 1 14:30 autoindex.conf -> ../mods-available/autoindex.conf
lrwxrwxrwx 1 root root 32 Jun 1 14:30 autoindex.load -> ../mods-available/autoindex.load
lrwxrwxrwx 1 root root 30 Jun 1 14:30 deflate.conf -> ../mods-available/deflate.conf
lrwxrwxrwx 1 root root 30 Jun 1 14:30 deflate.load -> ../mods-available/deflate.load
lrwxrwxrwx 1 root root 26 Jun 1 14:30 dir.conf -> ../mods-available/dir.conf
lrwxrwxrwx 1 root root 26 Jun 1 14:30 dir.load -> ../mods-available/dir.load
lrwxrwxrwx 1 root root 26 Jun 1 14:30 env.load -> ../mods-available/env.load
lrwxrwxrwx 1 root root 29 Jun 1 14:30 filter.load -> ../mods-available/filter.load
lrwxrwxrwx 1 root root 27 Jun 1 14:30 mime.conf -> ../mods-available/mime.conf
lrwxrwxrwx 1 root root 27 Jun 1 14:30 mime.load -> ../mods-available/mime.load
lrwxrwxrwx 1 root root 34 Jun 1 14:30 mpm_prefork.conf -> ../mods-available/mpm_prefork.conf
lrwxrwxrwx 1 root root 34 Jun 1 14:30 mpm_prefork.load -> ../mods-available/mpm_prefork.load
lrwxrwxrwx 1 root root 34 Jun 1 14:30 negotiation.conf -> ../mods-available/negotiation.conf
lrwxrwxrwx 1 root root 34 Jun 1 14:30 negotiation.load -> ../mods-available/negotiation.load
lrwxrwxrwx 1 root root 29 Jun 7 13:03 php8.0.conf -> ../mods-available/php8.0.conf
lrwxrwxrwx 1 root root 29 Jun 7 13:03 php8.0.load -> ../mods-available/php8.0.load
lrwxrwxrwx 1 root root 33 Jun 1 14:30 reqtimeout.conf -> ../mods-available/reqtimeout.conf
lrwxrwxrwx 1 root root 33 Jun 1 14:30 reqtimeout.load -> ../mods-available/reqtimeout.load
lrwxrwxrwx 1 root root 30 Jun 2 11:42 rewrite.load -> ../mods-available/rewrite.load
lrwxrwxrwx 1 root root 31 Jun 1 14:30 setenvif.conf -> ../mods-available/setenvif.conf
lrwxrwxrwx 1 root root 31 Jun 1 14:30 setenvif.load -> ../mods-available/setenvif.load
lrwxrwxrwx 1 root root 36 Jun 2 08:38 socache_shmcb.load -> ../mods-available/socache_shmcb.load
lrwxrwxrwx 1 root root 26 Jun 2 08:38 ssl.conf -> ../mods-available/ssl.conf
lrwxrwxrwx 1 root root 26 Jun 2 08:38 ssl.load -> ../mods-available/ssl.load
lrwxrwxrwx 1 root root 29 Jun 1 14:30 status.conf -> ../mods-available/status.conf
lrwxrwxrwx 1 root root 29 Jun 1 14:30 status.load -> ../mods-available/status.load

/etc/apache2/mods-available


-rw-r--r-- 1 root root  100 Mar 23 02:00 access_compat.load
-rw-r--r-- 1 root root 377 Mar 23 02:00 actions.conf
-rw-r--r-- 1 root root 66 Mar 23 02:00 actions.load
-rw-r--r-- 1 root root 843 Mar 23 02:00 alias.conf
-rw-r--r-- 1 root root 62 Mar 23 02:00 alias.load
-rw-r--r-- 1 root root 76 Mar 23 02:00 allowmethods.load
-rw-r--r-- 1 root root 76 Mar 23 02:00 asis.load
-rw-r--r-- 1 root root 94 Mar 23 02:00 auth_basic.load
-rw-r--r-- 1 root root 96 Mar 23 02:00 auth_digest.load
-rw-r--r-- 1 root root 100 Mar 23 02:00 auth_form.load
-rw-r--r-- 1 root root 72 Mar 23 02:00 authn_anon.load
-rw-r--r-- 1 root root 72 Mar 23 02:00 authn_core.load
-rw-r--r-- 1 root root 85 Mar 23 02:00 authn_dbd.load
-rw-r--r-- 1 root root 70 Mar 23 02:00 authn_dbm.load
-rw-r--r-- 1 root root 72 Mar 23 02:00 authn_file.load
-rw-r--r-- 1 root root 78 Mar 23 02:00 authn_socache.load
-rw-r--r-- 1 root root 74 Mar 23 02:00 authnz_fcgi.load
-rw-r--r-- 1 root root 90 Mar 23 02:00 authnz_ldap.load
-rw-r--r-- 1 root root 72 Mar 23 02:00 authz_core.load
-rw-r--r-- 1 root root 96 Mar 23 02:00 authz_dbd.load
-rw-r--r-- 1 root root 92 Mar 23 02:00 authz_dbm.load
-rw-r--r-- 1 root root 104 Mar 23 02:00 authz_groupfile.load
-rw-r--r-- 1 root root 94 Mar 23 02:00 authz_host.load
-rw-r--r-- 1 root root 74 Mar 23 02:00 authz_owner.load
-rw-r--r-- 1 root root 94 Mar 23 02:00 authz_user.load
-rw-r--r-- 1 root root 3.3K Mar 23 02:00 autoindex.conf
-rw-r--r-- 1 root root 70 Mar 23 02:00 autoindex.load
-rw-r--r-- 1 root root 64 Mar 23 02:00 brotli.load
-rw-r--r-- 1 root root 64 Mar 23 02:00 buffer.load
-rw-r--r-- 1 root root 62 Mar 23 02:00 cache.load
-rw-r--r-- 1 root root 889 Mar 23 02:00 cache_disk.conf
-rw-r--r-- 1 root root 89 Mar 23 02:00 cache_disk.load
-rw-r--r-- 1 root root 95 Mar 23 02:00 cache_socache.load
-rw-r--r-- 1 root root 70 Mar 23 02:00 cern_meta.load
-rw-r--r-- 1 root root 58 Mar 23 02:00 cgi.load
-rw-r--r-- 1 root root 115 Mar 23 02:00 cgid.conf
-rw-r--r-- 1 root root 60 Mar 23 02:00 cgid.load
-rw-r--r-- 1 root root 76 Mar 23 02:00 charset_lite.load
-rw-r--r-- 1 root root 60 Mar 23 02:00 data.load
-rw-r--r-- 1 root root 93 Mar 23 02:00 dav.load
-rw-r--r-- 1 root root 83 Mar 23 02:00 dav_fs.conf
-rw-r--r-- 1 root root 79 Mar 23 02:00 dav_fs.load
-rw-r--r-- 1 root root 68 Mar 23 02:00 dav_lock.load
-rw-r--r-- 1 root root 58 Mar 23 02:00 dbd.load
-rw-r--r-- 1 root root 460 Mar 23 02:00 deflate.conf
-rw-r--r-- 1 root root 84 Mar 23 02:00 deflate.load
-rw-r--r-- 1 root root 64 Mar 23 02:00 dialup.load
-rw-r--r-- 1 root root 157 Mar 23 02:00 dir.conf
-rw-r--r-- 1 root root 58 Mar 23 02:00 dir.load
-rw-r--r-- 1 root root 64 Mar 23 02:00 dump_io.load
-rw-r--r-- 1 root root 60 Mar 23 02:00 echo.load
-rw-r--r-- 1 root root 58 Mar 23 02:00 env.load
-rw-r--r-- 1 root root 66 Mar 23 02:00 expires.load
-rw-r--r-- 1 root root 72 Mar 23 02:00 ext_filter.load
-rw-r--r-- 1 root root 89 Mar 23 02:00 file_cache.load
-rw-r--r-- 1 root root 64 Mar 23 02:00 filter.load
-rw-r--r-- 1 root root 66 Mar 23 02:00 headers.load
-rw-r--r-- 1 root root 176 Mar 23 02:00 heartbeat.load
-rw-r--r-- 1 root root 182 Mar 23 02:00 heartmonitor.load
-rw-r--r-- 1 root root 1.3K Mar 23 02:00 http2.conf
-rw-r--r-- 1 root root 62 Mar 23 02:00 http2.load
-rw-r--r-- 1 root root 62 Mar 23 02:00 ident.load
-rw-r--r-- 1 root root 68 Mar 23 02:00 imagemap.load
-rw-r--r-- 1 root root 82 Mar 23 02:00 include.load
-rw-r--r-- 1 root root 402 Mar 23 02:00 info.conf
-rw-r--r-- 1 root root 60 Mar 23 02:00 info.load
-rw-r--r-- 1 root root 116 Mar 23 02:00 lbmethod_bybusyness.load
-rw-r--r-- 1 root root 116 Mar 23 02:00 lbmethod_byrequests.load
-rw-r--r-- 1 root root 114 Mar 23 02:00 lbmethod_bytraffic.load
-rw-r--r-- 1 root root 114 Mar 23 02:00 lbmethod_heartbeat.load
-rw-r--r-- 1 root root 121 Mar 23 02:00 ldap.conf
-rw-r--r-- 1 root root 60 Mar 23 02:00 ldap.load
-rw-r--r-- 1 root root 70 Mar 23 02:00 log_debug.load
-rw-r--r-- 1 root root 76 Mar 23 02:00 log_forensic.load
-rw-r--r-- 1 root root 58 Mar 23 02:00 lua.load
-rw-r--r-- 1 root root 62 Mar 23 02:00 macro.load
-rw-r--r-- 1 root root 56 Mar 23 02:00 md.load
-rw-r--r-- 1 root root 7.6K Mar 23 02:00 mime.conf
-rw-r--r-- 1 root root 60 Mar 23 02:00 mime.load
-rw-r--r-- 1 root root 120 Mar 23 02:00 mime_magic.conf
-rw-r--r-- 1 root root 72 Mar 23 02:00 mime_magic.load
-rw-r--r-- 1 root root 668 Mar 23 02:00 mpm_event.conf
-rw-r--r-- 1 root root 106 Mar 23 02:00 mpm_event.load
-rw-r--r-- 1 root root 571 Mar 23 02:00 mpm_prefork.conf
-rw-r--r-- 1 root root 108 Mar 23 02:00 mpm_prefork.load
-rw-r--r-- 1 root root 836 Mar 23 02:00 mpm_worker.conf
-rw-r--r-- 1 root root 107 Mar 23 02:00 mpm_worker.load
-rw-r--r-- 1 root root 724 Mar 23 02:00 negotiation.conf
-rw-r--r-- 1 root root 74 Mar 23 02:00 negotiation.load
-rw-r--r-- 1 root root 855 May 17 18:49 php8.0.conf
-rw-r--r-- 1 root root 101 May 17 18:49 php8.0.load
-rw-r--r-- 1 root root 822 Mar 23 02:00 proxy.conf
-rw-r--r-- 1 root root 62 Mar 23 02:00 proxy.load
-rw-r--r-- 1 root root 87 Mar 23 02:00 proxy_ajp.load
-rw-r--r-- 1 root root 347 Mar 23 02:00 proxy_balancer.conf
-rw-r--r-- 1 root root 115 Mar 23 02:00 proxy_balancer.load
-rw-r--r-- 1 root root 95 Mar 23 02:00 proxy_connect.load
-rw-r--r-- 1 root root 95 Mar 23 02:00 proxy_express.load
-rw-r--r-- 1 root root 89 Mar 23 02:00 proxy_fcgi.load
-rw-r--r-- 1 root root 93 Mar 23 02:00 proxy_fdpass.load
-rw-r--r-- 1 root root 189 Mar 23 02:00 proxy_ftp.conf
-rw-r--r-- 1 root root 87 Mar 23 02:00 proxy_ftp.load
-rw-r--r-- 1 root root 93 Mar 23 02:00 proxy_hcheck.load
-rw-r--r-- 1 root root 2.5K Mar 23 02:00 proxy_html.conf
-rw-r--r-- 1 root root 97 Mar 23 02:00 proxy_html.load
-rw-r--r-- 1 root root 89 Mar 23 02:00 proxy_http.load
-rw-r--r-- 1 root root 97 Mar 23 02:00 proxy_http2.load
-rw-r--r-- 1 root root 89 Mar 23 02:00 proxy_scgi.load
-rw-r--r-- 1 root root 91 Mar 23 02:00 proxy_uwsgi.load
-rw-r--r-- 1 root root 97 Mar 23 02:00 proxy_wstunnel.load
-rw-r--r-- 1 root root 85 Mar 23 02:00 ratelimit.load
-rw-r--r-- 1 root root 70 Mar 23 02:00 reflector.load
-rw-r--r-- 1 root root 68 Mar 23 02:00 remoteip.load
-rw-r--r-- 1 root root 1.2K Mar 23 02:00 reqtimeout.conf
-rw-r--r-- 1 root root 72 Mar 23 02:00 reqtimeout.load
-rw-r--r-- 1 root root 66 Mar 23 02:00 request.load
-rw-r--r-- 1 root root 66 Mar 23 02:00 rewrite.load
-rw-r--r-- 1 root root 58 Mar 23 02:00 sed.load
-rw-r--r-- 1 root root 66 Mar 23 02:00 session.load
-rw-r--r-- 1 root root 99 Mar 23 02:00 session_cookie.load
-rw-r--r-- 1 root root 99 Mar 23 02:00 session_crypto.load
-rw-r--r-- 1 root root 93 Mar 23 02:00 session_dbd.load
-rw-r--r-- 1 root root 1.3K Mar 23 02:00 setenvif.conf
-rw-r--r-- 1 root root 68 Mar 23 02:00 setenvif.load
-rw-r--r-- 1 root root 78 Mar 23 02:00 slotmem_plain.load
-rw-r--r-- 1 root root 74 Mar 23 02:00 slotmem_shm.load
-rw-r--r-- 1 root root 74 Mar 23 02:00 socache_dbm.load
-rw-r--r-- 1 root root 84 Mar 23 02:00 socache_memcache.load
-rw-r--r-- 1 root root 78 Mar 23 02:00 socache_redis.load
-rw-r--r-- 1 root root 78 Mar 23 02:00 socache_shmcb.load
-rw-r--r-- 1 root root 66 Mar 23 02:00 speling.load
-rw-r--r-- 1 root root 3.1K Mar 23 02:00 ssl.conf
-rw-r--r-- 1 root root 97 Mar 23 02:00 ssl.load
-rw-r--r-- 1 root root 749 Mar 23 02:00 status.conf
-rw-r--r-- 1 root root 64 Mar 23 02:00 status.load
-rw-r--r-- 1 root root 72 Mar 23 02:00 substitute.load
-rw-r--r-- 1 root root 64 Mar 23 02:00 suexec.load
-rw-r--r-- 1 root root 70 Mar 23 02:00 unique_id.load
-rw-r--r-- 1 root root 324 Mar 23 02:00 userdir.conf
-rw-r--r-- 1 root root 66 Mar 23 02:00 userdir.load
-rw-r--r-- 1 root root 70 Mar 23 02:00 usertrack.load
-rw-r--r-- 1 root root 74 Mar 23 02:00 vhost_alias.load
-rw-r--r-- 1 root root 66 Mar 23 02:00 xml2enc.load


My Answer:
To set the default PHP version for Apache to 8.0.15, you need to update the configuration files for Apache to use the desired PHP version. Here's how you can do it:

1. Disable the current PHP version module for Apache:
bash
sudo a2dismod php8.0


2. Enable the PHP 8.0.15 module for Apache:
bash
sudo a2enmod php8.0


3. Restart Apache for the changes to take effect:
bash
sudo systemctl restart apache2


After following these steps, Apache should now be using PHP version 8.0.15. You can verify this by checking the phpinfo() output or running a PHP script on your server.

Rate this post

3 of 5 based on 6999 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us