ENGINEER1.2
HTTP Service Basics
Web services based on B/S architecture
Provide pages----the service side;
----browser to download and display the page;
--------------------------------------------------------------------------------------------------------------- -------------------------------
Rapid deployment of standalone WAB host
Installing httpd
#yum-y Install httpd
2 Start the HTTPD service and set the boot
#systemctl Restart httpd
#systemctl Enable httpd
3. Write a webpage:
#echo MY First WEB >/var/www/htm/index.html
On desktop:
#elinks-dump 172.25.0.11
------Servername: DNS name registered on this site
vim/etc/httpd/conf/httpd.conf //Modify host configuration file
Vim Finder/ServerName
ServerName server0.example.com:80
2. Restart the HTTPD service:
#systemctl Restart httpd
On desktop:
#elinks-dump server0.example.com
To visit a Web site:
----documentroot: Web root directory (/var/www/html)
Service side:/var/www/html/
To modify the contents of a master file #vim/etc/httpd/conf/httpd.conf
DocumentRoot "/VAR/WWW/ABC"
2. Create a directory #mkdir/VAR/WWW/ABC
3. Restart httpd service #systemctl restart httpd
4. Writing Web page files
#echo wo shi abc >/var/www/abc/index.html
On desktop
#elinks-dump server0.example.com
Virtual Web Host
Purpose: Save money
Multiple different Web sites are provided by the same server.
How to differentiate:
Domain-based virtual machines
Port-based virtual machines
IP address-based virtual machines
Help Document:/usr/share/doc/httpd-2.4.6/httpd-vhosts.conf
Establish a profile from a configuration file
#vim/etc/httpd/conf.d/nsd01.conf
<virtualhost *: 80>
Documentroot/var/www/test
ServerName www0.example.com
</VirtualHost>
<virtualhost *: 80>
Documentroot/var/www/nsd
ServerName webapp0.example.com
</VirtualHost>
2. Create the catalogue and the corresponding Web content
#echo wo shi Test >/var/www/test/index.html
#echo wo shi nsd >/var/www/nsd/index.html
3. Restart HTTPD Service
#systemctl Restart httpd
Virtual Web, all sites must use virtual addresses
--------------------------------------------------------------------------------------------------------------- ------------
Web Access Control
To configure directory permissions:
Folder permissions:
Permission control for the DocumentRoot Web directory:
---httpd running identity: Apche
What network resources can---extract
#vim/etc/httpd/conf/httpd.conf
User Apche
Group Apache
Client Address Restrictions:
Use <Directory> Configure sections
---Each file home automatically inherits ACL access from its parent directory
---unless explicitly set for subdirectories
Prohibit any client access
<dirctory/>
Require all denied
</Dirctory>
Allow any client access
<dirctory "/var/www/html" >
Require all granted
</Dirctory>
Only partial client access allowed
<Dirctory/var/www/html/private>
Require IP 127.0.0.1
</Dirctory>
--------------------------------------------------------------------------------------------------------------- -----------------------
SELinux Policy Protection
Security context (with the same label)
#chcon-R--reference=/var/www/webroot
--------------------------------------------------------------------------------------------------------------- ------------------------
Using custom Web Access
Modifying a configuration file
#vim/etc/httpd/conf.d/nsd01.conf
<virtualhost *:80>
Document/webroot
ServerName server0.example.com
</VirtualHost>
2. Create a directory and a Web page file
#mkdir/webroot
#echo wo shi Webroot >/webroot/index.html
3. Modify the Access control configuration file
#vim/etc/httpd/conf.d/nsd02.conf
<directory "/webroot" >
Require all granted
</Directory>
4. Modify the SELinux label value:
#chcon-R--reference=/var/www/webroot
5. Restart the HTTPD service:
#systemctl Restart httpd
6. On the desktop:
#elinks-dumps server0.example.com
This article is from the Linux OPS blog, so be sure to keep this source http://13401400.blog.51cto.com/13391400/1978949
Linux Operational ENGINEER1.2 (HTTP service Basics, Web content access, secure Web)