skip to Main Content

I updated my server with php 7.4 however it created some issues my website couldn’t be live again, the issue started after resinstalling httpd or installing httpd-devel not sure
I have bitrix managing my websites however the application is also hosted on the server and not deployed whenever I tried to access it, it downloads the php file, I need at least that to be running again

Environment :

Centos 7

PHP7.4

httpd -v : Server version: Apache/2.4.6 (CentOS)

nginx -v : nginx version: nginx/1.16.1

I tried with "AddType" and "AddHandler" but no chance

I tried removing htaccess and recreating same issue

I can’t find LoadModule php so module, even in module files so I haven’t tried that option or I don’t know where to start

Example of conf file of one of my website :

# Ansible managed
# site: medrec.org
<VirtualHost 127.0.0.1:8887>
    ServerName  medrec.org
        ServerAlias www.medrec.org
        ServerAdmin webmaster@localhost
        DocumentRoot  /home/bitrix/ext_www/medrec.org/public

        ErrorLog logs/medrec_error_log
        LogLevel warn
        CustomLog logs/medrec_access_log combined

        <IfModule mod_rewrite.c>
                #Nginx should have "proxy_set_header HTTPS YES;" in location
                RewriteEngine On
                RewriteCond %{HTTP:HTTPS} =YES
                RewriteRule .* - [E=HTTPS:on,L]
        </IfModule>




        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        <DirectoryMatch .*.svn/.*>
        Require all denied
        </DirectoryMatch>

        <DirectoryMatch .*.git/.*>
                 Require all denied
        </DirectoryMatch>

        <DirectoryMatch .*.hg/.*>
                 Require all denied
        </DirectoryMatch>

        <Directory /home/bitrix/ext_www/medrec.org/public>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                DirectoryIndex index.php index.html index.htm
                AddType  application/x-httpd-php         .php
                AddType  application/x-httpd-php-source  .phps
        Require all granted

        #php_admin_value session.save_path /tmp/php_sessions/ext_www/medrec.org
        #php_admin_value upload_tmp_dir    /tmp/php_upload/ext_www/medrec.org
        </Directory>
<Directory /home/bitrix/ext_www/medrec.org/bitrix/cache>
                AllowOverride none
        Require all denied
        </Directory>

        <Directory /home/bitrix/ext_www/medrec.org/bitrix/managed_cache>
                AllowOverride none
        Require all denied
        </Directory>

        <Directory /home/bitrix/ext_www/medrec.org/bitrix/local_cache>
                AllowOverride none
        Require all denied
        </Directory>

        <Directory /home/bitrix/ext_www/medrec.org/bitrix/stack_cache>
                AllowOverride none
        Require all denied
        </Directory>
<Directory /home/bitrix/ext_www/medrec.org/upload>
                AllowOverride none
                #AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
                AddType  application/x-httpd-php         .php
                AddType  application/x-httpd-php-source  .phps
                #php_value engine off
        </Directory>

        <Directory /home/bitrix/ext_www/medrec.org/upload/support/not_image>
                AllowOverride none
        Require all denied
        </Directory>

        <Directory /home/bitrix/ext_www/medrec.org/bitrix/images>
                AllowOverride none
                #AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
                AddType  application/x-httpd-php         .php
                AddType  application/x-httpd-php-source  .phps
                #php_value engine off
        </Directory>

        <Directory /home/bitrix/ext_www/medrec.org/bitrix/tmp>
                AllowOverride none
                AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
                #php_value engine off
        </Directory>

</VirtualHost>

httpd.conf

ServerTokens OS
ServerRoot "/etc/httpd"
PidFile run/httpd.pid

# Timeout: The number of seconds before receives and sends time out.

Timeout 120

# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.

KeepAlive Off

# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.

MaxKeepAliveRequests 100

# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.

KeepAliveTimeout 15

<IfModule worker.c>
        StartServers         2
        MaxClients         150
        MinSpareThreads     25
        MaxSpareThreads     75
        ThreadsPerChild     25
        MaxRequestsPerChild  0
</IfModule>

# Active module

Include conf.modules.d/*.conf
<IfModule setenvif_module>
    SetEnvIf X-Forwarded-Scheme https HTTPS=on
    SetEnvIf X-Forwarded-Proto https HTTPS=on
</IfModule>

#
# Disabled standart config
#

#Include conf.d/*.conf

#
# BitrixEnv include configs
#

Include bx/conf/*.conf
Include bx/custom/*.conf

User bitrix
Group bitrix

ServerAdmin root@localhost

UseCanonicalName Off

DocumentRoot "/home/bitrix/www"

<Directory />
    Options FollowSymLinks
        AllowOverride None
</Directory>
<IfModule mod_userdir.c>
        UserDir disable
</IfModule>

DirectoryIndex index.html
AccessFileName .htaccess

<Files ~ "^.ht">
    Require all denied
</Files>

TypesConfig /etc/mime.types
#ForceType text/plain
<IfModule mod_mime_magic.c>
        MIMEMagicFile conf/magic
</IfModule>

HostnameLookups Off
ErrorLog logs/error_log

LogLevel warn
LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
LogFormat "%h %l %u %t "%r" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog logs/access_log combined

ServerSignature On

<IfModule mod_dav_fs.c>
        # Location of the WebDAV lock database.
        DAVLockDB /var/lib/dav/lockdb
</IfModule>

<IfModule mod_autoindex.c>
        IndexOptions FancyIndexing VersionSort NameWidth=* HTMLTable
        IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
</IfModule>

AddLanguage ca .ca
(Laguages ...)

#LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
#ForceLanguagePriority Prefer Fallback

AddDefaultCharset UTF-8

AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz

AddHandler type-map var
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml


BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4.0" force-response-1.0
BrowserMatch "Java/1.0" force-response-1.0
BrowserMatch "JDK/1.0" force-response-1.0

#BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
#BrowserMatch "MS FrontPage" redirect-carefully
#BrowserMatch "^WebDrive" redirect-carefully
#BrowserMatch "^WebDAVFS/1.[0123]" redirect-carefully
#BrowserMatch "^gnome-vfs/1.0" redirect-carefully
#BrowserMatch "^XML Spy" redirect-carefully
#BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully

Update
Liste of confs in conf.modules.d

enter image description here

15-php.conf

enter image description here

Modules

enter image description here

2

Answers


  1. I have also faced similar issues
    Try

    sudo apt-get install php7.x libapache2-mod-php7.x 
    

    will install everything you need and will start the server with support for PHP.

    verify if php module is loaded correctly using:

    a2query -m php7.x
    

    if not , load it using

    sudo a2enmod php7.x
    

    Type the following command:

    sudo systemctl restart nginx
    

    OR

    sudo service nginx restart
    

    Also

    The correct AddType for php is application/x-httpd-php

    AddType  application/x-httpd-php         .php
    AddType  application/x-httpd-php-source  .phps
    
    Login or Signup to reply.
  2. Your modules seems to be messed up.

    Check if php7 module is loaded:

    # apachectl -M | grep -i php
    php7_module (shared)
    

    In your httpd.conf, php7 modules are loaded by including existings files in conf.modules.d directory.

    The libphp7-zts.so means Thread Safe.
    And your Apache don’t seems to like it.

    You are only setting MIME types with lines below:

    AddType  application/x-httpd-php         .php
    AddType  application/x-httpd-php-source  .phps
    

    To handle PHP, you need to set handlers.

    So replace your 15-php.conf file with this:

    LoadModule php7_module modules/libphp7.so
    <FilesMatch ".+.ph(ar|p|tml)$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search