Apache and PHP combined (configuration httpd support PHP)

Source: Internet
Author: User

Apache and PHP Combine

Configuring HTTPD support PHP

Modify the configuration document

Vim/usr/local/apache2.4/conf/httpd.conf

The first step:

Cancel Comment

ServerName www.example.com:80
Step Two:

Change require all denied to require all granted

<Directory />    AllowOverride none    Require all granted</Directory>
Step Three:

Add a line AddType application/x-httpd-php. php

    AddType application/x-compress .Z    AddType application/x-gzip .gz .tgz    AddType application/x-httpd-php .php
Fourth Step:

Add Index page index.php
Add an index page after DirectoryIndex index.html index.php

<IfModule dir_module>    DirectoryIndex index.html index.php</IfModule>
Configuration effective check for configuration file httpd.cnf syntax is correct
/usr/local/apache2.4/bin/apachectl -t
Reload the configuration file
/usr/local/apache2.4/bin/apachectl graceful
Detect if PHP is parsing properly

Create a new PHP file

vi /usr/local/apache2.4/htdocs/1.php代码:<?phpphpinfo();?>

Browser open Access 192.168.188.2/1.php
If the display is a picture table file is normal;
If the code is displayed as an error;

Error checking procedure: 1. Check if PHP module is loaded
/usr/local/apache2.4/bin/apachectl -M

See if there is a php5_module (shared)

If there are no PHP5 modules, check for PHP5 module files libphp5.so

ls /usr/local/apache2.4/modules/libphp5.so

If you have a libphp5.so file, check that the HTTPD.CNF configuration file is loaded

LoadModule php5_module        modules/libphp5.so
2. Check if PHP is added
AddType application/x-httpd-php .php
3. Check whether to increase the index page index.php
DirectoryIndex index.html index.php

Apache and PHP combined (configuration httpd support PHP)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.