In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
I. brief introduction of Apache Web server
1.Apache Web is currently the number one Web server software used in the world. Apache server is characterized by simple use, high speed, stable performance, and can be used as a load balancing and proxy server.
two。 In enterprises, the most commonly used processing modules of Apache are Prefork MPM and Worker MPM,Event MPM, and the default Apache processing module is Prefork MPM.
3.Prefork MPM working principle: control process Master in the initial establishment of "StartServers" processes, in order to meet the MinSpareServers setting of the minimum idle process, so you need to create the first idle process, wait a second, continue to create two, in turn by increasing the number of exponential processes, up to 32 idle processes per second at the same time, until the value of at least two MinSpareServers settings is met. The pre-derived mode of Apache does not need to request to generate new processes when it arrives, thus reducing system overhead to increase performance. The engine provides external services based on multi-process mode, each process has only one thread, and each process can only maintain one connection at a certain time. The advantage is stability, but each process occupies relatively high memory.
How 4.Worker MPM works: control process Master initially set up "StartServers" processes, each process will create the number of threads set by ThreadsPerChild, multiple threads share the process memory space, while each thread independently processes the user's Http requests. This mode uses multiple processes, each process includes multiple threads, each thread can only maintain one connection at a certain time, and the amount of memory is relatively small, so it is suitable for large-scale development, high-traffic Web servers. The disadvantage of Worker MPM is that one thread crashes and the entire process dies along with any of its threads.
II. Installation of Apache Web server
[root@localhost tools] # wget http://archive.apache.org/dist/httpd/httpd-2.4.29.tar.gz
[root@localhost tools] # tar-xzvf httpd-2.4.29.tar.gz
[root@localhost tools] # cd httpd-2.4.29
[root@localhost httpd-2.4.29] # yum install apr apr-devel apr-util apr-util-devel-y
[root@localhost httpd-2.4.29] # / configure-- prefix=/usr/local/apache2/-- enable-rewrite-- enable-so
[root@localhost httpd-2.4.29] # make # compilation
[root@localhost httpd-2.4.29] # make install # installation
[root@localhost local] # / usr/local/apache2/bin/apachectl start
Test:
Third, Apache virtual host enterprise application
There are three ways to configure Web virtual hosts:
1. Based on a single IP with multiple socket ports
two。 One port based on multiple IP addresses
3. Different domain names based on a single IP port.
The actual combat steps are as follows:
[root@localhost conf] # pwd
/ usr/local/apache2/conf
[root@localhost conf] # vim httpd.conf
.
# Virtual hosts
Include conf/extra/httpd-vhosts.conf # just get rid of the previous #
.
[root@localhost extra] # pwd
/ usr/local/apache2/conf/extra
[root@localhost extra] # vim httpd-vhosts.conf
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/ usr/local/apache2//docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/ usr/local/apache2//docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
Create the www.sky9890.com and www.sky9899.com publishing directories, restart the Apache service, and create index.html pages, respectively, with the following commands:
[root@localhost extra] # mkdir-p / usr/local/apache2/htdocs/ {sky9890,sky9899} /
[root@localhost extra] # echo "www.sky9890.com Pages" > / usr/local/apache2/htdocs/sky9890/index.html
[root@localhost extra] # echo "www.sky9899.com Pages" > / usr/local/apache2/htdocs/sky9899/index.html
Modify the configuration file: [root@localhost extra] # vim httpd-vhosts.conf
# virtual machine port 80
ServerAdmin 553752017@qq.com # administrator mailbox
DocumentRoot "/ usr/local/apache2/htdocs/sky9890" # virtual host release directory.
ServerName www.sky9890.com # full domain name of virtual host
# ServerAlias www.dummy-host.example.com # alias
RewriteCond% {HTTP_HOST} www.sky9890.com [NC,OR] # NC means case-insensitive, OR expression or.
RewriteCond% {HTTP_HOST} www.sky9899.com [NC,OR]
RewriteCond% {HTTP_HOST} ^ sky9899.com [NC,OR]
RewriteCond% {HTTP_HOST} ^ sky9890.com [NC,OR]
RewriteRule ^ / (. *) $http://www.51cto.com [L] # L represents the last matching rule and stops matching subsequent rules. Jump www.sky9890.com, www.sky9899.com, sky9899.com, sky9890.com to www.51cto.com
ErrorLog "logs/www.sky9890.com_error_log"
CustomLog "logs/www.sky9890.com_access_logg" common
ServerAdmin 553752017@qq.com
DocumentRoot "/ usr/local/apache2/htdocs/sky9899"
ServerName www.sky9899.com
RewriteCond% {HTTP_HOST} www.sky9890.com [NC,OR]
RewriteCond% {HTTP_HOST} www.sky9899.com [NC,OR]
RewriteCond% {HTTP_HOST} ^ sky9890.com [NC]
RewriteRule ^ / (. *) $http://www.51cto.com [L]
ErrorLog "logs/www.sky9899.com_error_log"
CustomLog "logs/www.sky9899.com_access_log" common
IV. Actual combat of Apache rewrite rules
1.rewrite rules, also known as rule rewriting, the main function of the browser to access the HTTP URL jump.
The purpose of 2.rewrite rule rewriting is as follows:
1) friendly to search engine optimization, which is beneficial to search engine pages.
2) hide the real URL address of the website, and the browser display is more beautiful.
3) website changes and upgrades can be temporarily redirected to other pages based on rewrite.
5. Other configuration skills
1) find the entry in the LoadModule rewrite_module modules/mod_rewrite.so # http.conf configuration file and remove the previous # sign.
2) configure the virtual host configuration segment as this instruction to enable the rewrite function: RewriteEngine on
3) AllowOverride None, change it to AllowOverride All
4) write the rewrite rules to the httpd-vhosts.conf file and write them in.
5)% {there can be no spaces between the two symbols, otherwise the execution will have no effect.
6) the Windows client sets hosts mapping to bind www.sky9890.com and www.sky9899.com to 192.168.153.142. The purpose of the mapping is to bind the domain name to IP. The configuration is as follows:
C:\ Windows\ System32\ drivers\ etc\ hosts # Open the hosts file with notepad and add the following lines
192.168.153.142 www.sky9890.com
192.168.153.142 www.sk9899.com
192.168.153.142 sky9890.com
192.168.153.142 sky9899.com
6. The test results are as follows:
If you enter the above four addresses in the browser, you will automatically jump to the following interface:
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.