40.apache with PHP, apache default virtual host

Source: Internet
Author: User

One, Apache and PHP combined
    • First open the local Telnet client (test port use)


      /usr/local/apache2.4/bin/apachectl start //启动apache服务
    • Modifying the Apache configuration file
    • Because PHP5 and PHP7 have been loaded before, so here's a close one, run one of them

      vim/usr/local/apache2.4/conf/httpd.conf//Modification of the following 4 places
    • ServerName in front of the # removed
    • Require all denied to Require all granted
    • Add AddType application/x-httpd-php. php
    • DirectoryIndex index.html after adding index.php



    • After saving the configuration file
      /USR/LOCAL/APACHE2.4/BIN/APACHECTL-T//test syntax is correct
      /usr/local/apache2.4/bin/apachectl Graceful//reload config file (no need to restart Apache)

      Enter the host address in the browser to see if it enters

      Unable to connect
      First Test if you can ping the pass, and then test whether Port 80 is

      The tested IP can ping, but the 80 port is not available, suspect that the server firewall does not open 80 port
      iptables -nvL   //发现确实没有80端口iptables -I INPUT -p tcp --dport 80 -j ACCEPT  //临时打开80端口

      At this time in cmd in the Telnet 192.168.127.133 80 appears black window, prove that 80 port has been measured through
      Re-enter the IP address in the browser

 vim /usr/local/apache2.4/htdocs/test.php //增加如下内容

<?php
Phpinfo ();
?>

Open http://192.168.127.133/test.php in the browser

Successful display of PHP5 configuration files

    • If Apache cannot parse PHP, but instead displays the source code, then we need to check the following items
      1. /USR/LOCAL/APACHE2.4/BIN/APACHECTL-M Check if the PHP extension is loaded, whether or not
        /usr/local/apache2.4/modules/libphp5.so file to verify that it is a PHP problem or an Apache configuration issue
      2. Check Apache configuration
        LoadModule whether to load PHP
        3. Check Apache Configuration
        AddType application/x-httpd-php. Does PHP add
        4. Check Apache configuration
        5.DirectoryIndex index.html index.php whether to add

40.apache with PHP, apache default virtual host

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.