Building the HTTP Server (ii)

Source: Internet
Author: User
Tags install php php language browser cache

http (ii) 650) this.width=650; "src=" http://img.baidu.com/hi/jx2/j_0038.gif "alt=" j_0038.gif "/>
Apache encryption of the virtual host(https: Encrypted with CA Certificate)
<virtualhost *:80>
ServerName music.westos.com
Documentroot/var/www/virtual/music.westos.com/html
Customlog "logs/music.log" combined
</Virtualhost>
<directory "/var/www/virtual/music.westos.com/html"
Require all granted
</Directory>
<virtualhost*:443> (https is Port 443)
ServerName music.westos.com
Documentroot/var/www/virtual/music.westos.com/html
Customlog"logs/music-443.log"Combined
sslengine on
SSLCERTIFICATEFILE/ETC/PKI/TLS/CERTS/WWW.WESTOS.COM.CRT
Sslcertificatekeyfile/etc/pki/tls/private/www.westos.com.key
</Virtualhost>
(remember to empty the browser cache when Testing.)
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/8B/68/wKioL1hOBuaiK-9-AABldhYAAUk556.png-wh_500x0-wm_3 -wmp_4-s_3726145280.png "title=" 1.png "alt=" wkiol1hobuaik-9-aabldhyaauk556.png-wh_50 "/>
Page rewrite:
Vim/etc/httpd/conf.d/music.conf
<virtualhost *:80>
ServerName music.westos.com
Rewriteengine on
Rewriterule^ (/.*) $ https://%{http_host}$1
[redirect=301](move to HTTPS when HTTP is accessed)
</Virtualhost>
<directory "/var/www/virtual/music.westos.com/html" >
Require all granted
</Directory>
<virtualhost *:443> (https is Port 443)
ServerName music.westos.com
Documentroot/var/www/virtual/music.westos.com/html
Customlog "logs/music-443.log" combined
Sslengine on
Sslcertificatefile/etc/pki/tls/certs/www.westos.com.crt
Sslcertificatekeyfile/etc/pki/tls/private/www.westos.com.key
</Virtualhost>
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/8B/6B/wKiom1hOBvKDZ3OwAAGywWtqKv8645.png-wh_500x0-wm_3 -wmp_4-s_2782493156.png "title=" 2.png "alt=" wkiom1hobvkdz3owaagywwtqkv8645.png-wh_50 "/>
note: When we test HTTPS on another virtual host Test (news.westos.com) that is not set up, the page that it accesses is music.westos.com 's homepage (although there is a certificate, But no 443 ports do not set Up)
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/8B/6B/wKiom1hOBvuCPmHRAAA9fuia_64537.png-wh_500x0-wm_3 -wmp_4-s_3824035229.png "title=" 3.png "alt=" wkiom1hobvucpmhraaa9fuia_64537.png-wh_50 "/>


http only supported by default: PHP CGI HTML WSGI
Test PHP : 650) this.width=650; "src=" http://img.baidu.com/hi/jx2/j_0040.gif "alt=" j_0040.gif "/>cd/var/www/html
Vim index.php
<?php
Phpinfo ();
?>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/8B/6B/wKiom1hOBwST2l90AABCWy1Hfx0709.png-wh_500x0-wm_3 -wmp_4-s_1704494003.png "title=" 4.png "alt=" wkiom1hobwst2l90aabcwy1hfx0709.png-wh_50 "/>
Yum Install php-y ( compile and execute PHP language)
Vim/etc/httpd/conf/httpd.conf
<ifmodule dir_module>
DirectoryIndex index.php index.html
</IfModule>

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/8B/6B/wKiom1hOBw2Ccs4MAACxU-yIKsA822.png-wh_500x0-wm_3 -wmp_4-s_1911496136.png "title=" 5.png "alt=" wkiom1hobw2ccs4maacxu-yiksa822.png-wh_50 "/>
SYSTEMCLT Restart httpd


Browser testing:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/8B/68/wKioL1hOBxqjG84KAAGUJiZNPIw717.png-wh_500x0-wm_3 -wmp_4-s_2713613309.png "title=" 6.png "alt=" wkiol1hobxqjg84kaagujiznpiw717.png-wh_50 "/>

