设为首页 加入收藏

TOP

ansible分离部署LNMP架构(四)
2023-07-23 13:33:32 】 浏览:74
Tags:ansible LNMP 架构
that this server has been started. Generating a new UUID: 5a8e11ea-52de-11ed-b270-000c29c34b3e. 2022-10-23T14:24:07.383794Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2022-10-23T14:24:07.600947Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher. 2022-10-23T14:24:07.600960Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher. 2022-10-23T14:24:07.601238Z 0 [Warning] CA certificate ca.pem is self signed. 2022-10-23T14:24:07.640229Z 1 [Note] A temporary password is generated for root@localhost: y*rou<U9Om.c [root@ansible ~]# ansible mysql -m shell -a "echo 'y*rou<U9Om.c' > pass" //生成配置文件启动服务 [root@ansible ~]# vim /etc/ansible/scripts/mysql_service.sh #!/bin/bash cat >> /etc/my.cnf <<EOF [mysqld] basedir = /usr/local/mysql datadir = /opt/data socket = /tmp/mysql.sock port = 3306 pid-file = /opt/data/mysql.pid user = mysql skip-name-resolve EOF cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld sed -ri 's#^(basedir=).*#\1/usr/local/mysql#g' /etc/init.d/mysqld sed -ri 's#^(datadir=).*#\1/opt/data#g' /etc/init.d/mysqld chmod +x /etc/init.d/mysqld cat > /usr/lib/systemd/system/mysqld.service <<EOF [Unit] Description=mysqld server daemon After=network.target [Service] Type=forking ExecStart=/etc/init.d/mysqld start ExecStop=/etc/init.d/mysqld stop ExecReload=/bin/kill -HUP \$MAINPID [Install] WantedBy=multi-user.target EOF systemctl daemon-reload systemctl enable --now mysqld [root@ansible ~]# ansible mysql -m script -a '/etc/ansible/scripts/mysql_service.sh' [root@ansible ~]# ansible mysql -a 'ss -antl' mysql | CHANGED | rc=0 >> State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 80 *:3306 *:* LISTEN 0 128 [::]:22 [::]:*

4.部署php

//安装依赖包
[root@ansible ~]# ansible php -m yum -a 'name=epel-release state=present'
[root@ansible ~]# ansible php -m yum -a 'name=libxml2,libxml2-devel,openssl,openssl-devel,bzip2,bzip2-devel,libcurl,libcurl-devel,libicu-devel,libjpeg,libjpeg-devel,libpng,libpng-devel,openldap-devel,pcre-devel,freetype,freetype-devel,gmp,gmp-devel,libmcrypt,libmcrypt-devel,readline,readline-devel,libxslt,libxslt-devel,mhash,mhash-devel,php-mysqlnd,libsqlite3x-devel,libzip-devel,wget,gcc,gcc-c++,make state=present'
[root@ansible ~]# ansible php -a 'yum -y install http://mirror.centos.org/centos/8-stream/PowerTools/x86_64/os/Packages/oniguruma-devel-6.8.2-2.el8.x86_64.rpm'

//下载PHP并解压
[root@ansible ~]# ansible php -a 'wget https://www.php.net/distributions/php-8.1.11.tar.gz'
[root@ansible ~]# ansible php -a 'tar xf php-8.1.11.tar.gz -C /usr/src'

//编译安装php
[root@ansible ~]# vim /etc/ansible/scripts/php.sh
#!/bin/bash

cd /usr/src/php-8.1.11/
./configure --prefix=/usr/local/php \
--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-pd
首页 上一页 1 2 3 4 5 下一页 尾页 4/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇vim的常用命令 下一篇linux内网替换redhat-6.5为CentOS..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目