当前位置: 首页 > news >正文

jenkins集成工具(一)部署php项目

目录

什么是CI 、CD

Jenkins集成工具

一、Jenkins介绍

二、jenkins的安装和部署

环境部署

安装jenkins

安装gitlab

配置镜像源进行安装

修改密码

安装git工具

上传测试代码

Jenkins部署php项目wordpress

发布php代码

安装插件

测试代码发布

实现发布成功发送邮件通知

利用脚本部署lnmp环境

部署脚本

上传gitlab

发布执行

jenkins结合ansible修改配置文件

安装ansible

编写主机清单

编写jinjia2模板文件

编写playbook文件

测试结果


什么是CI 、CD

CI 、CD一般包含三个概念:持续集成(Continuous Integration ,CI),持续交付(Continuous Delivery),持续部署(Continuous Deploy

  1. 持续集成(CI):

开发人员频繁地将代码集成到共享的代码库中。每次集成都会触发自动化的构建和测试过程。例如,使用工具如 Jenkins、GitLab CI 等,当开发人员将新代码推送至代码仓库时,CI 系统会自动拉取代码,安装依赖项,编译代码,并运行一系列测试用例。如果测试失败,开发人员会立即收到反馈,以便及时修复问题。

  1. 持续交付(CD):

是在持续集成的基础上,确保软件产品可以随时被部署到生产环境或类生产环境。它强调的是软件发布过程的自动化和可重复性,包括从测试环境到预生产环境等各个环节的交付准备,使得软件能够以一种可靠、高效的方式从开发阶段顺利进入发布阶段,但在持续交付中,最终的部署到生产环境可能仍需要人工审批等操作。

  1. 持续部署(CD

可以看作是持续交付的进一步延伸。在持续部署中,一旦代码通过了所有的自动化测试环节,就会自动地部署到生产环境,不需要人工干预。这能够实现软件更新的最快速发布,让新功能和修复能够更快地到达用户手中。

了解到了一个它的基本概念下面学习jenkins集成工具

Jenkins集成工具

持续集成的特点:

  • 是一个自动化的周期性的集成测试过程,从检出代码、编译构建、运行测试,再到结果记录、测试统计等都是自动完成,无需人工干预
  • 需要有专门的集成服务器来执行集成构建
  • 需要有代码托管工具支持

一、Jenkins介绍

Jenkins 原名 Hudson,2011 年修改为 Jenkins,它是一个开源的实现软件持续集成的工具。

官网地址:https://www.jenkins.io/

Jenkins工具的优点:

  1. 易安装:官网下载直接运行
  2. 易配置:提供了友好的 GUI 配置界面
  3. 变更支持:能从代码仓库中获取并产生代码更新列表,输出到编译输出信息
  4. 支持永久链接:用户是通过 Web 来访问 Jenkins 的,而这些 Web 界面的链接地址是可以一直存在的
  5. 支持第三方插件
  6. 能实时监控集成中存在的错误,提供详细的日志文件和提醒功能,还可以用图表的形式形象的展示项目构建的趋势和稳定性。

二、jenkins的安装和部署

这里我们使用centos7进行部署,但要注意centos7已经停止了维护,但是我们只是初步的学习,所以使用centos7依旧可行

还要注意一点的是jenkins是由java开发的工具,所以他需要jdk环境,并且他需要做版本的适配,可见官网

Redhat Jenkins 软件包

环境部署

主机名

IP

角色

web01

192.168.143.162

部署服务的机器

web02

192.168.143.163

Gitlab服务器

web03

192.168.143.164

Jenkins服务器

安装jenkins

在web03上安装jenkins

配置jenkins的源,可按官方进行配置

​
[root@web03 ~]# wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo[root@web03 ~]#  rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key[root@web03 ~]# yum install -y fontconfig[root@web03 ~]# yum install -y Jenkins​

可以看到我这里安装的是2.479的版本,所以下面配置jdk需要17或21

这里需要去官网下载jdk传入web03,因为centos yum安装现在最高只支持11,如果你不想手动配置环境,可以指定下载jenkins,让他适配jdk11就行或者下载rpm包使用yum安装也ok

这里安装jdk 21

[root@web03 ~]# lsanaconda-ks.cfg  jdk-21_linux-x64_bin.rpm[root@web03 ~]# yum install -y jdk-21_linux-x64_bin.rpm

查看版本和执行路径

[root@web03 ~]# java --versionjava 21.0.5 2024-10-15 LTSJava(TM) SE Runtime Environment (build 21.0.5+9-LTS-239)Java HotSpot(TM) 64-Bit Server VM (build 21.0.5+9-LTS-239, mixed mode, sharing)[root@web03 ~]# which java/usr/bin/java启动jenkins[root@web03 ~]# systemctl start jenkins[root@web03 ~]# yum install net-tools记得关闭防火墙[root@web03 ~]# systemctl stop firewalld[root@web03 ~]# systemctl disable firewalldRemoved symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.查看8080端口是否启动[root@web03 ~]# netstat -ntlp

可以看到端口已经起来了

浏览器登录

[root@web03 ~]# cat /var/lib/jenkins/secrets/initialAdminPassword

选择哪一个都可以

这里我选择自定义安装,根据我后续的任务安装对应的插件

选择

自定义创建

安装gitlab

Gitlab是企业常用的远程私有仓库,像这样的远程仓库还有github,gitee等,都能实现对代码的拉取与上传

配置镜像源进行安装

在web02上安装github

配置github镜像源

[root@web02 ~]# cat /etc/yum.repos.d/gitlab.repo[gitlab-ce]name=Gitlab CE Repositorybaseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/gpgcheck=0enabled=1

yum安装

[root@web02 ~]# yum install -y gitlab-ce安装完成后进行自动配置[root@web02 ~]#  gitlab-ctl reconfigure# 启动githlab[root@web02 ~]# gitlab-ctl start

用浏览器访问

端口一般为80或者443

如果出现这个界面,但是报错502,说明是后端其他服务没起来,可能是内存或者磁盘太少导致。最明显的感受就是配置完gitlab,敲命令都非常卡顿,这个时候去虚拟机关机给服务器扩展内存和磁盘就行

扩展后

重新启动服务

Gitlab服务基础命令

gitlab-ctl start        启动gitlab服务gitlab-ctl stop         关闭gitlab服务gitlab-ctl restart      重启gitlab服务

出现登录界面

查看密码,默认用户为root

[root@web02 ~]# cat  /etc/gitlab/initial_root_password

修改密码

进入之后记得修改密码,因为我们使用临时密码进行登陆的

然后进去修改就ok了

创建存储库

点击项目,创建项目,根据个人需求进行勾选,这里我只进行了初始化

最后进行密钥的配置

把web03的公钥添加到gitlab上,只有上传公钥后续才能进行上传代码

编写一个简单的php页面,上传到gitlab仓库

[root@web03 ~]# cat index.php<head><meta charset="UTF-8"><title>简单的PHP页面示例</title></head><body><?php// 使用echo输出一段简单的欢迎文本echo "<h1>欢迎来到这个简单的PHP页面呀!</h1>";?><p>这是普通的HTML文本部分,和PHP代码可以混合编写呢。</p></body></html>

上传到gitlab仓库,需要有git工具,下面配置git工具

安装git工具

这里不使用yum安装,因为centos中yum下载版本有点低

这里从外部传输git

解压配置环境

[root@web03 ~]# tar -zxvf git-2.39.4.tar.gz -C /usr/local/# 配置安装编译依赖[root@web03 ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker -y#切换到目录进行编译,安装[root@web03 git-2.39.4]# make prefix=/usr/local/git all[root@web03 git-2.39.4]# make prefix=/usr/local/git install# 配置环境变量[root@web03 git-2.39.4]# tail -5 /etc/profileunset iunset -f pathmungeexport PATH=$PATH:/usr/local/git/bin[root@web03 git-2.39.4]# source /etc/profile[root@web03 git-2.39.4]# which git
/usr/bin/git

上传测试代码

[root@web03 ~]# lsanaconda-ks.cfg  git-2.39.4.tar.gz  index.php  test[root@web03 ~]# mv index.php test/[root@web03 ~]# cd test/[root@web03 test]# lsindex.php# 初始化构建版本库[root@web03 test]# git init初始化空的 Git 版本库于 /root/test/.git/# 添加文件至暂存区[root@web03 test]# git add index.php# 提交暂存区的内容到分支上[root@web03 test]# git commit -m "php页面"[master(根提交) 560e04f] php页面1 file changed, 15 insertions(+)create mode 100644 index.php# 关联远程仓库[root@web03 test]# git remote add origin git@192.168.143.163:root/php.git[root@web03 test]# git push -u origin mainerror: src refspec main does not match any.error: 无法推送一些引用到 'git@192.168.143.163:root/php.git'# 提交本地分支至远程仓库[root@web03 test]# git push -u origin masterCounting objects: 3, done.Delta compression using up to 4 threads.Compressing objects: 100% (2/2), done.Writing objects: 100% (3/3), 477 bytes | 0 bytes/s, done.Total 3 (delta 0), reused 0 (delta 0)remote:remote: To create a merge request for master, visit:remote:   http://192.168.143.163/root/php/-/merge_requests/new?merge_request%5Bsource_branch%5D=masterremote:To git@192.168.143.163:root/php.git* [new branch]      master -> master分支 master 设置为跟踪来自 origin 的远程分支 master。

这里需要注意的有两点:

  1. 我们需要将配置文件的url改为本机ip,如果进行了DNS解析也可以写主机名,如果不改,拉取代码会报错
#进入/etc/gitlab/gitlab.rb这个配置文件,搜索 external_url 'https://gitlab.example.com'

重启配置

gitlab-ctl reconfiguregitlab-ctl restart
  1. 我们在本地初始化后提交代码,默认会提交到master分支,但是我这里gitlab上默认给我创的main分支,所以上传代码要么更改gitlab库的分支,要么直接上传master分支

不过gitlab是提供了分支合并的

再看masetr分支已经合并到main

Jenkins部署php项目wordpress

再次创建一个存储库

这里下载wordpress.zip包解压后传入gitlab代码仓库

Wordpress官网::https://cn.wordpress.org/download/

[root@web03 ~]#  unzip wordpress-5.5.15-zh_CN.zip[root@web03 ~]# cd wordpress[root@web03 wordpress]# lsindex.php    readme.html      wp-admin            wp-comments-post.php  wp-content   wp-includes        wp-load.php   wp-mail.php      wp-signup.php     xmlrpc.phplicense.txt  wp-activate.php  wp-blog-header.php  wp-config-sample.php  wp-cron.php  wp-links-opml.php  wp-login.php  wp-settings.php  wp-trackback.php# 初始化[root@web03 wordpress]# git init初始化空的 Git 版本库于 /root/wordpress/.git/# 添加当前目录所有文件[root@web03 wordpress]# git add .# 把添加文件提交到分支[root@web03 wordpress]# git commit -m "wordpress博客"[master(根提交) 7c9dfba] wordpress博客2046 files changed, 1111469 insertions(+)# 关联远程仓库[root@web03 wordpress]# git remote add origin git@192.168.143.163:root/wordpress.git# 推送到git仓库[root@web03 wordpress]# git push -u origin masterCounting objects: 2290, done.Delta compression using up to 4 threads.Compressing objects: 100% (2211/2211), done.Writing objects: 100% (2290/2290), 13.56 MiB | 2.21 MiB/s, done.Total 2290 (delta 246), reused 0 (delta 0)remote: Resolving deltas: 100% (246/246), done.remote:remote: To create a merge request for master, visit:remote:   http://192.168.143.163/root/wordpress/-/merge_requests/new?merge_request%5Bsource_branch%5D=masterremote:To git@192.168.143.163:root/wordpress.git* [new branch]      master -> master分支 master 设置为跟踪来自 origin 的远程分支 master。

可以看到文件被推送到了仓库

发布php代码

部署php到指定服务器需要Publish Over SSH插件(发布代码),这个插件用于jenkins连接ssh的,利用这个插件就可以实现代码发布指定服务器

还需要Git 插件来实现拉取代码。

安装插件

安装Publish Over SSH插件

进入系统

在web03上生成密钥对,把私钥填入key中,将公钥分别传入web01,web02

# 生成密钥对的命令,后续一路回车[root@web03 ~]# ssh-keygen -t rsa# 查看生成的密钥[root@web03 ~]# ls ~/.ssh/      #id.rsa为私钥id_rsa  id_rsa.pub

复制给jenkins上的key

# 把公钥复制给其他机器[root@web03 ~]# ssh-copy-id 192.168.143.162[root@web03 ~]# ssh-copy-id 192.168.143.163

添加指定服务器,登录成功

安装git插件

测试代码发布

新建item

添加git仓库,用于拉取代码

添加构建步骤

这里添加需要部署服务的节点,也就是web01主机

这里填写的remote目录必须存在于web01中,而不能为虚构

保存,立即构建

看到出错了

点击箭头,找到控制台输出

定位错误,可以看到它说找不到构建版本

检查git配置

可以看到这里的分支为master,而我git仓库的分支为main

修改配置为main

再次构建

可以看到已经成功

查看web01指定目录

代码已经发布过来了

实现发布成功发送邮件通知

在系统中,找到邮件通知

密码是填写授权码

记得把系统管理地址改为自己的邮箱,不然测试会报错

测试

安装email Extension Plugin

进入系统添加用户和密码

重启jenkins

systemctl restart jenkins

再次进入配置,找到构建后操作,添加扩展邮件

点击高级设置,找到触发器,选择成功时发送给收件人列表,选择高深,添加收件人列表

再次构建

成功发送

利用脚本部署lnmp环境
部署脚本

在web03服务器即jenkins服务器上写一个安装lnmp环境的脚本

#!/bin/bash#基于LAMP架构安装wordpress博客平台#LAMP架构和数据库由yum进行安装# 自定义的安装日志文件
logfile=/var/log/wordpress_install.logtouch $logfile#基础准备工作systemctl stop firewalldsetenforce 0#安装httpd服务yum -y install httpd#检查if [ $? -ne 0 ]; then{echo "安装 httpd 服务失败。错误信息:$(yum -y install httpd 2>&1)" > $logfileexit 1}fiecho "httpd 服务安装成功。" > $logfile#启动httpd服务并设置开机自启systemctl start httpdsystemctl enable httpd#检查yum -y install net-toolsif netstat -lnpt | grep 80; thenecho "httpd服务启动成功" >> /var/log/wordpress_install.logelseecho "httpd服务启动失败"systemctl status httpd >> /var/log/wordpress_install.logfi#下载mariadb数据库yum -y install mariadb mariadb-server mariadb-libsif [ $? -ne 0 ]; thenecho "安装 MariaDB 数据库失败。错误信息:$(yum -y install mariadb mariadb-server mariadb-libs 2>&1)" >> $logfilefiecho "MariaDB 数据库安装成功。" >> $logfilesystemctl start mariadb && systemctl enable mariadb#检查if netstat -lnpt | grep 3306;thenecho "数据库启动成功" >> /var/log/wordpress_install.logelseecho "数据库启动失败"systemctl status mariadb >> /var/log/wordpress_install.logfi# 登录到MySQLmysql -e 'SET PASSWORD FOR 'root'@'localhost' = PASSWORD("123456");'systemctl restart mariadbif ! systemctl restart mariadb; thenecho "重启数据库服务失败,错误信息:$(systemctl status mariadb 2>&1)" >> /var/log/wordpress_install.logfi# 创建WordPress数据库mysql -u root -p123456 -e "CREATE DATABASE wordpress;"
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum-config-manager --enable remi-php70
php=(php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-redis)#下载phpyum -y install "${php[@]}" #检查for package in "${php[@]}"; doecho "$package 安装成功。" >> /var/log/wordpress_install.logdone
systemctl start php-fpm
systemctl enable php-fpm
上传gitlab

新建一个存储库

上传代码

[root@web03 ~]# mkdir lnmp[root@web03 ~]# mv lnmp.sh lnmp/[root@web03 ~]# cd lnmp/[root@web03 lnmp]# lslnmp.sh[root@web03 lnmp]# git init初始化空的 Git 版本库于 /root/lnmp/.git/[root@web03 lnmp]# git add lnmp.sh[root@web03 lnmp]# git commit -m "lnmp环境"[master(根提交) 7ab2687] lnmp环境1 file changed, 155 insertions(+)create mode 100755 lnmp.sh[root@web03 lnmp]# git remote add origin git@192.168.143.163:root/lnmp.git[root@web03 lnmp]# git push -u origin masterCounting objects: 3, done.Delta compression using up to 4 threads.Compressing objects: 100% (2/2), done.Writing objects: 100% (3/3), 1.27 KiB | 0 bytes/s, done.Total 3 (delta 0), reused 0 (delta 0)remote:remote: To create a merge request for master, visit:remote:   http://192.168.143.163/root/lnmp/-/merge_requests/new?merge_request%5Bsource_branch%5D=masterremote:To git@192.168.143.163:root/lnmp.git* [new branch]      master -> master分支 master 设置为跟踪来自 origin 的远程分支 master。

合并分支

发布执行

再次进入jenkins,添加一个git仓库

可以看到它显示结果不稳定

看看文件有传输过去吗

手动执行看看,发现脚本正在执行,可能是网路导致,服务下载出错,导致失败

这里为了证实猜想,手动更新yum源,只对服务进行下载来减少下载时间

jenkins结合ansible修改配置文件
安装ansible

在web03上安装ansible,并在jenkins上安装插件

# 先拉取epel扩展源wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo# 更新yum源yum makecache fast# 安装Ansibleyum -y install ansible

编写主机清单

使用/etc/ansible/hosts或inventory.ini都行

[root@web03 ansible]# cat hosts[web01]192.168.143.162  ansible_ssh_user=root ansible_ssh_pass=050801

测试是否能够正常连接

编写jinjia2模板文件

这里其实没有太多内容添加,更多的是把原文内容复制过来,主要是httpd服务默认未开启php模块(LoadModule php7_module modules/libphp7.so),我们需要手动给他添加

[root@web01 conf]# cat httpd.conf## This is the main Apache HTTP server configuration file.  It contains the# configuration directives that give the server its instructions.# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.# In particular, see# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html># for a discussion of each configuration directive.## Do NOT simply read the instructions in here without understanding# what they do.  They're here only as hints or reminders.  If you are unsure# consult the online docs. You have been warned. ## Configuration and logfile names: If the filenames you specify for many# of the server's control files begin with "/" (or "drive:/" for Win32), the# server will use that explicit path.  If the filenames do *not* begin# with "/", the value of ServerRoot is prepended -- so 'log/access_log'# with ServerRoot set to '/www' will be interpreted by the# server as '/www/log/access_log', where as '/log/access_log' will be# interpreted as '/log/access_log'.## ServerRoot: The top of the directory tree under which the server's# configuration, error, and log files are kept.## Do not add a slash at the end of the directory path.  If you point# ServerRoot at a non-local disk, be sure to specify a local disk on the# Mutex directive, if file-based mutexes are used.  If you wish to share the# same ServerRoot for multiple httpd daemons, you will need to change at# least PidFile.#ServerRoot "/etc/httpd"## Listen: Allows you to bind Apache to specific IP addresses and/or# ports, instead of the default. See also the <VirtualHost># directive.## Change this to Listen on specific IP addresses as shown below to# prevent Apache from glomming onto all bound IP addresses.##Listen 12.34.56.78:80Listen 80## Dynamic Shared Object (DSO) Support## To be able to use the functionality of a module which was built as a DSO you# have to place corresponding `LoadModule' lines at this location so the# directives contained in it are actually available _before_ they are used.# Statically compiled modules (those listed by `httpd -l') do not need# to be loaded here.## Example:# LoadModule foo_module modules/mod_foo.so#{{ php_modules }}Include conf.modules.d/*.conf## If you wish httpd to run as a different user or group, you must run# httpd as root initially and it will switch. ## User/Group: The name (or #number) of the user/group to run httpd as.# It is usually good practice to create a dedicated user and group for# running httpd, as with most system services.#User apacheGroup apache# 'Main' server configuration## The directives in this section set up the values used by the 'main'# server, which responds to any requests that aren't handled by a# <VirtualHost> definition.  These values also provide defaults for# any <VirtualHost> containers you may define later in the file.## All of these directives may appear inside <VirtualHost> containers,# in which case these default settings will be overridden for the# virtual host being defined.### ServerAdmin: Your address, where problems with the server should be# e-mailed.  This address appears on some server-generated pages, such# as error documents.  e.g. admin@your-domain.com#ServerAdmin root@localhost## ServerName gives the name and port that the server uses to identify itself.# This can often be determined automatically, but we recommend you specify# it explicitly to prevent problems during startup.## If your host doesn't have a registered DNS name, enter its IP address here.##ServerName www.example.com:80## Deny access to the entirety of your server's filesystem. You must# explicitly permit access to web content directories in other# <Directory> blocks below.#<Directory />AllowOverride noneRequire all denied</Directory>## Note that from this point forward you must specifically allow# particular features to be enabled - so if something's not working as# you might expect, make sure that you have specifically enabled it# below.### DocumentRoot: The directory out of which you will serve your# documents. By default, all requests are taken from this directory, but# symbolic links and aliases may be used to point to other locations.#DocumentRoot "/var/www/html"## Relax access to content within /var/www.#<Directory "/var/www">AllowOverride None# Allow open access:Require all granted</Directory># Further relax access to the default document root:<Directory "/var/www/html">## Possible values for the Options directive are "None", "All",# or any combination of:#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews## Note that "MultiViews" must be named *explicitly* --- "Options All"# doesn't give it to you.## The Options directive is both complicated and important.  Please see# http://httpd.apache.org/docs/2.4/mod/core.html#options# for more information.#Options Indexes FollowSymLinks## AllowOverride controls what directives may be placed in .htaccess files.# It can be "All", "None", or any combination of the keywords:#   Options FileInfo AuthConfig Limit#AllowOverride None## Controls who can get stuff from this server.#Require all granted</Directory>## DirectoryIndex: sets the file that Apache will serve if a directory# is requested.#<IfModule dir_module>DirectoryIndex index.html</IfModule>## The following lines prevent .htaccess and .htpasswd files from being# viewed by Web clients.#<Files ".ht*">Require all denied</Files>## ErrorLog: The location of the error log file.# If you do not specify an ErrorLog directive within a <VirtualHost># container, error messages relating to that virtual host will be# logged here.  If you *do* define an error logfile for a <VirtualHost># container, that host's errors will be logged there and not here.#ErrorLog "logs/error_log"## LogLevel: Control the number of messages logged to the error_log.# Possible values include: debug, info, notice, warn, error, crit,# alert, emerg.#LogLevel warn<IfModule log_config_module>## The following directives define some format nicknames for use with# a CustomLog directive (see below).#LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedLogFormat "%h %l %u %t \"%r\" %>s %b" common<IfModule logio_module># You need to enable mod_logio.c to use %I and %OLogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio</IfModule>## The location and format of the access logfile (Common Logfile Format).# If you do not define any access logfiles within a <VirtualHost># container, they will be logged here.  Contrariwise, if you *do*# define per-<VirtualHost> access logfiles, transactions will be# logged therein and *not* in this file.##CustomLog "logs/access_log" common## If you prefer a logfile with access, agent, and referer information# (Combined Logfile Format) you can use the following directive.#CustomLog "logs/access_log" combined</IfModule><IfModule alias_module>## Redirect: Allows you to tell clients about documents that used to# exist in your server's namespace, but do not anymore. The client# will make a new request for the document at its new location.# Example:# Redirect permanent /foo http://www.example.com/bar## Alias: Maps web paths into filesystem paths and is used to# access content that does not live under the DocumentRoot.# Example:# Alias /webpath /full/filesystem/path## If you include a trailing / on /webpath then the server will# require it to be present in the URL.  You will also likely# need to provide a <Directory> section to allow access to# the filesystem path.## ScriptAlias: This controls which directories contain server scripts.# ScriptAliases are essentially the same as Aliases, except that# documents in the target directory are treated as applications and# run by the server when requested rather than as documents sent to the# client.  The same rules about trailing "/" apply to ScriptAlias# directives as to Alias.#ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"</IfModule>## "/var/www/cgi-bin" should be changed to whatever your ScriptAliased# CGI directory exists, if you have that configured.#<Directory "/var/www/cgi-bin">AllowOverride NoneOptions NoneRequire all granted</Directory><IfModule mime_module>## TypesConfig points to the file containing the list of mappings from# filename extension to MIME-type.#TypesConfig /etc/mime.types## AddType allows you to add to or override the MIME configuration# file specified in TypesConfig for specific file types.##AddType application/x-gzip .tgz## AddEncoding allows you to have certain browsers uncompress# information on the fly. Note: Not all browsers support this.##AddEncoding x-compress .Z#AddEncoding x-gzip .gz .tgz## If the AddEncoding directives above are commented-out, then you# probably should define those extensions to indicate media types:#AddType application/x-compress .ZAddType application/x-gzip .gz .tgz## AddHandler allows you to map certain file extensions to "handlers":# actions unrelated to filetype. These can be either built into the server# or added with the Action directive (see below)## To use CGI scripts outside of ScriptAliased directories:# (You will also need to add "ExecCGI" to the "Options" directive.)##AddHandler cgi-script .cgi# For type maps (negotiated resources):#AddHandler type-map var## Filters allow you to process content before it is sent to the client.## To parse .shtml files for server-side includes (SSI):# (You will also need to add "Includes" to the "Options" directive.)#AddType text/html .shtmlAddOutputFilter INCLUDES .shtml</IfModule>## Specify a default charset for all content served; this enables# interpretation of all content as UTF-8 by default.  To use the# default browser choice (ISO-8859-1), or to allow the META tags# in HTML content to override this choice, comment out this# directive:#AddDefaultCharset UTF-8<IfModule mime_magic_module>## The mod_mime_magic module allows the server to use various hints from the# contents of the file itself to determine its type.  The MIMEMagicFile# directive tells the module where the hint definitions are located.#MIMEMagicFile conf/magic</IfModule>## Customizable error responses come in three flavors:# 1) plain text 2) local redirects 3) external redirects## Some examples:#ErrorDocument 500 "The server made a boo boo."#ErrorDocument 404 /missing.html#ErrorDocument 404 "/cgi-bin/missing_handler.pl"#ErrorDocument 402 http://www.example.com/subscription_info.html### EnableMMAP and EnableSendfile: On systems that support it,# memory-mapping or the sendfile syscall may be used to deliver# files.  This usually improves server performance, but must# be turned off when serving from networked-mounted# filesystems or if support for these functions is otherwise# broken on your system.# Defaults if commented: EnableMMAP On, EnableSendfile Off##EnableMMAP offEnableSendfile on# Supplemental configuration## Load config files in the "/etc/httpd/conf.d" directory, if any.IncludeOptional conf.d/*.conf
编写playbook文件
[root@web03 ansible]# cat httpd.yml---- name: httpd confighosts: web01vars:- php_modules: LoadModule php7_module modules/libphp7.sotasks:- name: change configtemplate:src: /etc/ansible/http.conf.j2dest: /etc/httpd/conf/httpd.confnotify: restarthandlers:- name: restartservice:name: httpdstate: restarted

管理jenkins找到工具,进入找到ansible安装,配置ansible执行路径

进入jenkins项目配置,构建步骤添加ansible playbook命令

给出playbook文件路径,主机清单文件

测试结果

再次构建

相关文章:

jenkins集成工具(一)部署php项目

目录 什么是CI 、CD Jenkins集成工具 一、Jenkins介绍 二、jenkins的安装和部署 环境部署 安装jenkins 安装gitlab 配置镜像源进行安装 修改密码 安装git工具 上传测试代码 Jenkins部署php项目wordpress 发布php代码 安装插件 测试代码发布 实现发布成功发送邮件…...

17_HTML5 Web 存储 --[HTML5 API 学习之旅]

HTML5 Web 存储&#xff08;Web Storage&#xff09;是 HTML5 引入的一种在用户浏览器中存储数据的机制。它提供了比传统的 cookies 更加方便和强大的功能&#xff0c;包括更大的存储空间、更好的性能以及更简单的 API。Web 存储主要分为两种类型&#xff1a;localStorage 和 s…...

GCP Cloud Architect exam - PASS

备考指南 推荐视频课程 https://www.udemy.com/course/google-cloud-architect-certifications/?couponCodeKEEPLEARNING 推荐题库 https://www.udemy.com/course/gcp-professional-cloud-architect-exam-practice-tests-2024​/?couponCodeKEEPLEARNING 错题集 http…...

【Sentinel】初识Sentinel

目录 1.1.雪崩问题及解决方案 1.1.1.雪崩问题 1.1.2.超时处理 1.1.3.仓壁模式 1.1.4.断路器 1.1.5.限流 1.1.6.总结 1.2.服务保护技术对比 1.3.Sentinel介绍和安装 1.3.1.初识Sentinel 1.3.2.安装Sentinel 1.4.微服务整合Sentinel 1.1.雪崩问题及解决方案 1.1.1.…...

java常见类库

StringBuffer类 String和StringBuffer的区别 String 不可变性&#xff1a;String 类是不可变的&#xff0c;这意味着一旦创建了一个 String 对象&#xff0c;其值就不能改变。每次对 String 进行修改&#xff08;如连接、替换等操作&#xff09;都会产生新的 String 对象&…...

Wordly Wise 3000 国际背单词01 介绍 + 测词汇量

&#x1f4da; Wordly Wise 3000 国际背单词01 介绍 测词汇量 &#x1f31f; 大家好&#xff01;我们正式启动背Wordly Wise 3000单词&#xff0c;旨在利用国际资源和科学的学练方法&#xff0c;帮助大家更得效地坚持学练单词。我们将通过图文和Video等多种形式与大家分享经验…...

Unity Dots理论学习-2.ECS有关的模块(1)

Unity的实体组件系统&#xff08;ECS&#xff09;是支撑DOTS模块和技术的面向数据架构。ECS为Unity中的内存数据和runtime进程调度提供了高度的控制和确定性。 ECS for Unity 2022 LTS 配备了两个兼容的物理引擎&#xff0c;一个高级的Netcode package&#xff0c;以及一个用来…...

2021.12.28基于UDP同信的相关流程

作业 1、将TCP的CS模型再敲一遍 服务器 #include <myhead.h> #define PORT 8888 #define IP "192.168.124.123" int main(int argc, const char *argv[]) {//创建套接字//绑定本机IP和端口号//监听客户端请求//接收客户端连接请求//收发消息//创建套接字int…...

使用 Docker 搭建 Hadoop 集群

1.1. 启用 WSL 与虚拟机平台 1.1.1. 启用功能 启用 WSL并使用 Moba 连接-CSDN博客 1.2 安装 Docker Desktop 最新版本链接&#xff1a;Docker Desktop: The #1 Containerization Tool for Developers | Docker 指定版本链接&#xff1a;Docker Desktop release notes | Do…...

optuna和 lightgbm

文章目录 optuna使用1.导入相关包2.定义模型可选参数3.定义训练代码和评估代码4.定义目标函数5.运行程序6.可视化7.超参数的重要性8.查看相关信息9.可视化的一个完整示例10.lightgbm实验 optuna使用 1.导入相关包 import torch import torch.nn as nn import torch.nn.functi…...

Android 设置铃声和闹钟

Android设置铃声和闹钟使用的方法是一样的&#xff0c;但是要区别的去获取对应的权限。 统一权限&#xff0c;不管是设置闹钟还是铃声&#xff0c;他们都需要一个系统设置权限如下: //高版本需要WRITE_SETTINGS权限//此权限是敏感权限&#xff0c;无法动态申请&#xff0c;需要…...

自动化测试模型(一)

8.8.1 自动化测试模型概述 在自动化测试运用于测试工作的过程中&#xff0c;测试人员根据不同自动化测试工具、测试框架等所进行的测试活动进行了抽象&#xff0c;总结出线性测试、模块化驱动测试、数据驱动测试和关键字驱动测试这4种自动化测试模型。 线性测试 首先&#…...

解决nuxt3下载慢下载报错问题

在下载nuxt3时总是下不下来&#xff0c;最后还报错了。即使改成国内镜像源也不行。 解决方法&#xff1a; 直接去github上下载 https://github.com/nuxt/starter/tree/v3 解压后得到如下目录&#xff1a; 手动修改项目名和文件夹名 安装依赖 npm install可能会比较慢或下不…...

Ubuntu修改swap大小

查看swap位置和大小&#xff1a; swapon -s 方案一&#xff1a;修改原有文件大小方式 第一步&#xff1a;进入系统根目录cd /; 第二步&#xff1a;执行&#xff1a;sudo dd if/dev/zero of/swap bs1M count16384 //每段块1M 共16384块&#xff0c;即16G 第三步&#xff1a;执行…...

[C#] 复数乘法的跨平台SIMD硬件加速向量算法(不仅支持X86的Sse、Avx、Avx512,还支持Arm的AdvSimd)

文章目录 一、简单算法二、向量算法2.1 算法思路2.1.1 复数乘法的数学定义2.1.2 复数的数据布局2.1.3 第1步&#xff1a;计算 (a*c) (-b*d)i2.1.4 第2步&#xff1a;计算 (a*d) (b*c)i2.1.5 第3步&#xff1a;计算结果合并 2.2 算法实现&#xff08;UseVectors&#xff09;2.…...

C#WPF基础介绍/第一个WPF程序

什么是WPF WPF&#xff08;Windows Presentation Foundation&#xff09;是微软公司推出的一种用于创建窗口应用程序的界面框架。它是.NET Framework的一部分&#xff0c;提供了一套先进的用户界面设计工具和功能&#xff0c;可以实现丰富的图形、动画和多媒体效果。 WPF 使用…...

强大的接口测试可视化工具:Postman Flows

Postman Flows是一种接口测试可视化工具&#xff0c;可以使用流的形式在Postman工作台将请求接口、数据处理和创建实际流程整合到一起。如下图所示 Postman Flows是以API为中心的可视化应用程序开发界面。它提供了一个无限的画布用于编排和串连API&#xff0c;数据可视化来显示…...

系统设计及解决方案

发送验证码 1&#xff1a;根据手机号从Redis中获取value(验证码_时间戳) 2&#xff1a;如果value不为空&#xff0c;并且时间戳与当前时间戳的间隔小于60秒&#xff0c;则返回一个错误信息 3&#xff1a;生成随机验证码 4&#xff1a;调用阿里云短信服务API给用户发送短信验证码…...

从0入门自主空中机器人-2-2【无人机硬件选型-PX4篇】

1. 常用资料以及官方网站 无人机飞控PX4用户使用手册&#xff08;无人机基本设置、地面站使用教程、软硬件搭建等&#xff09;&#xff1a;https://docs.px4.io/main/en/ PX4固件开源地址&#xff1a;https://github.com/PX4/PX4-Autopilot 飞控硬件、数传模块、GPS、分电板等…...

Linux之ARM(MX6U)裸机篇----2.汇编LED驱动实验

一&#xff0c;alpha的LED灯硬件原理分析 STM32 IO初始化流程 ①&#xff0c;使能GPIO时钟 ②&#xff0c;设置IO复用&#xff0c;复用为GPIO ③&#xff0c;配置GPIO的电气属性推挽&#xff0c;上拉下拉 ④&#xff0c;使用GPIO&#xff0c;输出高/低电平 MX6ULL IO初始化…...

STM标准库-TIM旋转编码器

文章目录 一、编码器接口1.1简介1.2正交编码器1.3编码器接口基本结构**1. 模块与 STM32 配置的映射关系****2. 设计实现步骤&#xff08;核心流程&#xff09;****① 硬件规划****② 时钟使能****③ GPIO 配置&#xff08;对应架构图 “GPIO” 模块&#xff09;****④ 时基单元…...

CAN通信收发测试(USB2CAN模块测试实验)

1.搭建测试环境 电脑&#xff1a;安装 USB 驱动&#xff0c;安装原厂调试工具&#xff0c;安装cangaroo&#xff08;参考安装包的入门教程即可&#xff09; USB驱动路径&#xff1a;~\CAN分析仪资料20230701_Linux\硬件驱动程序 原厂调试工具路径&#xff1a;~\CAN分析仪资料2…...

Linux编程:2、进程基础知识

一、进程基本概念 1、进程与程序的区别 程序&#xff1a;静态的可执行文件&#xff08;如电脑中的vs2022安装程序&#xff09;。进程&#xff1a;程序的动态执行过程&#xff08;如启动后的vs2022实例&#xff09;&#xff0c;是操作系统分配资源的单位&#xff08;如 CPU 时…...

第六十二节:深度学习-加载 TensorFlow/PyTorch/Caffe 模型

在计算机视觉领域,OpenCV的DNN(深度神经网络)模块正逐渐成为轻量级模型部署的利器。本文将深入探讨如何利用OpenCV加载和运行三大主流框架(TensorFlow、PyTorch、Caffe)训练的模型,并提供完整的代码实现和优化技巧。 一、OpenCV DNN模块的核心优势 OpenCV的DNN模块自3.3…...

MobaXterm配置跳转登录堡垒机

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 背景操作步骤 背景 主要是为了能通过MobaXterm登录堡垒机&#xff0c;其中需要另外一台服务器进行跳转登录 操作步骤 MobaXterm登录堡垒机的操作&#xff0c;需…...

多模态大语言模型arxiv论文略读(109)

Math-PUMA: Progressive Upward Multimodal Alignment to Enhance Mathematical Reasoning ➡️ 论文标题&#xff1a;Math-PUMA: Progressive Upward Multimodal Alignment to Enhance Mathematical Reasoning ➡️ 论文作者&#xff1a;Wenwen Zhuang, Xin Huang, Xiantao Z…...

Java Stream 高级实战:并行流、自定义收集器与性能优化

一、并行流深度实战&#xff1a;大规模数据处理的性能突破 1.1 并行流的核心应用场景 在电商用户行为分析场景中&#xff0c;需要对百万级用户日志数据进行实时统计。例如&#xff0c;计算某时段内活跃用户数&#xff08;访问次数≥3次的用户&#xff09;&#xff0c;传统循环…...

数论总结,(模版与题解)

数论 欧拉函数X质数&#xff08;线性筛与二进制枚举&#xff09;求解组合数欧拉降幂&#xff08;乘积幂次&#xff09;乘法逆元最小质因子之和模版 欧拉函数 欧拉函数的定义就是小于等于n的数里有f(n)个数与n互质&#xff0c;下面是求欧拉函数的模版。 package com.js.datas…...

计算机网络第2章(下):物理层传输介质与核心设备全面解析

目录 一、传输介质1.1 传输介质的分类1.2 导向型传输介质1.2.1 双绞线&#xff08;Twisted Pair&#xff09;1.2.2 同轴电缆&#xff08;Coaxial Cable&#xff09;1.2.3 光纤&#xff08;Optical Fiber&#xff09;1.2.4 以太网对有线传输介质的命名规则 1.3 非导向型传输介质…...

使用 Coze 工作流一键生成抖音书单视频:全流程拆解与技术实现

使用 Coze 工作流一键生成抖音书单视频&#xff1a;全流程拆解与技术实现&#xff08;提供工作流&#xff09; 摘要&#xff1a;本文基于一段关于使用 Coze 平台构建抖音爆火书单视频的详细讲解&#xff0c;总结出一套完整的 AI 视频自动化制作流程。内容涵盖从思路拆解、节点配…...