In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Nginx virtual host domain name based virtual host IP address based virtual host port based virtual host 1, install DNS domain name resolution server 1, install bind server [root@localhost ~] # yum install bind-y2, modify the main configuration file (named.conf) [root@localhost ~] # vim / etc/named.conf options {listen-on port 53 {any;} # # listening on all listen-on-v6 port 53 {:: 1;}; directory "/ var/named"; dump-file "/ var/named/data/cache_dump.db"; statistics-file "/ var/named/data/named_stats.txt" Memstatistics-file "/ var/named/data/named_mem_stats.txt"; recursing-file "/ var/named/data/named.recursing"; secroots-file "/ var/named/data/named.secroots"; allow-query {any;} # # allow all 3, modify the zone configuration file (named.rfc1912.zones) [root@localhost ~] # vim / etc/named.rfc1912.zones # # configure the zone configuration file zone "kgc.com" IN {type master; file "kgc.com.zone"; # # kgc zone data configuration file allow-update {none;} }; zone "accp.com" IN {type master; file "accp.com.zone"; # # accp zone data configuration file allow-update {none;};} 4. Modify the zone data configuration file (kgc.com.zone accp.com.zone) [root@localhost ~] # cd / var/named/ [root@localhost named] # cp-p named.localhost kgc.com.zone # # copy template [root@localhost named] # vim kgc.com.zone # # modify the zone configuration file $TTL 1D @ IN SOA @ rname.invalid. (0; serial 1D; refresh 1H Retry 1W; expire 3H) Minimum NS @ A 127.0.0.1www IN A 192.168.13.128 # # Local address [root@localhost named] # cp-p kgc.com.zone accp.com.zone # # copy the file for the accp area data configuration file [root@localhost named] # systemctl start named # # enable the dns service [root@localhost named] # systemctl stop firewalld. Service # # turn off the firewall [root@localhost named] # setenforce 05 Create site directories for two websites and add home page content [root@localhost] # mkdir-p / var/www/html/accp # # create accp site [root@localhost] # mkdir-p / var/www/html/kgc # # create kgc site [root@localhost ~] # cd / var/www/html/ [root@localhost html] # lsaccp kgc [root@localhost html] # echo "this an accp web" > accp/index.html # create Create Home content [root@localhost html] # echo "this a kgc web" > kgc/index.html # # create Home content 2 Share the compression package required by LAMP on Windows (if you have any questions here, please see the previous blog article)
three, Use remote sharing on Linux to obtain files and mount them to the mnt directory [root@localhost] # smbclient-L / / 192.168.100.3 / # # remote share access Enter SAMBA\ root's password: Sharename Type Comment-LNMP- C7 Disk [root@localhost ~] # mount.cifs / / 192.168.100.3/LNMP-C7 / mnt # # Mount to / mnt directory Compile and install Nginx1, decompress the source code package to / opt And view [root@localhost ~] # cd / mnt # # switch to the mount point directory [root@localhost mnt] # lsDiscuz_X3.4_SC_UTF8.zip nginx-1.12.2.tar.gzmysql-boost-5.7.20.tar.gz php-7.1.20.tar.gz [root@localhost mnt] # tar zxvf nginx-1.12.2.tar.gz-C / opt # # decompress the Nginx source code package to / opt [root@localhost mnt ] # cd / opt/ # # switch to [root@localhost opt] # lsnginx-1.12.2 rh2 under the decompressed directory Install the environment component package required for compilation [root@localhost opt] # yum-y install\ gcc\ / c language gcc-c++\ / / C++ language pcre-devel\ / / pcre language tool zlib-devel / / function library for data compression 3 Create program user nginx and compile Nginx [root@localhost opt] # useradd-M-s / sbin/nologin nginx # # create program user Security non-login status [root@localhost opt] # id nginxuid=1001 (nginx) gid=1001 (nginx) group = 1001 (nginx) [root@localhost opt] # cd nginx-1.12.0/ # # switch to the nginx directory [root@localhost nginx-1.12.0]. / configure\ # # configure nginx >-- prefix=/usr/local/nginx\ # # installation path >-- user=nginx\ # # user name >-- group=nginx\ # # user group >-- with-http_stub_status_module # # status statistics module 4 Compile and install [root@localhost nginx-1.12.0] # make # # compile... [root@localhost nginx-1.12.0] # make install # # install .5, optimize the nginx startup script So that the system can recognize [root@localhost nginx] # ln-s / usr/local/nginx/sbin/nginx / usr/local/sbin/ # # create a soft connection to let the system recognize the nginx startup script [root@localhost nginx] # nginx-t # # check the syntax problems of the configuration file nginx: the configuration file / usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file / usr/local/nginx/conf/nginx.conf test is successful [root@localhost Nginx] # nginx # # Open ngnix [root@localhost nginx] # netstat-ntap | grep 80 # # View port Nginx has enabled tcp 0 0 0.0.0 LISTEN 39620/nginx: master [root@localhost nginx] # systemctl stop firewalld.service # # turn off the firewall [root@localhost nginx] # setenforce 0 [root@localhost nginx] # nginx # # enable 6, and create a management script Easy to use service management to use [root@localhost nginx] # cd / etc/init.d/ # # to switch to the startup configuration file directory [root@localhost init.d] # lsfunctions netconsole network README [root@localhost init.d] # vim nginx # # Edit the startup script file #! / bin/bash# chkconfig:-99 20 # # comment Information # description: Nginx Service Control ScriptPROG= "/ usr/local/nginx/sbin/nginx" # # set the variable to the nginx command file PIDF= "/ usr/local/nginx/logs/nginx.pid" # # set the variable PID file process number is 5346case "$1" in start) $PROG # # start the service ; stop) kill-s QUIT $(cat $PIDF) # # disable the service;; restart) # # restart the service $0 stop $0 start Reload) # # reload service kill-s HUP $(cat $PIDF) *) # # incorrect input prompt echo "Usage: $0 {start | stop | restart | reload}" exit 1esacexit 0 [root@localhost init.d] # chmod + x / etc/init.d/nginx # # give startup script execution permission [root@localhost init.d] # chkconfig-- add nginx # # add to service Manager [root@localhost init.d] # service nginx stop # # you can use service to control nginx [root@localhost init.d] # service nginx start7 Or it is convenient for systemctl management Configuration file (to facilitate writing one) [root@localhost ~] # vim / lib/systemd/system/nginx.service # # create a profile [Unit] Description=nginx # # describe After=network.target # # describe the service type [Service] Type=forking # # background running form PIDFile=/usr/local/nginx/logs/nginx.pid # # PID file location ExecStart=/usr/local/nginx/sbin/nginx # # start the service ExecReload=/usr/bin/kill-s HUP $MAINPID # # configure ExecStop=/usr/bin/kill-s QUIT $MAINPID # terminate the process PrivateTmp=true according to PID [Install ] WantedBy=multi-user.target [root@localhost ~] # chmod 754 / lib/systemd/system/nginx.service # # set execution permission [root@localhost ~] # systemctl stop nginx.service # # close [root@localhost ~] # systemctl start nginx.service # # enable five Modify nginx configuration file information [root@localhost ~] # cd / usr/local/nginx/conf [root@localhost conf] # vim nginx.conf # # modify Nginx configuration file server {listen 80 based on virtual host 1 of different domain names Server_name www.kgc.com; # # kgc website charset utf-8; access_log logs/www.kgc.com.access.log; # # Log file location / {root / var/www/html/kgc; # # site directory index index.html index.htm } error_page 500 502 503 504 / 50x.htl; location = / 50x.html {root html;}} server {listen 80; server_name www.accp.com; # # accp website charset utf-8; access_log logs/www.accp.com.access.log # # Log file location / {root / var/www/html/accp; # # site directory index index.html index.htm;} error_page 500502 503504 / 50x.htl; location = / 50x.html {root html }} [root@localhost conf] # service nginx restart # # restart nginx Service 2 and use the test machine to access websites with different domain names
6. Modify nginx configuration file information [root@localhost] # cd / usr/local/nginx/conf [root@localhost conf] # vim nginx.conf # # based on virtual host 1 of different ports. Modify Nginx configuration file server {listen 80; server_name www.accp.com; charset utf-8; access_log logs/www.accp.com.access.log; location / {root / var/www/html/accp Index index.html index.htm;} error_page 500502 503504 / 50x.htl; location = / 50x.html {root html;}} server {listen 192.168.13.138location 8080; # # modify the listening port to 8080 server_name www.accp.com; charset utf-8 The access_log logs/www.accp8080.com.access.log; # # log file is modified to the site directory of port 8080 location / {root / var/www/html/accp8080; # # 8080 index index.html index.htm;} error_page 500502 503 504 / 50x.hml; location = / 50x.html {root html }} 2, create an accp8080 site directory And create home page content [root@localhost conf] # cd / var/www/html/ # # switch to site directory [root@localhost html] # mkdir accp8080 # # create site directory [root@localhost html] # cd accp8080/ [root@localhost accp8080] # echo "this is accp8080 web" > index.html # # create home page content [root@localhost accp8080] # service nginx restart # # restart Nginx service 3 Use a test machine to visit websites in different ports
Seventh, add a network card 192.168.13.138192.168.13.133 to the virtual machine based on the virtual host 1 of different IP
2. Modify the dns zone data configuration file [root@localhost ~] # cd var/named/ [root@localhost named] # vim kgc.com.zone # # modify the kgc zone data configuration file $TTL 1D @ IN SOA @ rname.invalid. (0; serial 1D; refresh 1H Retry 1W; expire 3H) Minimum NS @ A 127.0.0.1www IN A 192.168.13.133 # # address: 133 [root@localhost named] # vim accp.com.zone # # modify accp's zone data configuration file $TTL 1D @ IN SOA @ rname.invalid. (0; serial 1D; refresh 1H Retry 1W; expire 3H) Minimum NS @ A 127.0.0.1www IN A 192.168.13.138 # # address: 138 [root@localhost named] # systemctl restart named # # restart dns service 3 Modify nginx configuration file information [root@localhost ~] # cd / usr/local/nginx/conf [root@localhost conf] # vim nginx.conf # # modify Nginx configuration file server {listen 192.168.13.133 cd 80 # # specify IP address server_name www.kgc.com; charset utf-8; access_log logs/www.kgc.com.access.log; location / {root / var/www/html/kgc; index index.html index.htm;} error_page 500502503504 / 50x.htl; location = / 50x.html {root html }} server {listen 192.168.13.138IP 80; # # specify the IP address server_name www.accp.com; charset utf-8; access_log logs/www.accp.com.access.log; location / {root / var/www/html/accp; index index.html index.htm;} error_page 500502 503 504 / 50x.html Location = / 50x.html {root html;}} [root@localhost conf] # service nginx restart # # restart Nginx service 4 and use a test machine to visit websites of different IP
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.