enabling php7

Issues related to applications and software problems and general support
Post Reply
freaks
Posts: 5
Joined: 2021/10/22 15:20:56

enabling php7

Post by freaks » 2021/10/22 15:22:48

hello
i installed lamp on my centos 8
but i can't enable php 7.2
when i access the website my php file is not interpreted
i have php-fpm and apache

what can i do ?
thnaks

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: enabling php7

Post by TrevorH » 2021/10/22 15:34:11

i installed lamp on my centos 8
What did you do to install it?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

freaks
Posts: 5
Joined: 2021/10/22 15:20:56

Re: enabling php7

Post by freaks » 2021/10/22 15:50:57

very simple
php and mariadb

first i installed php of centos8
then i tried with php:remi-7.3

Code: Select all

dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm
dnf module list php
dnf module reset php
dnf module enable php:remi-7.3
dnf install php php-opcache php-gd php-curl php-mysqlnd php-fpm

Code: Select all

apachectl -M
Loaded Modules:
 core_module (static)
 so_module (static)
 http_module (static)
 access_compat_module (shared)
 actions_module (shared)
 alias_module (shared)
 allowmethods_module (shared)
 auth_basic_module (shared)
 auth_digest_module (shared)
 authn_anon_module (shared)
 authn_core_module (shared)
 authn_dbd_module (shared)
 authn_dbm_module (shared)
 authn_file_module (shared)
 authn_socache_module (shared)
 authz_core_module (shared)
 authz_dbd_module (shared)
 authz_dbm_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_owner_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 brotli_module (shared)
 cache_module (shared)
 cache_disk_module (shared)
 cache_socache_module (shared)
 data_module (shared)
 dbd_module (shared)
 deflate_module (shared)
 dir_module (shared)
 dumpio_module (shared)
 echo_module (shared)
 env_module (shared)
 expires_module (shared)
 ext_filter_module (shared)
 filter_module (shared)
 headers_module (shared)
 include_module (shared)
 info_module (shared)
 log_config_module (shared)
 logio_module (shared)
 macro_module (shared)
 mime_magic_module (shared)
 mime_module (shared)
 negotiation_module (shared)
 remoteip_module (shared)
 reqtimeout_module (shared)
 request_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 slotmem_plain_module (shared)
 slotmem_shm_module (shared)
 socache_dbm_module (shared)
 socache_memcache_module (shared)
 socache_shmcb_module (shared)
 status_module (shared)
 substitute_module (shared)
 suexec_module (shared)
 unique_id_module (shared)
 unixd_module (shared)
 userdir_module (shared)
 version_module (shared)
 vhost_alias_module (shared)
 watchdog_module (shared)
 dav_module (shared)
 dav_fs_module (shared)
 dav_lock_module (shared)
 lua_module (shared)
 mpm_event_module (shared)
 proxy_module (shared)
 lbmethod_bybusyness_module (shared)
 lbmethod_byrequests_module (shared)
 lbmethod_bytraffic_module (shared)
 lbmethod_heartbeat_module (shared)
 proxy_ajp_module (shared)
 proxy_balancer_module (shared)
 proxy_connect_module (shared)
 proxy_express_module (shared)
 proxy_fcgi_module (shared)
 proxy_fdpass_module (shared)
 proxy_ftp_module (shared)
 proxy_http_module (shared)
 proxy_hcheck_module (shared)
 proxy_scgi_module (shared)
 proxy_uwsgi_module (shared)
 proxy_wstunnel_module (shared)
 systemd_module (shared)
 cgid_module (shared)
 http2_module (shared)
 proxy_http2_module (shared)

Code: Select all

apachectl -M | grep -i php
==> nothing returned

when i access a php page i see the source code of php
Last edited by freaks on 2021/10/22 15:57:01, edited 1 time in total.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: enabling php7

Post by TrevorH » 2021/10/22 15:55:14

Your install list does not include php-fpm.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

freaks
Posts: 5
Joined: 2021/10/22 15:20:56

Re: enabling php7

Post by freaks » 2021/10/22 15:56:00

php-fpm is installed
( i checked )

Code: Select all

systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2021-10-22 17:47:50 CEST; 7min ago
 Main PID: 3306 (php-fpm)
   Status: "Processes active: 0, idle: 5, Requests: 0, slow: 0, Traffic: 0req/sec"
    Tasks: 6 (limit: 48918)
   Memory: 13.9M
   CGroup: /system.slice/php-fpm.service
           ├─3306 php-fpm: master process (/etc/php-fpm.conf)
           ├─3308 php-fpm: pool www
           ├─3309 php-fpm: pool www
           ├─3310 php-fpm: pool www
           ├─3311 php-fpm: pool www
           └─3312 php-fpm: pool www

oct. 22 17:47:50 frhb67331ds systemd[1]: Starting The PHP FastCGI Process Manager...
oct. 22 17:47:50 frhb67331ds systemd[1]: Started The PHP FastCGI Process Manager.

Code: Select all

php -v
PHP 7.3.31 (cli) (built: Sep 21 2021 10:24:03) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.31, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.31, Copyright (c) 1999-2018, by Zend Technologies
i disabled SELinux

Code: Select all

