I'll share it with you today. Build a Web server under Linux
1. Installation package
Yum Install httpd
After the installation is complete, we will see a httpd directory in the/etc directory.
Our default file location in/var/www/html
And then modify our note configuration file.
Vim/etc/httpd/conf/httpd.confservername own host Name: 80
Represents the service name for its own hostname, listening on port 80
And then we can build the file.
Vim/var/www/html/index.htmlhello
This is our homepage file.
And then we turn on my HTTP service
Service httpd Start
Then we can test it on another virtual machine.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/45/53/wKiom1PnU9rBjKcEAAD8fxMplho336.jpg "title=" Picture 1.png "alt=" Wkiom1pnu9rbjkceaad8fxmplho336.jpg "/>
This is a simple set up a Web server.
Note: If the display cannot be connected, your firewall may be blocked from the wall, you need to shut down the firewall.
2. Create file-based access control
First we need to create a directory
Cd/var/www/htmlmkdir Adminmkdir Bbsvim Bbs/index.htmlhello a vim/etc/httpd/conf/httpd.conf<directory "/var/www/ Html/admin "> Options none allowoverride authconfig authtype Basic authname" admin area. " AUTHUSERFILE/ETC/HTTPD/CONF/.HTTPASSWD Require valid-user</directory>
Then do a user name and password to store files
Htpasswd-c-m/etc/httpd/conf/.httpasswd tomtomtomhtpasswd-m/etc/httpd/conf/.httpasswd jryjryjry
Then reread the configuration file
Service httpd Reload
When we visit again, we'll pop up the username and password.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/45/54/wKioL1PnZa_xuggTAARlHU-NVTg503.jpg "title=" Picture 2.png "alt=" Wkiol1pnza_xuggtaarlhu-nvtg503.jpg "/>
3. Group-based access control configuration
On the basis of 2, we create a file
Vim/etc/httpd/conf/.httpgrouptest:tom
Add the test group, the team member is Tom, and then edit the configuration file to modify the contents of the file in the previous instance as follows
Vim/etc/httpd/conf/httpd.conf<directory "/var/www/html/admin" > Options none allowoverride authconfig AuthType Basic authname "Admin area." AUTHUSERFILE/ETC/HTTPD/CONF/.HTTPASSWD authgroupfile/etc/httpd/conf/.httpgroup Require Group Test</Director Y>
Then reread the configuration file
Service httpd Reload
And then we landed Tom and jry separately. View
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/45/57/wKioL1Pnh-fSn2sqAARjf40nC5k912.jpg "title=" Picture 3.png "alt=" Wkiol1pnh-fsn2sqaarjf40nc5k912.jpg "/>
4, Port-based virtual host
Edit the master configuration file
vim/etc/httpd/conf/httpd.conf Add listen 8080 turn on listening 8080 port #documentroot "/var/www/html" comment off the central host configuration so that the virtual host configuration will take effect < VirtualHost 172.16.249.29:80> ServerName www.jsh.com documentroot "/web/hosta" </VirtualHost> <virtualhost 172.16.249.29:8080> ServerName www.jsh.com documentroot "/web/hostb" </virtualhos T>
Configuration file Syntax check
Httpd-t
Create the corresponding directory and provide the paging file
Mkdir-pv/web/host{a,b}vim/web/hosta/index.htmlhello Hostavim/web/hostb/index.htmlhello HostB
Then reread the configuration file
Service httpd Restart
And then you can test it.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/45/56/wKiom1PnhvSg-CmPAAH-QksBnrI059.jpg "style=" float: none; "title=" Image 4.png "alt=" Wkiom1pnhvsg-cmpaah-qksbnri059.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/45/57/wKioL1PniBajO-LDAAH4mooXvWM691.jpg "style=" float: none; "title=" Image 5.png "alt=" Wkiol1pnibajo-ldaah4mooxvwm691.jpg "/>
5. IP-based virtual host
Step is the same as in the 4 instance, just change the second IP address to a different IP, and change the 8080 port to 80.