您好,登錄后才能下訂單哦!
https://pan.baidu.com/s/1tXzFm2DVckZNS6HuwDwGoA //軟件連接百度云
systemctl stop firewalld //關(guān)閉防火墻
setenforce 0 //關(guān)閉監(jiān)控
yum install lrz* -y //可以直接把軟件包拖到xshell當(dāng)前目錄里面的命令
tar xf nginx-1.13.9.tar.gz -C /opt/ //解壓壓縮包到/opt/下
cd /opt/
ls
cd /opt/nginx-1.13.9/ //進(jìn)入文件
useradd -s /sbin/nologin -M nginx //創(chuàng)建一個(gè)無(wú)法登陸系統(tǒng)的用戶
yum install -y \ //安裝編譯工具及插件
gcc \
gcc-c++ \
make \
openssl-devel \
zlib-devel \
pcre-devel
./configure \ //個(gè)性化配置
--user=nginx \
--group=nginx \
--with-file-aio \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-http_realip_module
make && make install //編譯且安裝
cd //到root根目錄下
vi /usr/local/nginx/conf/nginx.conf
user nginx nginx;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
add_header X-Server $hostname;
server_names_hash_bucket_size 128;
server_name_in_redirect off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
#keepalive_timeout 0;
keepalive_timeout 60;
client_header_buffer_size 32k;
large_client_header_buffers 4 128k;
client_max_body_size 512m;
open_file_cache max=65535 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 1;
gzip on;
gzip_static on;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_min_length 1024;
gzip_vary on;
gzip_types text/plain text/javascript application/x-javascript text/css text/xml application/xml application/xml+rss;
server_tokens off;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 512k;
fastcgi_buffers 6 512k;
fastcgi_busy_buffers_size 512k;
fastcgi_temp_file_write_size 512k;
fastcgi_intercept_errors on;
client_body_buffer_size 128k;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
proxy_buffer_size 32k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 2m;
proxy_ignore_client_abort on;
proxy_cache_path /usr/local/nginx/cache_temp levels=2:2
keys_zone=cache_temp:128m inactive=30m max_size=2g;
proxy_cache_valid 200 302 10m;
include /usr/local/nginx/conf/conf.d/*.conf;
server {
listen 80;
server_name localhost;
charset UTF-8;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
:wq //保存退出
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/ //軟鏈接
nginx -t //檢查nginx有沒有錯(cuò)誤
cd /usr/local/nginx/conf/
mkdir conf.d
cd conf.d/
vi lvs01.conf //新建子配置文件
server {
listen 80;
server_name lvs01 192.168.80.100; //服務(wù)器名稱與IP地址
index index.html index.jsp;
root /usr/local/nginx/html;
access_log /usr/local/nginx/logs/tomcat.aa.com_access.log main;
location ~ .*\.jsp$ {
index index.jsp;
proxy_set_header HOST $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Client-IP $remote_addr;
proxy_set_header X-For $proxy_add_x_forwarded_for;
proxy_pass http://center_pool;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
proxy_pass http://center_pool;
}
location ~ .*\.(js|css)?$ {
expires 1h;
proxy_pass http://center_pool;
}
}
:wq //保存退出
vi pool.conf //創(chuàng)建服務(wù)器池
#添加以下內(nèi)容
upstream center_pool { //默認(rèn)輪詢
server 192.168.80.102:8080;
server 192.168.80.103:8080;
}
:wq //保存退出
nginx -t
vi /etc/init.d/nginx
#!/bin/bash
# chkconfig: 35 99 20
# description: Nginx Service Control Script
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.pid"
case "$1" in
start)
$PROG
;;
stop)
kill -s QUIT $(cat $PIDF)
;;
restart)
$0 stop
$0 start
;;
reload)
kill -s HUP $(cat $PIDF)
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
exit 0
:wq //保存退出
chmod +x /etc/init.d/nginx //增加執(zhí)行權(quán)限
chkconfig --add nginx //加入系統(tǒng)管理服務(wù)
service nginx start //啟動(dòng)nginx服務(wù)
netstat -anpt | grep 80 //查看80端口有哪些服務(wù)在開啟狀態(tài)
在瀏覽器地址欄中輸入192.168.80.100/index.jsp
scp /usr/local/nginx/conf/nginx.conf root@192.168.80.101:/usr/local/nginx/conf/nginx.conf //把本機(jī)上的nginx.conf傳送到80.101虛擬機(jī)上
yes
自己設(shè)置的root密碼
scp * root@192.168.80.101:/usr/local/nginx/conf/conf.d/ //傳送到80.101虛擬機(jī)上
自己設(shè)置的root密碼
scp /etc/init.d/nginx root@192.168.80.101:/etc/init.d
自己設(shè)置的root密碼
cd /etc/yum.repos.d/ //進(jìn)入目錄
cp back/* ./ //把back里面所有內(nèi)容提取到上一個(gè)目錄下
ifconfig ens34 down //關(guān)閉網(wǎng)卡
ifconfig ens34 up //開啟網(wǎng)卡
yum install -y epel-release //安裝
yum install keepalived -y //安裝
cd //到root根目錄下
vi /etc/keepalived/keepalived.conf
#把里面內(nèi)容都刪了添加以下內(nèi)容
! Configuration File for keepalived
global_defs {
route_id NGINX-01
}
vrrp_script nginx {
script "/opt/nginx.sh"
interval 2
weight -10
}
vrrp_instance VI_1 {
state MASTER
interface ens32
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
track_script {
nginx
}
virtual_ipaddress {
192.168.80.188
}
}
:wq //保存退出
scp /etc/keepalived/keepalived.conf root@192.168.80.101:/etc/keepalived/
自己設(shè)置root的密碼
cd /opt/
vi nginx.sh
#!/bin/bash
#Filename:nginx.sh
A=$(ps -ef | grep keepalived | grep -v grep | wc -l)
if [ $A -gt 0 ]; then
/etc/init.d/nginx start
else
/etc/init.d/nginx stop
fi
:wq //保存退出
chmod +x nginx.sh //給這個(gè)文件權(quán)限
./nginx.sh //執(zhí)行這個(gè)腳本
systemctl start keepalived //重啟keepalived服務(wù)
systemctl stop firewalld //關(guān)閉firewalld服務(wù)
chkconfig --add nginx
service nginx start //重啟nginx服務(wù)
./nginx.sh //在執(zhí)行腳本
systemctl stop firewalld //關(guān)閉防火墻
setenforce 0 //關(guān)閉監(jiān)控
yum install lrz* -y //可以直接把軟件包拖到xshell當(dāng)前目錄里面的命令
yum install -y \ //安裝編譯工具及插件
gcc \
gcc-c++ \
make \
openssl-devel \
zlib-devel \
pcre-devel
./configure \ //個(gè)性化配置
--user=nginx \
--group=nginx \
--with-file-aio \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-http_realip_module
make && make install //編譯且安裝
cd /usr/local/nginx/conf/ //進(jìn)入文件夾
mkdir conf.d //創(chuàng)建這個(gè)文件
vi conf.d/lvs01.conf
把80.100改成80.101
chkconfig --add nginx
useradd -s /sbin/nologin -M nginx //創(chuàng)建一個(gè)無(wú)法登陸系統(tǒng)的用戶
service nginx start //重啟nginx
cd /etc/yum.repos.d/ //進(jìn)入這個(gè)目錄
cp back/* ./ //把back這個(gè)目錄里面的內(nèi)容轉(zhuǎn)到上一個(gè)目錄下
ifconfig ens34 down //關(guān)閉網(wǎng)卡
ifconfig ens34 up //開啟網(wǎng)卡
yum install -y epel-release //安裝
yum install keepalived -y //安裝
vi /etc/keepalived/keepalived.conf //進(jìn)入文件
cd /opt/ //到/opt/下
vi nginx.sh
#!/bin/bash
#Filename:nginx.sh
A=$(ip addr | grep 192.168.80.188/32 | grep -v grep | wc -l)
if [ $A -gt 0 ]; then
/etc/init.d/nginx start
else
/etc/init.d/nginx stop
fi
:wq //保存退出
chmod +x nginx.sh //給這個(gè)腳本執(zhí)行權(quán)限
./nginx.sh //啟動(dòng)這個(gè)腳本
systemctl start keepalived //重啟服務(wù)
systemctl stop firewalld //關(guān)閉防火墻
setenforce 0 //關(guān)閉監(jiān)控
yum install lrz* -y //可以直接把軟件包拖到xshell當(dāng)前目錄里面的命令
tar xf apache-tomcat-8.5.23-embed.tar.gz //壓縮apache-tomcat-8.5.23-embed.tar.gz到當(dāng)前目錄上
tar xf jdk-8u144-linux-x64.tar.gz //壓縮jdk-8u144-linux-x64.tar.gz到當(dāng)前目錄上
cp -rv jdk1.8.0_144/ /usr/local/java //把jdk1.8.0_144拷貝到 /usr/local/java 目錄下
vi /etc/profile //在文件末尾新增
export JAVA_HOME=/usr/local/java
export JRE_HOME=/usr/local/java/jre
export PATH=$PATH:/usr/local/java/bin
export CLASSPATH=./:/usr/local/java/lib:/usr/local/java/jre/lib
source /etc/profile
java -version //查看版本顯示下面內(nèi)容
java version "1.8.0_144"
……
……
--------------以上是搭建JAVA環(huán)境---------
cp -r apache-tomcat-8.5.23 /usr/local/tomcat8 //把a(bǔ)pache-tomcat-8.5.23拷貝到/usr/local/tomcat8
ln -s /usr/local/tomcat8/bin/startup.sh /usr/bin/tomcatup //把/usr/local/tomcat8/bin/startup.sh軟鏈接到 /usr/bin/tomcatup
ln -s /usr/local/tomcat8/bin/shutdown.sh /usr/bin/tomcatdown //把/usr/local/tomcat8/bin/shutdown.sh軟鏈接到/usr/bin/tomcatdown
vi /usr/local/tomcat8/webapps/ROOT/index.jsp
在第一行加server aa
tomcatup
netstat -anpt | grep 8080 //查看當(dāng)前8080端口有哪些程序在運(yùn)行
systemctl stop firewalld //關(guān)閉防火墻
setenforce 0 //關(guān)閉監(jiān)控
yum install lrz* -y //可以直接把軟件包拖到xshell當(dāng)前目錄里面的命令
tar xf apache-tomcat-8.5.23-embed.tar.gz //壓縮apache-tomcat-8.5.23-embed.tar.gz到當(dāng)前目錄上
tar xf jdk-8u144-linux-x64.tar.gz //壓縮jdk-8u144-linux-x64.tar.gz到當(dāng)前目錄上
cp -rv jdk1.8.0_144/ /usr/local/java //把jdk1.8.0_144拷貝到 /usr/local/java 目錄下
vi /etc/profile //在文件末尾新增
export JAVA_HOME=/usr/local/java
export JRE_HOME=/usr/local/java/jre
export PATH=$PATH:/usr/local/java/bin
export CLASSPATH=./:/usr/local/java/lib:/usr/local/java/jre/lib
source /etc/profile
java -version //查看版本顯示下面內(nèi)容
java version "1.8.0_144"
……
……
--------------以上是搭建JAVA環(huán)境---------
cp -r apache-tomcat-8.5.23 /usr/local/tomcat8 //把a(bǔ)pache-tomcat-8.5.23拷貝到/usr/local/tomcat8
ln -s /usr/local/tomcat8/bin/startup.sh /usr/bin/tomcatup //把/usr/local/tomcat8/bin/startup.sh軟鏈接到 /usr/bin/tomcatup
ln -s /usr/local/tomcat8/bin/shutdown.sh /usr/bin/tomcatdown //把/usr/local/tomcat8/bin/shutdown.sh軟鏈接到/usr/bin/tomcatdown
vi /usr/local/tomcat8/webapps/ROOT/index.jsp
在第一行加server bb
tomcatup
netstat -anpt | grep 8080 //查看當(dāng)前8080端口有哪些程序在運(yùn)行
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。