sestatus
SELinux status:                 disabled

list of modules

Code: Select all

ls /etc/httpd/modules/
libphp7.so            mod_authz_dbd.so        mod_dav_fs.so        mod_http2.so                mod_mpm_prefork.so     mod_proxy_wstunnel.so    mod_substitute.so
libphp7-zts.so        mod_authz_dbm.so        mod_dav_lock.so      mod_include.so              mod_mpm_worker.so      mod_ratelimit.so         mod_suexec.so
mod_access_compat.so  mod_authz_groupfile.so  mod_dav.so           mod_info.so                 mod_negotiation.so     mod_reflector.so         mod_systemd.so
mod_actions.so        mod_authz_host.so       mod_dbd.so           mod_lbmethod_bybusyness.so  mod_proxy_ajp.so       mod_remoteip.so          mod_unique_id.so
mod_alias.so          mod_authz_owner.so      mod_deflate.so       mod_lbmethod_byrequests.so  mod_proxy_balancer.so  mod_reqtimeout.so        mod_unixd.so
mod_allowmethods.so   mod_authz_user.so       mod_dialup.so        mod_lbmethod_bytraffic.so   mod_proxy_connect.so   mod_request.so           mod_userdir.so
mod_asis.so           mod_autoindex.so        mod_dir.so           mod_lbmethod_heartbeat.so   mod_proxy_express.so   mod_rewrite.so           mod_usertrack.so
mod_auth_basic.so     mod_brotli.so           mod_dumpio.so        mod_log_config.so           mod_proxy_fcgi.so      mod_sed.so               mod_version.so
mod_auth_digest.so    mod_buffer.so           mod_echo.so          mod_log_debug.so            mod_proxy_fdpass.so    mod_setenvif.so          mod_vhost_alias.so
mod_authn_anon.so     mod_cache_disk.so       mod_env.so           mod_log_forensic.so         mod_proxy_ftp.so       mod_slotmem_plain.so     mod_watchdog.so
mod_authn_core.so     mod_cache.so            mod_expires.so       mod_logio.so                mod_proxy_hcheck.so    mod_slotmem_shm.so
mod_authn_dbd.so      mod_cache_socache.so    mod_ext_filter.so    mod_lua.so                  mod_proxy_http2.so     mod_socache_dbm.so
mod_authn_dbm.so      mod_cgid.so             mod_filter.so        mod_macro.so                mod_proxy_http.so      mod_socache_memcache.so
mod_authn_file.so     mod_cgi.so              mod_headers.so       mod_mime_magic.so           mod_proxy_scgi.so      mod_socache_shmcb.so
mod_authn_socache.so  mod_charset_lite.so     mod_heartbeat.so     mod_mime.so                 mod_proxy.so           mod_speling.so
mod_authz_core.so     mod_data.so             mod_heartmonitor.so  mod_mpm_event.so            mod_proxy_uwsgi.so     mod_status.so

Code: Select all

httpd -V 
Server version: Apache/2.4.37 (centos)
Server built:   Oct 12 2021 23:35:12
Server's Module Magic Number: 20120211:83
Server loaded:  APR 1.6.3, APR-UTIL 1.6.1
Compiled using: APR 1.6.3, APR-UTIL 1.6.1
Architecture:   64-bit
Server MPM:     event
  threaded:     yes (fixed thread count)
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"
if i add this in httpd.conf

Code: Select all

LoadModule php7_module /etc/httpd/modules/libphp7.so
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

i have this error

Code: Select all

Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe.  You need to recompile PHP.

User avatar
remirepo
Posts: 447
Joined: 2014/09/21 09:07:12
Location: France
Contact:

Re: enabling php7

Post by remirepo » 2021/10/22 16:16:52

> apachectl -M | grep -i php
> ==> nothing returned

This is expected, On CentOS 8, mod_php is no more used (still provided, but only for prefork MPM), but php-fpm is used by default
and defined in the provided configuration

In /etc/httpd/conf.d/php.conf
=> SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost"


Have you restart the httpd service after php-fpm installation ?
Remi's Repository - Forum - Blog

freaks
Posts: 5
Joined: 2021/10/22 15:20:56

Re: enabling php7

Post by freaks » 2021/10/22 16:22:04

now i resolved
modifying /etc/httpd/conf.modules.d/00-mpm.conf

Code: Select all

LoadModule mpm_event_module modules/mod_mpm_event.so
With

Code: Select all

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
and adding
add the end of httpd.conf

Code: Select all

LoadModule php7_module /etc/httpd/modules/libphp7.so
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

freaks
Posts: 5
Joined: 2021/10/22 15:20:56

Re: enabling php7

Post by freaks » 2021/10/22 16:23:57

remirepo wrote:
2021/10/22 16:16:52
> apachectl -M | grep -i php
> ==> nothing returned

This is expected, On CentOS 8, mod_php is no more used (still provided, but only for prefork MPM), but php-fpm is used by default
and defined in the provided configuration

In /etc/httpd/conf.d/php.conf
=> SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost"


Have you restart the httpd service after php-fpm installation ?
yes i restarted the httpd service
yes i have this

Code: Select all

SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost"


Post Reply