shell脚本一键部署zabbix监控服务

–with-apr-util=/usr/local/apr-util/ \

–enable-modules=most \

–enable-mpms-shared=all \

–with-mpm=prefork

make && make install

fi

if [ $? -eq 0 ];then

echo “apache 编译完成”

else

echo “apache 编译失败,请检查”

fi

ln -s /usr/local/apache/include/ /usr/include/httpd

echo ‘export PATH=/usr/local/apache/bin:$PATH’ > /etc/profile.d/httpd.sh

cd $route/apache/conf/

sed -i ‘203s///g’ httpd.conf

touch /usr/lib/systemd/system/httpd.service

sum=$(cat /usr/lib/systemd/system/httpd.service | wc -l)

if [ $sum -lt 2 ];then

cat > /usr/lib/systemd/system/httpd.service << EOF

[Unit]

Description=httpd server daemon

After=network.target

[Service]

Type=forking

ExecStart=/usr/local/apache/bin/apachectl start

ExecStop=/usr/local/apache/bin/apachectl stop

ExecReload=/bin/kill -HUP $MAINPID

[Install]

WantedBy=multi-user.target

EOF

fi

systemctl daemon-reload

systemctl enable --now httpd

echo “安装mysql”

id mysql &> /dev/null

if [ $? -ne 0 ];then

useradd -r -M -s /sbin/nologin mysql

fi

chown -R mysql.mysql $route/mysql

echo ‘export PATH=/usr/local/mysql/bin:$PATH’ > /etc/profile.d/mysql.sh

mkdir -p /opt/data

chown -R mysql.mysql /opt/data/

look=$( ls $data | wc -l)

if [ $look -eq 0 ];then

$route/mysql/bin/mysqld --initialize-insecure --user mysql --datadir /opt/data/

cat > /etc/my.cnf << EOF

[mysqld]

basedir = $route/mysql

datadir = $data

socket = /tmp/mysql.sock

port = 3306

pid-file = /opt/data/mysql.pid

user = mysql

skip-name-resolve

EOF

sed -ri “s^(basedir=).*\1$route/mysqlg” /usr/local/mysql/support-files/mysql.server

sed -ri “s^(datadir=).*\1$datag” /usr/local/mysql/support-files/mysql.server

cat > /usr/lib/systemd/system/mysql.service << EOF

[Unit]

Description=mysql server daemon

After=network.target

[Service]

Type=forking

ExecStart=/usr/local/mysql/support-files/mysql.server start

ExecStop= /usr/local/mysql/support-files/mysql.server stop

ExecReload=/bin/kill -HUP $MAINPID

[Install]

WantedBy=multi-user.target

EOF

fi

systemctl daemon-reload

systemctl enable --now mysql

echo “部署PHP”

cd $route/php-8.0.12

if [ ! -d $route/php8 ];then

./configure --prefix=/usr/local/php8 --with-config-file-path=/etc --enable-fpm --disable-debug --disable-rpath --enable-shared --enable-soap --with-openssl --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --enable-exif --enable-ftp --enable-gd --with-jpeg --with-zlib-dir --with-freetype --with-gettext --enable-mbstring --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-readline --enable-shmop --enable-simplexml --enable-sockets --with-zip --enable-mysqlnd-compression-support --with-pear --enable-pcntl --enable-posix && \

make && make install

fi

echo ‘export PATH=/usr/local/php8/bin:$PATH’ > /etc/profile.d/php.sh

cd $route/php-8.0.12

cp php.ini-production /etc/php.ini

cd $route/php-8.0.12/sapi/fpm

cp init.d.php-fpm /etc/init.d/php-fpm

chmod +x /etc/rc.d/init.d/php-fpm

cp $route/php8/etc/php-fpm.conf.default $route/php8/etc/php-fpm.conf

cp $route/php8/etc/php-fpm.d/www.conf.default $route/php8/etc/php-fpm.d/www.conf

touch /usr/lib/systemd/system/php-fpm.service