cgi:650) this.width=650; "src=" http://img.baidu.com/hi/jx2/j_0039.gif "alt=" j_0039.gif "/>
Cd/var/www/html
mkdir CGI
(cgi scripts can refer to HTTP Manual:yum install Http-manual-y)
Vim index.cgi
#!/usr/bin/perl
Print "content-type:text/html\n\n";
print ' Date ';
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/8B/6B/wKiom1hOBy3iQ-IMAABnqYWa3OY826.png-wh_500x0-wm_3 -wmp_4-s_460091863.png "title=" 7.png "alt=" wkiom1hoby3iq-imaabnqywa3oy826.png-wh_50 "/>
chmod +x index.cgi

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/8B/68/wKioL1hOBzWyMPxNAACvHVW1ttY558.png-wh_500x0-wm_3 -wmp_4-s_1657376748.png "title=" 8.png "alt=" wkiol1hobzwympxnaacvhvw1tty558.png-wh_50 "/>
Vim/etc/httpd/conf.d/default.conf

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/8B/6B/wKiom1hOBz3jjQBmAADUkXPHh88229.png-wh_500x0-wm_3 -wmp_4-s_1981965064.png "title=" 9.png "alt=" wkiom1hobz3jjqbmaadukxphh88229.png-wh_50 "/>
SELinux ( Please note the security Context)
Cd/var/www
Ls-zd cgi-bin/
Drwxr-xr-x. Root root System_u:object_r:httpd_sys_script_exec_t:s0 cgi-bin/
Semanage fcontext-a-thttpd_sys_script_exec_t '/var/www/html/cgi (/.*)? '
restorecon-fvvr/var/www/html/cgi/
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/8B/68/wKioL1hOB0SQOD5_AAID1Hsm3kY426.png-wh_500x0-wm_3 -wmp_4-s_2391540903.png "title=" 10.png "alt=" wkiol1hob0sqod5_aaid1hsm3ky426.png-wh_50 "/>
SYSTEMCLT Restart httpd

test:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/8B/68/wKioL1hOB07CG2zXAABVZz62IWw813.png-wh_500x0-wm_3 -wmp_4-s_3689997999.png "title=" 11.png "alt=" wkiol1hob07cg2zxaabvzz62iww813.png-wh_50 "/>


Build a Forum:
To download an installation package:
Discuz_x3.2_sc_utf8.zip
(yum Install Php/php-mysql-y)
Extract:
Unzip Discuz_x3.2_sc_utf8.zip
Note to read: less readme/readme.txt
chmod 777 upload/data/upload/config/
Note:SELinux ( warning mode )
172.25.254.231/upload/install
Installation:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/8B/6C/wKiom1hOB1jR3Q9sAAJBqFo6WuM881.png-wh_500x0-wm_3 -wmp_4-s_2012486756.png "title=" 12.png "alt=" wkiom1hob1jr3q9saajbqfo6wum881.png-wh_50 "/>
login:

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/8B/68/wKioL1hOB2Lh4ulZAAGyAOa8V-A764.png-wh_500x0-wm_3 -wmp_4-s_4214011863.png "title=" 13.png "alt=" wkiol1hob2lh4ulzaagyaoa8v-a764.png-wh_50 "/>

forward Proxy: It works like a Springboard. Simply put, I am a user, I cannot access a website, but I can access a proxy server (proxy server can access this site). so, I first connect the proxy server, tell him I can not access the content of the site, the proxy server to access, and then return to Me. Sometimes do not know the User's request is what, also hides the user information, depending on the agent does not tell the website (the client must be set Up) 650) this.width=650; "src=" http://img.baidu.com/hi/jx2/j_0033. GIF "alt=" j_0033.gif "/>

Simulate tests with two virtual machines:
Add a network card to the Server:
ip1:172.25.254.231 (same network segment with real Machine)
ip2:172.25.31.10 (same Network segment as DESKTOP)

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/8B/6C/wKiom1hOB2-igKR4AAJ1YGsELmU138.png-wh_500x0-wm_3 -wmp_4-s_4192541037.png "title=" 14.png "alt=" wkiom1hob2-igkr4aaj1ygselmu138.png-wh_50 "/>
Inside the desktop
ip:172.25.31.10
Real Machine ip:172.25.254.31
Test: server can ping the real machine
Desktop can not ping the real machine

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/8B/6C/wKiom1hOB3mQ9PQXAAK8nNZgmPo866.png-wh_500x0-wm_3 -wmp_4-s_2817669492.png "title=" 15.png "alt=" wkiom1hob3mq9pqxaak8nnzgmpo866.png-wh_50 "/>
Server: ( The virtual machine that can ping the telepresence machine)
Yum Install Squid-y
Vim/etc/squid/squid.conf
Http_access Allow all
Cache_dir UFS/VAR/SPOOL/SQUID 100 16 256

