Linux Learning Summary (33) Lamp httpd associated PHP

Source: Internet
Author: User
Tags define dns

I. HTTPD Associated PHP

HTTPD Master configuration file/usr/local/apache2.4/conf/httpd.conf
vim /usr/local/apache2.4/conf/httpd.confModify the following 4 places
1 Open a virtual host
Search servername, remove the front #

  1. Then find require all denied, modified to granted, which means to change the deny request to allow.

    3 Search Tube Detection AddType find AddType application/x-gzip. gz. tgz add a line below it AddType application/x-httpd-php. php

    4. Then search for the index.html to find the following paragraph, add index.php after it
    <ifmodule dir_module>
    DirectoryIndex index.html
    </IfModule>
    /usr/local/apache2.4/bin/apachectl -t //测试语法/usr/local/apache2.4/bin/apachectl start //启动服务netstat -lnp |grep 80  //查看启动情况curl localhost   //测试网站解析


    vim/usr/local/apache2.4/htodcs/test.php//Add the following:
    <?php
    echo Hello php;
    ? >curl localhost/test.php

    Two virtual hosts

    One server can access multiple Web sites, each of which is a virtual host
    Concept: Domain name (hostname), DNS, resolving domain name, hosts
    Any domain name resolves to this machine, the virtual host that can be accessed is the default virtual host
    vim/usr/local/apache2/conf/httpd.conf//Search Httpd-vhost, remove #, meaning to open a virtual host call, so httpd master configuration file will invoke the virtual host configuration file, The httpd-vhost.conf file as shown below

    vim /usr/local/apache2/conf/extra/httpd-vhosts.conf //改为如下<VirtualHost *:80>DocumentRoot "/data/wwwroot/admin.com"ServerName admin.comServerAlias www.admin.comErrorLog "logs/admin.com-error_log"CustomLog "logs/admin.com-access_log" common</VirtualHost><VirtualHost *:80>DocumentRoot "/data/wwwroot/123.com"ServerName 123.comServerAlias www.123.com</VirtualHost>


    /usr/local/apache2/bin/apachectl –t
    /usr/local/apache2/bin/apachectl gracefulReload Configuration
    mkdir -p /data/wwwroot/admin.com /data/wwwroot/123.comCreate a Site Directory
    echo "just a virtualhost" &gt; /data/wwwroot/admin.com/index.htmlEdit page, the default home page of the site is index.html
    echo "123.com" &gt; /data/wwwroot/123.com/index.html
    curl -x127.0.0.1:80 admin.comThis will go to visit admin.com/index.html
    curl -x127.0.0.1:80 123.comVisit www.123.com
    curl -x127.0.0.1:80 www.abc.comIf an unspecified website jumps directly to amdin.com, then he is the default virtual host. According to the order of the configuration files.

    You can also enter IP access in the browser to access the default virtual host. To access 123.com, you can define DNS in WinDOS C:\Windows\System32\drivers\etc\hosts, such as adding
    192.168.226.130 123.com

Linux Learning Summary (33) Lamp httpd associated 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.