Linux Beginner Notes 04

Source: Internet
Author: User


1. HTTP protocol
Hypertext Transfer Protocol (Hypertext Transfer Protocol), HTML (Hyper Text Mark language)
The complete process of a single HTTP transaction
Client--Request message--server
Client <--Response Message--server
Web Resources
-Static resources: png,html
-Dynamic resources: jsp.php
Positioning of resources
Url:http://172.25.254.88:80/phpadmin
2. Simple application of httpd
Installation and startup
Yum Install Httpd-y
Systemctl Start httpd
Systemctl Enable httpd
Systemctl Stop Firewalld
Master configuration file/etc/httpd/conf/httpd.conf
-Modify HTTPD service default port
8080 Listen
-Modify the default publishing directory (note SELinux)
119 DocumentRoot "/westos/www/html"
124 <directory "/westos/www" >
AllowOverride None
126 Allow open access:
127 Require All granted
</Directory>
163 <ifmodule dir_module>
164 DirectoryIndex index.htmlwestos.html
165 </IfModule>
-HTTPD Help Manual
Yum Install Httpd-manual.noarch-y
Visit: http://localhost/manual
Establishment of ###-virtual host
One server, baidu.com,qq.com

1). httpd Port changed to 80, default publish directory changed back;
2). Create a directory with different domains to access different information
Mkdir/virtual/{qq.com,baidu.com}/html-p
echo "Baidu ' page" >/virtual/baidu.com/html/index.html
echo "QQ ' page" >/virtual/qq.com/html/index.html
3). Modify the configuration file under the/etc/httpd/conf.d/directory
cd/etc/httpd/conf.d/
Vim virtual.conf

1 <virtualhost*:80>
2 servername www.qq.com
3 Serveralias qq.com
4 documentroot/virtual/qq.com/html
5 Customlog "Logs/qq.com.log" combined
6 </virtualhost>
7
8 <directory/virtual/qq.com >
9 Require all granted
Ten </directory>

Vim default.conf

1 <virtualhost*:80>
2 documentroot/var/www/html
3 Customlog "Logs/default.log" combined
4 </virtualhost>
5 <directory/var/www>
6 Require all granted
7 </directory>
Systemctl Start httpd
4). Modify the SELinux label for the/virtual/directory, selinux=enforcing
Semanage fcontext-a-thttpd_sys_content_t '/virtual (/.*)? '
restorecon-fvvr/virtual/
5). Client must write parsing/etc/hosts
172.25.xx.xx www.baidu.com www.qq.com www.sina.com
###-Based on user authentication
1). Newly created user authentication Web pages that can be accessed
Mkdir/var/www/html/admin
echo "Admin ' spage" >/var/www/html/admin/index.html
2). Generate the file that corresponds to the user name and password
HTPASSWD-CM/ETC/HTTPD/.HTPASSWD Admin
HTPASSWD-M/ETC/HTTPD/.HTPASSWD Harry
3). Modify the profile file:/home/kiosk/desktop/http.md

Vim/etc/httpd/conf.d/default.conf
<virtualhost*:80>
Documentroot/var/www/html
Customlog "Logs/default.log" combined
</virtualhost>
<directory/var/www/html/admin>
AuthName "Pleaseinput Your name and passwd:"
AuthType Basic
authuserfile/etc/httpd/.htpasswd
Require Useradmin
</directory>

4). Client Access: Http://localhost/admin
###-a custom Signing certificate
* HTTP:80 https:443
1). Install the Crypto-utils package
Yum Install Crypto-utilsmod_ssl-y
2). Call Genkey to generate a self-signed certificate and private key
Genkey 172.25.254.139
3). Edit the file/etc/httpd/conf.d/ssl.conf
Sslengine on
Sslcertificatefile/etc/pki/tls/certs/172.25.254.139.crt
Sslcertificatekeyfile/etc/pki/tls/private/172.25.254.139.key
Restart the httpd service, Access https://www.baidu.com access to the default access page
4). Edit the file/etc/httpd/conf.d/virtual.conf
1 <virtualhost*:443>
2 servernamewww.qq.com
3 serveraliasqq.com
4 documentroot/virtual/qq.com/html
5 Customlog "Logs/qq.com.log" combined
6 Sslengine on
7 SSLCERTIFICATEFILE/ETC/PKI/TLS/CERTS/172.25.254.139.CRT
8sslcertificatekeyfile/etc/pki/tls/private/172.25.254.139.key
9 </virtualhost>
10
<directory/virtual/qq.com >
12require allgranted
</directory>
Restart the HTTPD service and visit https://www.qq.com to access the/virtual/qq.com/html/index.html page
* * Note: 1. The first time you visit https://www.baidu.com (or other), you need to trust the self-signed certificate;
2. Next time you do not need, if you want to trust again, you can set in the browser;
###-Web Redirection (rewrite): All 80 port requests are redirected by HTTPS
1). Edit/etc/httpd/conf/virtual.conf
<Virtualhost*:80>
ServerNamewww.qq.com
Rewriteengineon
rewriterule^ (/.*) $ https://%{http_host}$1 [redirect=301]
</Virtualhost>

2). Restart the httpd service and automatically jump to https://www.qq.com when the client accesses www.qq.com


Linux Beginner Notes 04

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.