650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M02/8B/6C/ Wkiom1hob4bheqnxaajo-0li2uo679.png-wh_500x0-wm_3-wmp_4-s_3066664702.png "title=" 16.png "alt=" Wkiom1hob4bheqnxaajo-0li2uo679.png-wh_50 "/>

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M01/8B/68/wKioL1hOB5DQ_ Gufaad_y4ec5pq284.png-wh_500x0-wm_3-wmp_4-s_949695238.png "title=" 17.png "alt=" wkiol1hob5dq_gufaad_ Y4ec5pq284.png-wh_50 "/>
systemctl start squid
Test: a virtual machine that does not ping can also access the Apache Web page of the real machine (at this point the desktop or ping does not pass the real machine ~)
650) this.width=650; "src=" http://s4.51cto.com/ Wyfs02/m02/8b/6c/wkiom1hob5iq48vuaacwr1wpchy766.png-wh_500x0-wm_3-wmp_4-s_3594587169.png "title=" 18.png "alt=" Wkiom1hob5iq48vuaacwr1wpchy766.png-wh_50 "/>

Reverse proxy: (the server does not install Https) enterprises do, The client does not make any settings specifically tell the parent server what to take
Squid (mostly accelerated)
Yum install squid-y
vim/etc/squid/squid.conf
cache_peer 172.25.254.4 parent80 0 no-query

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/8B/6C/wKiom1hOB63xssT0AAF961VK_4E636.png-wh_500x0-wm_3 -wmp_4-s_3120376543.png "title=" 19.png "alt=" wkiom1hob63xsst0aaf961vk_4e636.png-wh_50 "/>
Systemctl start Squid
Netstat-antlpe | grep 80
TCP 0 0 172.25.254.231:22 172.25.254.31:48992 established 0 28081 1585/sshd: [email PR otected]
TCP6 0 0::: +:::* LISTEN 0 191797 4659/(squid-1)
TCP6 0 0:: 1:6010:: 1:38780 established 0 28373 1585/sshd: [email PR otected]
TCP6 0 0:: 1:38780:: 1:6010 established 0 28372 1621/dbus-launch
Attention:There's no httpd in the Server. this 80 port is Squid-open.
Test in another virtual machine:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/8B/68/wKioL1hOB8LinzUhAACCfhb2N7A134.png-wh_500x0-wm_3 -wmp_4-s_2529094891.png "title=" 20.png "alt=" wkiol1hob8linzuhaaccfhb2n7a134.png-wh_50 "/>
Reverse proxy polling mechanism: 650) this.width=650; "src=" http://img.baidu.com/hi/jx2/j_0042.gif "alt=" j_0042.gif "/>cache_peer 172.25.254.4 Parent 0 no-query Originserver Round-robin name=web1
Cache_peer 172.25.254.3 Parent 0 no-query originserver Round-robin name=web2
Cache_peer_domain Web1 web2650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/8B/6C/wKiom1hOB9jz9jqyAAFNzvAOYxM532.png-wh_500x0-wm_3 -wmp_4-s_2952214839.png "title=" 21.png "alt=" wkiom1hob9jz9jqyaafnzvaoyxm532.png-wh_50 "/>www.taobao.com


Systemctl Restart Squid


Test on another machine: www.taobao.com
Refresh two times: get a different page




650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/8B/68/wKioL1hOB-Pw0ElFAABE5XiKOxg761.png-wh_500x0-wm_3 -wmp_4-s_1721831935.png "style=" float:none; "title=" 22.png "alt=" wkiol1hob-pw0elfaabe5xikoxg761.png-wh_50 "/>

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/8B/6C/wKiom1hOB-SyCcUXAABnW5kfm5c137.png-wh_500x0-wm_3 -wmp_4-s_3421774497.png "style=" float:none; "title=" 23.png "alt=" wkiom1hob-syccuxaabnw5kfm5c137.png-wh_50 "/>
















Building the HTTP Server (ii)

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.