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)。
- 持续集成(CI):
开发人员频繁地将代码集成到共享的代码库中。每次集成都会触发自动化的构建和测试过程。例如,使用工具如 Jenkins、GitLab CI 等,当开发人员将新代码推送至代码仓库时,CI 系统会自动拉取代码,安装依赖项,编译代码,并运行一系列测试用例。如果测试失败,开发人员会立即收到反馈,以便及时修复问题。
- 持续交付(CD):
是在持续集成的基础上,确保软件产品可以随时被部署到生产环境或类生产环境。它强调的是软件发布过程的自动化和可重复性,包括从测试环境到预生产环境等各个环节的交付准备,使得软件能够以一种可靠、高效的方式从开发阶段顺利进入发布阶段,但在持续交付中,最终的部署到生产环境可能仍需要人工审批等操作。
- 持续部署(CD):
可以看作是持续交付的进一步延伸。在持续部署中,一旦代码通过了所有的自动化测试环节,就会自动地部署到生产环境,不需要人工干预。这能够实现软件更新的最快速发布,让新功能和修复能够更快地到达用户手中。
了解到了一个它的基本概念下面学习jenkins集成工具
Jenkins集成工具
持续集成的特点:
- 是一个自动化的周期性的集成测试过程,从检出代码、编译构建、运行测试,再到结果记录、测试统计等都是自动完成,无需人工干预
- 需要有专门的集成服务器来执行集成构建
- 需要有代码托管工具支持
一、Jenkins介绍
Jenkins 原名 Hudson,2011 年修改为 Jenkins,它是一个开源的实现软件持续集成的工具。
官网地址:https://www.jenkins.io/
Jenkins工具的优点:
- 易安装:官网下载直接运行
- 易配置:提供了友好的 GUI 配置界面
- 变更支持:能从代码仓库中获取并产生代码更新列表,输出到编译输出信息
- 支持永久链接:用户是通过 Web 来访问 Jenkins 的,而这些 Web 界面的链接地址是可以一直存在的
- 支持第三方插件
- 能实时监控集成中存在的错误,提供详细的日志文件和提醒功能,还可以用图表的形式形象的展示项目构建的趋势和稳定性。
二、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。
这里需要注意的有两点:
- 我们需要将配置文件的url改为本机ip,如果进行了DNS解析也可以写主机名,如果不改,拉取代码会报错
#进入/etc/gitlab/gitlab.rb这个配置文件,搜索 external_url 'https://gitlab.example.com'
重启配置
gitlab-ctl reconfiguregitlab-ctl restart
- 我们在本地初始化后提交代码,默认会提交到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代码 安装插件 测试代码发布 实现发布成功发送邮件…...
ubuntu 使用samba与windows共享文件[注意权限配置]
在Ubuntu上使用Samba服务与Windows系统共享文件,需要正确配置Samba服务以及相应的权限。以下是详细的步骤: 安装Samba 首先,确保你的Ubuntu系统上安装了Samba服务。 sudo apt update sudo apt install samba配置Samba 安装完成后,…...
【GridView渐进全解】第四部分GridView分页进阶
目录 一、启用分页 二、修改GridView分页模板 1.进入控件模板修改视图: 2.进入页码模板(PagerTemplate)视图 3.添加导航按钮控件 4.修改导航控件属性 三、输入页号跳转 1.进入页码模板视图 2.添加文本框及按钮控件 3.编写代码 【接…...
K8s集群平滑升级(Smooth Upgrade of K8S Cluster)
简介: Kubernetes (简称K8s)是一个开源的容器编排和管理平台,由Google开发并维护。它最初是为了解决谷歌内部大规模容器管理的问题而设计的,后来在2014年开源,成为云原生技术的核心组成部分。1 K8…...
HarmonyOS-面试整理
目录 为什么选择HarmonyOS/ 优点/特点鸿蒙系统的权限有哪些说一说鸿蒙系统的安全机制说一说鸿蒙系统的微内核与安卓的内核区别鸿蒙操作系统的微内核架构有哪些优势分布式能力在鸿蒙系统中如何实现请解释一下鸿蒙系统中的分布式软总线技术如何在鸿蒙操作系统中进行多设备协同开发…...
基于编程语言的知识图谱表示增强大模型推理能力研究,一种提升LLM推理准确率达91.5%的结构化数据方法
基于编程语言的知识图谱表示增强大模型推理能力研究,一种提升LLM推理准确率达91.5%的结构化数据方法 理解数据分析全流程提问问题:知识的表示方式如何影响模型的推理能力?问题:为什么编程语言会是一个更好的知识表示选择ÿ…...
【北京迅为】iTOP-4412全能版使用手册-第七十章 Linux内核移植
iTOP-4412全能版采用四核Cortex-A9,主频为1.4GHz-1.6GHz,配备S5M8767 电源管理,集成USB HUB,选用高品质板对板连接器稳定可靠,大厂生产,做工精良。接口一应俱全,开发更简单,搭载全网通4G、支持WIFI、蓝牙、…...
使用 ASP.NET Core wwwroot 上传和存储文件
在 ASP.NET Core 应用程序中上传和存储文件是用户个人资料、产品目录等功能的常见要求。本指南将解释使用wwwroot存储图像(可用于文件)的过程以及如何在应用程序中处理图像上传。 步骤 1:设置项目环境 确保您的 ASP.NET 项目中具有必要的依…...
什么是 Azure OpenAI ?了解微软 Azure OpenAI 和 OpenAI 的关系
一、什么是Azure OpenAI ? 微软已与 OpenAI 合作以实现三个主要目标: ⦿利用 Azure 的基础结构(包括安全性、合规性和区域可用性),帮助用户构建企业级应用程序。 ⦿在微软产品(包括 Azure AI 产品以及以外…...
Flink CDC 自定义函数处理 SQLServer XML类型数据 映射 doris json字段方案
Flink CDC 自定义函数处理 SQLServer XML类型数据方案 1. 背景 因业务使用SQLServer数据库,CDC同步到doris 数仓。对于SQLServer xml类型,doris没有相应的字段对应, 可以使用json来存储xml数据。需要进行一步转换。从 flink 自定义函数入手…...
导致启动nacos报错Caused by: java.lang.IllegalStateException: No DataSource set 的两种原因
Java资深小白,不足之处,或者有任何错误欢迎指出。 --蓝紫报错代码如下: C:\Windows\System32>cd D:\nacos-server-2.2.3\nacos\binC:\Windows\System32>d:D:\nacos-server-2.2.3\nacos\bin>startup.cmd -m standalone "nacos is starting…...
mysql乱码、mysql数据中文问号
网上排出此错误方法的很多,但是 都不简洁,找不到根本原因 主要排查两点: 1.代码中jdbc链接的编码规则 urljdbc:mysql://localhost:3306/title?useUnicodetrue&characterEncodingutf8 将characterEncoding设置为utf8 2.设置mysq…...
python RAG 管道
RAG(RetrievalAugmented Generation)管道是一种结合了信息检索(Retrieval)和文本生成(Generation)的技术框架,主要用于生成高质量、基于事实的文本。它通过从外部知识源(如文档、数据…...
018-spring-基于aop的事务控制
1 先配置平台事务管理器 2 在配置 spring提供的advice 3 事务增强的aop 总结: 事务就是要做2个配置: <!-- 1 开启事务管理器 不同的框架对应不同的事务管理器 --> <bean id"transactionManager" class"org.springframework.j…...
HTML 轮播图(Carousel)详细讲解
HTML 轮播图(Carousel)详细讲解 轮播图(Carousel)是一种常见的用户界面组件,用于在同一位置展示多个图像或内容,允许用户通过滑动或自动播放的方式查看不同的内容。它通常用于展示产品、图片、广告等。 1…...
计算机网络-数据链路层(ppp协议)
2.2 ppp协议 点对点协议ppp是目前使用最广泛的点对点数据链路层协议。 2.3 媒体接入控制基本概念 共享信道要着重考虑的一个问题就是如何协调多个发送和接收站点对一个共享传输媒体的占用,即媒体接入控制MAC。 2.3.1 静态划分信道 频分复用 时分复用 波分复用 码分复…...
如何优化Python网络爬虫的数据清洗流程,以提升数据质量并有效应对网站反爬虫机制?
优化爬虫数据清洗流程,应对反爬虫机制 一、数据清洗的重要性 在网络爬虫中,数据清洗是关键环节。打个比方,我们从网页抓取到的原始数据就像一堆杂乱的杂物,里面有各种格式、错误和重复信息。比如抓取到的文本可能包含HTML标签、…...
QSharedMemory 实现数据exe间共享
定义共享数据结构 首先,需要定义一个结构体来包含要共享的数据。这个结构体应该包含所有需要在多个类的实例之间共享的成员变量 struct SharedData {int intValue;QString stringValue;// 可以添加更多需要共享的成员变量}; 使用 QSharedMemory 进行数据共享 在写…...
强化学习(1)
Reinforcement Learning Goal-directed learing from ineraction with the environment. 1. Basic Element 基本元素 1.1 Agent 玩家 1.2 Environment 1.3 Goal 2. Main Element 主要元素 2.1 State 2.2 Action 状态与行为往复 2.3 Reward 目标:最大化总…...
Spring Boot 嵌套事务详解及失效解决方案
在复杂的业务场景中,嵌套事务可以帮助我们更加精细地控制数据的一致性。然而,在 Spring Boot 中,如果嵌套事务的配置不当,可能会导致事务不生效的问题,尤其是在同一个类中进行方法调用时。 本文将详细介绍嵌套事务的原…...
IDEA 社区版 SpringBoot不能启动
报错原因,Failed to load class [javax.servlet.Filter] <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-tomcat</artifactId><scope>provided</scope> </dependency>…...
【SQL server】教材数据库(4)
学生(学号,年龄,性别,系名) 教材(编号,书名,出版社编号,价格) 订购(学号,书号,数量) 出版社(编…...
px、em、rem,vw区别介绍
在网页设计中,px、em、rem 和 vw 都是常用的 CSS 单位,它们各自有不同的用途和特性。下面是这些单位的详细介绍及其区别: 1. px(像素) 定义: px 是最常用的绝对单位,表示屏幕上的一个物理像素…...
pip安装paddle失败
一、pip安装paddle失败,报错如下 Preparing metadata (setup.py) ... error error: subprocess-exited-with-error import common, dual, tight, data, prox ModuleNotFoundError: No module named common [end of output] 二、解决方法: 按照提示安装对…...
QWT 之 QwtPlotDirectPainter直接绘制
QwtPlotDirectPainter 是 Qwt 库中用于直接在 QwtPlot 的画布上绘制图形的一个类。它提供了一种高效的方法来实时更新图表,特别适合需要频繁更新的数据可视化应用,例如实时数据流的显示。 使用 QwtPlotDirectPainter 的主要优势在于它可以绕过 QwtPlot 的…...
编辑音频的基本属性
导入音频 “文件-导入-选择音频”拖到音频轨道创建序列。选择音频,在效果空间可以看到音频的基本属性。 音量的设置 “效果工作区-效果控件-音量”在这里可以控制所有引导的混合音量 静音 静止所有声音 音频仪表 一般位于时间轴的后面,找不到可以…...
【英特尔IA-32架构软件开发者开发手册第3卷:系统编程指南】2001年版翻译,2-44
文件下载与邀请翻译者 学习英特尔开发手册,最好手里这个手册文件。原版是PDF文件。点击下方链接了解下载方法。 讲解下载英特尔开发手册的文章 翻译英特尔开发手册,会是一件耗时费力的工作。如果有愿意和我一起来做这件事的,那么ÿ…...
格式化输出年月日
直接上图 结论:老老实实用yyyy,得到的年月日是我们口头上说的时间,而YYYY有点反人类.... 对于一年的最后一周的一些日子,会统计成下一年; 对于下一年的第一周的一些日子,会统计成上一年; 你猜…...
解决Spring boot集成quartz时service注入失败为null的问题
解决Spring boot集成quartz时service注入失败为null的问题 一、报错信息二、代码任务类源代码配置类原代码 三、注入失败原因四、解决的思路11、任务类修改2、配置类修改 五、 解决的思路2 一、报错信息 java.lang.NullPointerException: null at farbun.server.scheduledTask…...
Python 青铜宝剑十六维,破医疗数智化难关(下)
九、模型可靠性的验证秘籍 在医疗数智化进程中,模型可靠性宛如一座灯塔,为精准医疗决策指引方向。以疾病诊断模型为例,一旦模型可靠性存疑,在癌症早期筛查场景下,可能将良性病变误判为恶性,让患者承受不必要的痛苦与恐慌,又或是遗漏细微癌变迹象,延误最佳治疗时机;在…...
初识具身智能
具身智能是智能科学的一个基础问题,在过去的5.4亿年以来,地球上所有生物都是通过身体和环境交互、进化逐步产生的。通俗地讲,具身智能体以第一人称视角身临其境地从环境交互中理解外部世界的本质概念,被认为是通向通用人工智能的重…...
Node 使用pkg打包部署
一、安装pkg(不太好装,需要借助国内镜像) npm install -g pkg --registryhttps://registry.npm.taobao.org 二、配置package.jsonsan // package.json ,配置专门制定pkg的执行入口 { ... "bin": "main.js", "pkg":{"assets&q…...
计算机网络-L2TP Over IPSec基础实验
一、概述 上次我们进行了标准L2TP的配置,但是在最后我们在进行业务流量访问时看到流量是没有进行加密的,这就导致可能得安全风险,所以这里其实可以退像GRE那样调用IPSec框架来进行加密保护。 拓扑 数据不加密 现在需要配置IPSec,然…...
Java工程师实现视频文件上传minio文件系统存储及网页实现分批加载视频播放
Java工程师实现minio存储大型视频文件网页实现分批加载视频播放 一、需求说明 老板给我出个题目,让我把的电影文件上传到minio文件系统,再通过WEB端分配加载视频播放,类似于我们普通的电影网站。小编把Java代码共享出来。是真正的能拿过来直…...
html5css3
1.html5新增语义化标签 <header><nav><article><section><aside><footer> 2.新增多媒体标签 视频<video>格式:map4,webm,ogg <video controls"controls" autoplay"autoplay" muted"mute…...
运维人员的Go语言学习路线
以下是一份更为详细的适合运维人员的Go语言学习路线图: 一、基础环境搭建与入门(第 1 - 2 周) 第 1 周 环境搭建 在本地开发机和常用的运维服务器环境(如 Linux 系统)中安装 Go 语言。从官方网站(https://…...
怎么在家访问公司服务器?
在日常工作中,特别是对信息技术从业者而言,工作往往离不开公司的服务器。他们需要定期访问服务器,获取一些关键的机密文件或数据。如果您在家办公,并且需要处理未完成的任务,同时需要从公司服务器获取所需的数据&#…...
【linux学习指南】】Ext系列文件系统(三)ext2 文件系统的认识与构成
文章目录 📝ext2 ⽂件系统🌠 宏观认识🌉 Block Group 🌠块组内部构成🌉超级块(SuperBlock) 🌠GDT(GroupDescriptorTable)🌉块位图(Blo…...
区块链安全常见的攻击分析——Unprotected callback - ERC721 SafeMint reentrancy【8】
区块链安全常见的攻击分析——Unprotected callback - ERC721 SafeMint reentrancy【8】 1.1 漏洞分析1.2 漏洞合约1.3 攻击分析1.4 攻击合约 重点:MaxMint721 漏洞合约的 mint 函数调用了 ERC721 合约中的 _checkOnERC721Received 函数,触发 to 地址中实…...
Linux中sed命令的使用技巧
一、sed语法介绍 sed命令主要用于文本内容的编辑,默认只处理模式空间,不处理原数据。 命令格式: sed [option] command filename示例:删除空白行 sed ‘/^\s*$/d’ filename option 参数: -n:只有经过sed…...
小米路由器开启SSH,配置阿里云ddns,开启外网访问SSH和WEB管理界面
文章目录 前言一、开启SSH二、配置阿里云ddns1.准备工作2.创建ddns脚本3.添加定时任务 三、开启外网访问SSH和WEB管理界面1、解除WEB管理页面访问限制2.手动添加防火墙端口转发规则,开启外网访问WEB管理和SSH 前言 例如:随着人工智能的不断发展…...
Flink源码解析之:如何根据JobGraph生成ExecutionGraph
Flink源码解析之:如何根据JobGraph生成ExecutionGraph 在上一篇Flink源码解析中,我们介绍了Flink如何根据StreamGraph生成JobGraph的流程,并着重分析了其算子链的合并过程和JobGraph的构造流程。 对于StreamGraph和JobGraph的生成来说&…...
活动预告 |【Part2】Microsoft 安全在线技术公开课:安全性、合规性和身份基础知识
课程介绍 通过参加“Microsoft 安全在线技术公开课:安全性、合规性和身份基础知识”活动提升你的技能。在本次免费的介绍性活动中,你将获得所需的安全技能和培训,以创造影响力并利用机会推动职业发展。你将了解安全性、合规性和身份的基础知…...
网络基础入门到深入(2):网络协议-TCP/IP协议栈
目录 一.TCP/IP协议栈的四层结构 二.每一层的作用与协议 1.作用层 作用: 常见协议: 示例: 2.传输层 作用: 核心功能: 3.网络层 作用: 核心功能: 常见协议: 示例: 4.数据链路层(物理层) 作用: 核心功能: 常见技术: 示例: 三.TCP/IP协议栈的分层…...
美畅物联丨视频上云网关获取视频流地址供第三方调用的方法
在视频监控与流媒体传输领域,视频流地址的获取与调用是极为关键的环节。视频上云网关作为一款高效且稳定的视频传输设备,为获取视频流地址提供了便捷途径,从而使外部系统或平台能够方便地进行调用。今天我们就来讨论一下如何在视频上云网关上…...
【Cesium】一、cesium简介
文章目录 前言1.什么是Cesium?2.Cesium能做什么?3.Cesium的依赖性4.Cesium学习参考 前言 本人是前端,主要是开发web,使用技术栈Vue、Js。最近因工作需要开始学习使用Cesium,找到一位博主的文章很好,一边学…...
微服务架构介绍
微服务架构是一种现代化的软件架构风格,它将应用程序构建为一组小型、自治的服务,每个服务都运行在其独立的进程中,服务与服务之间通过轻量级通信机制(通常是HTTP/RESTful API)进行通信。 1. 服务(Service&…...
SOLID-开闭原则
单一职责原则:https://blog.csdn.net/dmk877/article/details/143447010 在前面我们学习了单一职责原则,今天来一起学习一下SOLID原则中的开闭原则(Open-Closed Principle, OCP) 通过本篇博客你将学到到以下内容 ①什么是开闭原则 ②如何实现开闭原则 ③…...
Mac 安装 Flutter 提示 A network error occurred while checking
错误信息 A network error occurred while checking "https://maven.google.com/": Operation timed out原因 在中国大陆(由于访问 Google 服务器的限制导致超时),无法连接到 https://maven.google.com/ 解决方案 需要使用镜像网站 #flutter 使用国内的镜像 export …...
Rocky Linux下安装meld
背景介绍: meld是一款Linux系统下的用于 文件夹和文件的比对软件,非常常用; 故障现象: 输入安装命令后,sudo yum install meld,报错。 12-31 22:12:17 ~]$ sudo yum install meld Last metadata expirat…...