标签:自动 apache follow efi 设置权限 mysql inux home end
在80.100虚拟机上:tar xf haproxy-1.5.15.tar.gz -C /opt/ //解压压缩包
cd /opt/haproxy-1.5.15/
yum install -y \
pcre-devel \
bzip2-devel \
gcc \
gcc-c++ \
make
uname -r //内核版本
make TARGET=linux26 PREFIX=/usr/local/haproxy //标识64为系统
make install PREFIX=/usr/local/haproxy
mkdir /etc/haproxy //创建目录
useradd -s /sbin/nologin -M haproxy //创建用户
id haproxy //查看用户信息
cd /usr/local/haproxy/
cd /opt/haproxy-1.5.15/
cd examples/
cp haproxy.cfg /etc/haproxy/
cd /etc/haproxy/
vi haproxy.cfg
chroot /usr/share/haproxy前面加#
uid 1000
gid 1000 ...
srvtimeout 50000 后面的内容全删了,再添加以下内容
--------------统计页面配置------------------
listen admin_stats #为haproxy访问状态监控页面配置,取名为admin_stats
bind 0.0.0.0:8089 //监听端口
stats enable //启用监听端口
mode http #http的7层模式
log global # 继承global中log的定义
stats uri /stats #监控页面的url访问路径,即http://ip/stats 访问监控页面
stats realm Haproxy\ Statistics #监控页面的密码框提示信息
stats auth admin:admin #监控页面的用户和密码admin,可以设置多个用户名
#stats hide-version //隐藏统计页面上HAProxy的版本信息
stats admin if TRUE //当通过认证才可管理
stats refresh 30s //页面自动刷新时间30s
:wq //保存退出
cd -
cp haproxy.init /etc/init.d/haproxy
ll /etc/init.d/haproxy
chmod +x /etc/init.d/haproxy //给这个文件设置权限
ll /etc/init.d/haproxy
chkconfig --add haproxy
ln -s /usr/local/haproxy/sbin/haproxy /usr/sbin/haproxy
service haproxy start
netstat -anp | grep haproxy
在网页上输入http://192.168.80.100:8089/stats
vi /etc/haproxy/haproxy.cfg 最后一行添加以下内容
listen www
bind *:80
maxconn 5000
mode http
log global
option httplog
option httpclose
option forwardfor
log global
default_backend default #设置默认访问页面
#定义当请求的内容是静态内容时,将请求转交给static server的acl规则
#静态
acl url_static path_beg -i /static /images /img /javascript /stylesheets
acl url_static path_end -i .jpg .gif .png .css .js .html
#php内容
acl url_php path_end -i .php
#jsp内容
acl url_jsp path_end -i .jsp .do
#引用acl匹配规则
use_backend static_pool if url_static or host_static
use_backend php_pool if url_php
use_backend tomcat_pool if url_jsp
#定义后端backend server
backend static_pool
option httpchk GET /index.html
server static1 192.168.80.101:80 cookie id1 check inter 2000 rise 2 fall 3
backend php_pool
option httpchk GET /index.php
server php1 192.168.80.102:80 cookie id1 check inter 2000 rise 2 fall 3
backend tomcat_pool
option httpchk GET /index.jsp
server tomcat1 192.168.80.103:8080 cookie id2 check inter 2000 rise 2 fall 3
backend default
mode http
option httpchk GET /index.html
server default 192.168.80.104:80 cookie id1 check inter 2000 rise 2 fall 3 maxconn 5000
:wq //保存退出
service haproxy stop //关闭haproxy服务
service haproxy start //开启haproxy服务
在网页上输入http://192.168.80.100:8089/stats
————————————————————————————
在80.101虚拟机上:
systemctl stop firewalld
setenforce 0
yum install httpd -y
vi /etc/httpd/conf/httpd.conf
把ServerName www.example.com:80 前面的#去掉
cd /var/www/html/
yum install lrz* -y
放张图片进去图片名叫aa.jpg
systemctl start httpd
在网页输入192.168.80.101/aa.jpg
mkdir img //加个路径目录
mv aa.jpg img/
在网页上输入192.168.80.106/img/aa.jpg
————————————————————————————
在80.102虚拟机上:
systemctl stop firewalld
setenforce 0
yum install httpd -y
vi /etc/httpd/conf/httpd.conf
把ServerName www.example.com:80 前面的#去掉
DirectoryIndex index.php index.html
yum install php -y
php安装
yum install -y \
php-mysql \
php-gd \
libjpeg* \
php-ldap \
php-odbc \
php-pear \
php-xml \
php-xmlrpc \
php-mbstring \
php-bcmath \
php-mhash
查看php版本
php --version
vi /etc/php.ini
date.timezone = PRC 日期时区=×××
cd /var/www/html/
vi index.php
<?php
phpinfo();
?>
systemctl start httpd
在网页上输入 http://192.168.80.102
————————————————————————————
在80.103虚拟机上:
systemctl stop firewalld
setenforce 0
yum install lrz* -y
把tomcat和jdk的包拉入
tar xf apache-tomcat-8.5.23.tar.gz -C /opt/
tar xf jdk-8u144-linux-x64.tar.gz -C /opt/
cd /opt/
cp -rf 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 //查看是否生效
cp -rf apache-tomcat-8.5.23/ /usr/local/tomcat8
ln -s /usr/local/tomcat8/bin/startup.sh /usr/bin/tomcatup
ln -s /usr/local/tomcat8/bin/shutdown.sh /usr/bin/tomcatdown
tomcatup
在网页上访问http://192.168.80.103:8080
cd /usr/local/tomcat8/
cd conf/
vi server.xml
mkdir -p /webapp/web01
vi /web/webapp1/index.jsp //添加以下内容
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>JSP test page</title>
</head>
<body>
<% out.println("Welcom to test site");%>
</body>
</html>
tomcatdown //关闭tomcat
tomcatup //开启tomcat
————————————————————————————
最后在网页上输入
http://192.168.80.100/img/aa.jpg
http://192.168.80.100/index.php
http://192.168.80.100/index.jsp
标签:自动 apache follow efi 设置权限 mysql inux home end
原文地址:http://blog.51cto.com/14158297/2342257