Author Topic: PHP files are downloaded instead of parsing  (Read 2117 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
PHP files are downloaded instead of parsing
« on: March 03, 2018, 01:10:02 PM »
Hello
i installed cwp to fresh vps server. My problem is that all php files are not running. Instead they are downloaded.
I tried fix permission and rebuild hosts but nothing.
The permissions seems ok. Because i can run other files in same folder
eg. mysite.com/index.html is running but if you click mysite.com/index.php or other php file, the browser just download that file
I tried different versions of php (5.6, 7, 7.2) but nothing. install apache only and other versions with nginx+ varnish but still same problem. I add some apachehandlers to httpd.conf but nothing
(p.s. i always erase browser cache and cookies and restart apache and other services before any test)
Any help please

Offline
***
Re: PHP files are downloaded instead of parsing
« Reply #1 on: March 03, 2018, 10:41:18 PM »
What's the output of /etc/nginx/sites-available/default file?
https://www.24x7servermanagement.com/
Server Management, Server Security, Server Monitoring.
India's Leading Managed Service Provider !!

Offline
*
Re: PHP files are downloaded instead of parsing
« Reply #2 on: March 06, 2018, 01:57:45 PM »
at /etc/nginx there is no "sites-available" folder
i use centos 7.4
my domain folder is /home/MYSITE/public_html
the /etc/httpd/conf/httpd.conf is
----------
ServerRoot "/etc/httpd"
Listen 80

Include conf.modules.d/*.conf

User apache
Group apache

ServerAdmin root@localhost

ServerName 195.201.4.203:80

<Directory />
    AllowOverride none
    Require all denied
</Directory>


DocumentRoot "/var/www/html"

<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

<Directory "/home/mylotgr/public_html">
    AllowOverride all
    # Allow open access:
order allow,deny
allow from all
    Require all granted
</Directory>

# Further relax access to the default document root:
<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
DirectoryIndex index.html index.html.var index.phtml index.php index.phps


#AddType application/x-tar .tgz

# added for PHP
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

<Files ".ht*">
    Require all denied
</Files>


ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
 
    TypesConfig /etc/mime.types
    AddType application/x-compress .Z
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    #
    # The mod_mime_magic module allows the server to use various hints from the
    # contents of the file itself to determine its type.  The MIMEMagicFile
    # directive tells the module where the hint definitions are located.
    #
    MIMEMagicFile conf/magic
</IfModule>

EnableSendfile on

# Supplemental configuration
#
# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf

# PHP 7 specific configuration
<IfModule php7_module>
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    <IfModule dir_module>
        DirectoryIndex index.html index.php
    </IfModule>
</IfModule>

LoadModule php5_module "/usr/lib64/php"

AddType application/x-httpd-php .phtml
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddHandler application/x-httpd-php72 .php

<FilesMatch \.php$>
​SetHandler application/x-httpd-php
​</FilesMatch>

DirectoryIndex index.html index.html.var index.phtml index.php index.phps


# added for PHP
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps