Getting blank PHP page over Apache

前端 未结 8 1599
南方客
南方客 2020-12-14 10:37

In a newly setup digitalOcean cloud server (CentOS), I have installed php and Apache. The webserver is running fine:

[root@a2m5cent01 httpd]# service httpd s         


        
8条回答
  •  借酒劲吻你
    2020-12-14 11:02

    I think your php installation with apache is faulty. Thats why you can not see any php page in your webserver. Clean remove all the existing apps, like httpd,php,php-fpm,php-cli etc. and try to clean isntall in this order

    yum install httpd -y
    yum install php php-common php-cli php-gd php-curl php-fpm -y
    

    then make sure you restart yout httpd server.

    service httpd restart
    

    Install mod_fastcgi:

    yum install  mod_fastcgi
    

    Start the service:

    service php-fpm start
    

    Restart Apache:

    service httpd restart
    

    5. Configuration of Apache with PHP-FPM

    Open the fastcgi.conf file:

    nano /etc/httpd/conf.d/fastcgi.conf
    

    Add this to the end of the file:

    
                    DirectoryIndex index.html index.shtml index.cgi index.php
                    AddHandler php5-fcgi .php
                    Action php5-fcgi /php5-fcgi
                    Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
                    FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization
    
    

    After that search after "FastCgiWrapper" and make sure it's set to "off" then save the file.

    The /usr/lib/cgi-bin/ directory must exist, so we create it:

    mkdir /usr/lib/cgi-bin/ 
    

    If mod_php is installed and enabled, we need to disable it so open the configuration at /etc/httpd/conf.d/php.conf:

    nano /etc/httpd/conf.d/php.conf
    

    Comment out the AddHandler and AddType lines so it looks like here:

    #
    # PHP is an HTML-embedded scripting language which attempts to make it
    # easy for developers to write dynamically generated webpages.
    #
    
      LoadModule php5_module modules/libphp5.so
    
    
      LoadModule php5_module modules/libphp5-zts.so
    
    #
    # Cause the PHP interpreter to handle files with a .php extension.
    #
    #AddHandler php5-script .php
    #AddType text/html .php
    #
    # Add index.php to the list of files that will be served as directory
    # indexes.
    #
    DirectoryIndex index.php
    #
    # Uncomment the following line to allow PHP to pretty-print .phps
    # files as PHP source code:
    #
    #AddType application/x-httpd-php-source .phps
    

    Save the file and restart Apache:

    service httpd restart
    

提交回复
热议问题