标签:env 结果 安装 超时 负载均衡 server web header profile
--------------------------------------------------------------------------------
Apache
httpd
enable/start httpd
firewall-cmd --permanent --zone=public --add-service=http / https
reload
service httpd status
systemctl status httpd
httpd -v
IP测试
--------------------------------------------------------------------------------
负载均衡+反向代理基础搭建
#Tomcat 配置JAVA环境使用
vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_152
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
source /etc/profile
tar -C /usr/local/tomcat
vi /usr/local/tomcat/conf/server.xml
/usr/local/tomcat/bin/startup.sh
/usr/local/tomcat/bin/shutdown.sh
Tomcat #建jsp并访问测试
mkdir -pv /web/webapp
cat <<END >/web/webapp/index.jsp
<html>
<head>
<title>JSP test1 page</title>
</head>
<body>
<% out.println("<h1>welcome to Jsp</h1>");%>
</body>
</html>
END
vi /usr/local/tomcat/conf/server.xml
<Context docBase="/web/webapp" path="" reloadable="false">
</Context>
#tomcat设置启动
# --------------------------------------------------
vi /lib/systemd/system/tomcat.service
[Unit]
Description=tomcat
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
Environment=‘JAVA_HOME=/home/jdk‘
Environment=‘CATALINA_PID=/usr/local/tomcat/bin/tomcat.pid‘
Environment=‘CATALINA_HOME=/usr/local/tomcat/‘
Environment=‘CATALINA_BASE=/usr/local/tomcat/‘
Environment=‘CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC‘
WorkingDirectory=/usr/local/tomcat/
ExecStart=/usr/local/tomcat/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
vi /usr/local/tomcat/bin/catalina.sh
export JAVA_HOME=/home/jdk
export JRE_HOME=/home/jdk
---------------------
#Nginx编译安装使用
#编译一
./configure
make&&make install
vi /usr/local/nginx/conf/nginx.conf
/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -s
#编译二
mkdir -p /var/temp/nginx
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi
vi /usr/local/nginx/conf/nginx.conf
/usr/local/nginx/sbin/nginx
#编译三
groupadd www
useradd -g www www -s /bin/false
./configure --prefix=/usr/local/nginx --user=www --group=www --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_ssl_module
make&&make install
/usr/local/nginx/sbin/nginx
vi /usr/local/nginx/conf/nginx.conf
upstream tomcat_server {
server 192.168.140.158:8080 weight=1;
server 192.168.140.159:8080 weight=2;
}
location / {
proxy_pass http://tomcat_server;
proxy_set_header Host $host;
}
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nginx设置启动
vi /lib/systemd/system/nginx.service
# --------------------------------------------------
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
# --------------------------------------------------
#Nginx 应用优化
#隐藏版本号
curl dd/IP #访问网页
curl -i dd/IP #查看nginx版本
vi /usr/local/nginx/conf/nginx.conf
http内添加:
server_tokens off;
#网页缓存
cat <<END >/usr/local/nginx/html/index.html
<html>
<head>
<title>windows</title>
</head>
<body>
windows7
<img src="./win7.jpg"/> #./指的是/usr/local/nginx/html/
</body>
</html>
END
#缓存图片类型及期限
vi /usr/local/nginx/conf/nginx.conf
location ~ \.(gif|jpg|jpeg|png|bmp|ico)$ {
expires 1d;
}
location ~ .*\.(js|css)$ {
expires 1h;
}
#连接超时
vi /usr/local/nginx/conf/nginx.conf
keepalive_timeout 65;
client_header_timeout 60;
client_body_timeout 60;
#网页压缩传输
vi /usr/local/nginx/conf/nginx.conf
gzip on; ##开启gzip压缩输出
gzip_min_length 1k; ##用于设置允许压缩的页面最小字节数
gzip_buffers 4 16k; ##表示申请 4 个单位为 16k 的内存作为压缩结果流缓存
gzip_http_version 1.1; ##设置识别 http 协议版本,默认是 1.1
gzip_comp_level 2; ##gzip 压缩比, 1-9 等级
gzip_types text/plain text/javascript application/x-javascript text/css text/xml
application/xml application/xml+rss; ##压缩类型,是就对哪些网页文档启用压缩功能
#访问控制
htpasswd -c /usr/local/nginx/conf/user.conf dd
vi /usr/local/nginx/conf/nginx.conf
location ~ \. {
auth_basic "GIVE ME GIVE ME";
auth_basic_user_file /usr/local/nginx/conf/user.conf;
allow 192.168.1.0/24;
deny 192.168.140.110;
}
#定义错误页面
echo "deny" >>/usr/local/nginx/html/404.html
vi /usr/local/nginx/conf/nginx.conf
error_page 403 404 500 502 503 504 /404.html;
location = /404.html {
root html;
}
#FTP类页面
location /download {
autoindex on;
}
在Tomcat上线项目;
项目项目数据到mysql
mysql -uroot -pxxx < xxx.sql
show databases;
use xxx;
show tables;
grant all on xxx.* to ‘账户‘@‘IP‘ identified by ‘密码‘;
flush privileges;
exit quit
cp 项目根文件 /usr/local/tomcat/webapps
vi 项目根文件/WEB-INF/x.properties
标签:env 结果 安装 超时 负载均衡 server web header profile
原文地址:https://www.cnblogs.com/feizhuanye/p/10395298.html