I. HTTPD Associated PHP
HTTPD Master configuration file/usr/local/apache2.4/conf/httpd.conf
vim /usr/local/apache2.4/conf/httpd.conf
Modify the following 4 places
1 Open a virtual host
Search servername, remove the front #
- 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 hostsOne 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 graceful
Reload Configuration
mkdir -p /data/wwwroot/admin.com /data/wwwroot/123.com
Create a Site Directory
echo "just a virtualhost" > /data/wwwroot/admin.com/index.html
Edit page, the default home page of the site is index.html
echo "123.com" > /data/wwwroot/123.com/index.html
curl -x127.0.0.1:80 admin.com
This will go to visit admin.com/index.html
curl -x127.0.0.1:80 123.com
Visit www.123.com
curl -x127.0.0.1:80 www.abc.com
If 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