In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
It is believed that many inexperienced people don't know what to do about the steps of building HTTP server in Linux system. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
HTTP server refers to the website server, which can process requests from Web clients such as browsers and return corresponding responses. It can also place website files for the whole world to browse. Introduction to http Services:
HTTP is the abbreviation of Hypertext transfer Protocol (HyperText Transfer Protocol), which is based on the application layer protocol of Cplink S architecture.
Friends who are familiar with this part of the content should know that TCP/IP protocol is the content of the protocol layer, it defines the basic protocol of communication between computers, we are familiar with HTTP, FTP, Telnet and other protocols are based on the TCP/IP protocol.
In HTTP protocol, the client is responsible for initiating a Request, which contains the request method, URL, protocol version and other information. After receiving the Request, the server will return a Response, and the Response contains status code, response content and other information. This model is called request / response model.
The http service of the Linux system is installed through rpm, and there may be security problems when installing redundant modules, so we choose to install the Apache service by compiling and installing.
one。 Compile and install the Apache package first we uninstall the native httpd service rpm-e httpd-- nodeps 1 and then compile and install
1) the first step is to unlock the source code package tar zxf httpd-2.2.17.tar.gz-C / usr/src/ 12) the second step is to configure the selected installation function and installation directory and other information such as cd / usr/src/httpd-2.2.17/. / configure-- prefix=/usr/local/httpd-- enable-so-- enable-rewrite-- enable-charset-lite-- enable-cgi 123) the third step is to compile and configure Information generation executable binaries make 14) step 4 install make install 1 II. Optimize the execution path ln-s / usr/local/httpd/bin/* / usr/local/bin/ ls-l / usr/local/bin/httpd / usr/local/bin/apachectl (view soft links) 12 as shown in the figure
three。 Add the httpd system service cp / usr/local/httpd/bin/apachectl / etc/init.d/httpd vi / etc/init.d/httpd 12 in front of the two lines as shown in the figure to change the execution environment of the first line
Save and exit after completion
Chkconfig-- add httpd (adjust startup level) chkconfig-- list httpd (view startup status) 123 as shown in the figure
At this point, we will complete the configuration and open the browser to enter 127.0.0.1. We can see that the interface here is the default directory of the http service.
Httpd service access control in order to make our page more secure, we configure user authorization restrictions, that is, users need a password to access our interface.
Add user cd / usr/local/httpd/bin switch directory htpasswd-c / usr/local/httpd/conf/.htpass webadmin 12 add a user whose user name is webadmin requires the (- c) parameter when adding a user for the first time, which can be omitted later
View the user record file cat / usr/local/httpd/conf/.htpass: user name on the left and password on the right (encrypted display) 12
Add authorization vi / usr/local/httpd/conf/httpd.conf 1 to the website directory by adding these four lines in the location shown in the figure, note that the top is inside, save and exit.
Restart the service service httpd restart 1 test to check 127.0.0.1 with the browser again and find that the user name and password are required for access. At this time, we can enter the user name and password we added before, which can effectively prevent outsiders from viewing our network, and it is also a security defense measure.
The directory structure of httpd service. Let's introduce the directory structure service directory: / usr/local/httpd/
Main configuration file: / usr/local/httpd/conf/httpd.conf web page directory: / usr/local/httpd/htdocs/ service script: / usr/local/httpd/bin/apachectl executor: / usr/local/httpd/bin/httpd access log: / usr/local/httpd/log/access_log 123456789httpd.conf configuration file commonly used global configuration parameters ServerRoot: service directory ServerAdmin: administrator mailbox User: running the service User identity Group: the group identity of the service running ServerName: the domain name of the website server DocumentRoot: the root directory of the web document Listen: the listening IP address, Port number PidFile: file that holds the PID number of the httpd process DirectoryIndex: default index page file ErrorLog: location of error log file CustomLog: location of access log file LogLevel: level of logging Default is warn Timeout: network connection timeout, default is 300s KeepAlive: whether to keep connection, optional On or Off MaxKepAliveRequests: maximum number of files requested per connection KeepAliveTimeout: timeout when keeping connected Include: other configuration files that need to be included 1234567891011121314151617 area configuration item Options FollowSymLinks # control option Allow the use of symbolic links AllowOverride None # do not allow overrides in implicit control files to configure Order deny,allow # Application order of access control policies Deny from all # prohibits anyone from accessing this area what is a Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-tasking, multi-threading and multi-CPU operating system Using Linux, you can run major Unix tools, applications, and network protocols.
After reading the above, have you mastered the steps of building a HTTP server in the Linux system? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.