11.14-15 Apache and PHP combined
HTTPD Master Profile/usr/local/apache2.4/conf/httpd.confvim/usr/local/apache2.4/conf/httpd.conf//Modify the following 4 places servername//get rid of # Note, 194 lines ServerName Www.example.com:80Require all granted//modify denied to granted <directory/> allowoverride None Require all granted </Directory> addtype application/x-httpd-php. PHP// Add this line AddType application/x-compress. Z AddType application/x-gzip. gz. tgz addtype application/x-httpd-php. Phpdirectoryindex index.html index.ph P//This line adds index.php <ifmodule dir_module> directoryindex index.html index.php </IFMODULE&G T;/USR/LOCAL/APACHE2.4/BIN/APACHECTL-T//Test syntax/usr/local/apache2.4/bin/apachectl graceful///usr/local/apache2.4/ Bin/apachectl Start//Startup service Netstat-lntpcurl localhostvim/usr/local/apache2.4/htdocs/test.php//Add the following content <?phpecho 123;curl localhost/test.phpiptables-i input-p TCP--dport 80-j ACCEPT [[email protected] ~]#/usr/loCal/apache2.4/bin/apachectl graceful httpd not running, trying to start/usr/local/apache2.4/bin/apachectl: line 79:4 343-Segment Error $HTTPD-K $ARGV to report a mistake, comment out one of the following LoadModule php5_module modules/libphp5.so #LoadModule Php7_module modules/libphp7.so [[email protected] ~]# ls/usr/local/apache2.4/htdocs/index.html PHP Information content [[email protected] ~]# vim vim/usr/local/apache2.4/htdocs/info.php <?php phpinfo ();
11.16-17 Apache Default virtual host
A server can access multiple Web sites, each site is a virtual host concept: Domain name (hostname), DNS, resolve domain name, hosts any domain name resolves to this machine, can access the virtual host is the default virtual host vim/usr/local/apache2.4/ conf/httpd.conf//Search Httpd-vhost, remove # # Virtual hosts Include Conf/extra/httpd-vhosts.confvim/usr/local/apa che2.4/conf/extra/httpd-vhosts.conf//change to the following <virtualhost *:80> ServerAdmin [email protected] DocumentRoot "/data/wwwroot/abc.com" ServerName abc.com serveralias www.abc.com www.123. COM errorlog "Logs/abc.com-error_log" Customlog "Logs/abc.com-access_log" Common </virtual host> <virtualhost *:80> documentroot "/data/wwwroot/111.com" ServerName 111.com Errorlog "Logs/111.com-error_log" Customlog "Logs/111.com-access_log" Common </virtualhost> ; [[email protected] ~] #/usr/local/apache2.4/bin/apachectl-t AH00112:Warning:DocumentRoot [/data/wwwroot/abc.com] does not existAH0011 2:warning: DocumentRoot [/data/wwwroot/111.com] does not existsyntax ok[[email protected] ~]]#/usr/local/apache2.4/bin/ Apachectl GracefulAH00112:Warning:DocumentRoot [/data/wwwroot/abc.com] does not existAH00112:Warning:DocumentRoot [/ Data/wwwroot/111.com] does not existcurl-x192.168.104.160:80 [[email protected] ~]# mkdir/data/wwwroot/[[email& Nbsp;protected] ~]# mkdir/data/wwwroot/abc.com[[email protected] ~]# mkdir/data/wwwroot/111.com[[email Protected] ~]# vim/data/wwwroot/abc.com/index.php[[email protected] ~]# vim/data/wwwroot/111.com/index.php[[ Email protected] ~]#/usr/local/apache2.4/bin/apachectl-tsyntax ok[[email protected] ~]#/usr/local/ Apache2.4/bin/apachectl graceful[[email protected] ~]# curl-x192.168.104.160:80 www.abc.comabc.com[[email protected][[email protected] ~]# curl-x192.168.104.160:80 abc.comabc.com[[email protected] ~]# Curl -x192.168.104.160:80 111.com111.com[[email protected] ~]#
2018-04-12 Linux Learning