view=$(cat /usr/lib/systemd/system/php-fpm.service | wc -l)

if [ $view -lt 2 ];then

cat > /usr/lib/systemd/system/php-fpm.service << EOF

[Unit]

Description=php server daemon

After=network.target

[Service]

Type=forking

ExecStart=/etc/init.d/php-fpm start

ExecStop=/etc/init.d/php-fpm stop

ExecReload=/bin/kill -HUP $MAINPID

[Install]

WantedBy=multi-user.target

EOF

fi

systemctl daemon-reload

systemctl enable --now php-fpm

sed -i ‘120s/#//g’ /usr/local/apache/conf/httpd.conf

sed -i ‘124s/#//g’ /usr/local/apache/conf/httpd.conf

cd $route/apache/htdocs && mkdir -p test

cd $route/apache/htdocs/test

if [ ! -s index.php ];then

cat > index.php << EOF

<?php phpinfo(); ?>

EOF

chown -R apache.apache /usr/local/apache/htdocs/

cd $route/apache/conf

cat >> httpd.conf << EOF

<VirtualHost *:80>

DocumentRoot “/usr/local/apache/htdocs/test”

ServerName www.test.com

ProxyRequests Off

ProxyPassMatch ^/(.*.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/test/$1

<Directory “/usr/local/apache/htdocs/test”>

Options none

AllowOverride none

Require all granted

EOF

cd $route/apache/conf

sed -i ‘261s/index.html/index.php &/g’ httpd.conf

fi

systemctl restart php-fpm.service

systemctl restart httpd.service && sleep 5

echo “部署zabbix”

id zabbix &> /dev/null

if [ $? -ne 0 ];then

useradd -r -M -s /sbin/nologin zabbix

fi

$route/mysql/bin/mysql -e “create database zabbix character set utf8 collate utf8_bin;”

$route/mysql/bin/mysql -e “grant all privileges on zabbix.* to zabbix@localhost identified by ‘123’;”

$route/mysql/bin/mysql -e “flush privileges;”

cd $route/zabbix-5.4.4/database/mysql

$route/mysql/bin/mysql -uzabbix -p123 zabbix < schema.sql

$route/mysql/bin/mysql -uzabbix -p123 zabbix < images.sql

$route/mysql/bin/mysql -uzabbix -p123 zabbix < data.sql

cd $route/zabbix-5.4.4

jjyy=$(ls $route/etc | wc -l)

if [ $jjyy == 0 ];then

./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 && \

make install

cd $route/etc

sed -i “123s/#//g” zabbix_server.conf

sed -i “123s/DBPassword=/&$pass/g” zabbix_server.conf

sed -i ‘s/# DBSocket=/DBSocket=/tmp/mysql.sock/g’ zabbix_server.conf

fi

echo “/usr/lib64/mysql/” > /etc/ld.so.conf && ldconfig

cat > /usr/lib/systemd/system/zabbix_server.service << EOF

[Unit]

Description=zabbix server daemon

After=network.target

[Service]

Type=forking

ExecStart=/usr/local/sbin/zabbix_server -c /usr/local/etc/zabbix_server.conf

ExecReload=/bin/kill -HUP $MAINPID

RestartSec=10s

User=zabbix

Group=zabbix

[Install]

WantedBy=multi-user.target

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)

img

最后

由于篇幅有限,这里就不一一罗列了,20道常见面试题(含答案)+21条MySQL性能调优经验小编已整理成Word文档或PDF文档

MySQL全家桶笔记

还有更多面试复习笔记分享如下

Java架构专题面试复习

《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)**

img

最后

由于篇幅有限,这里就不一一罗列了,20道常见面试题(含答案)+21条MySQL性能调优经验小编已整理成Word文档或PDF文档

[外链图片转存中…(img-ZucU5HkT-1712666206374)]

还有更多面试复习笔记分享如下

[外链图片转存中…(img-eN5jHU4f-1712666206374)]

《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值