news 2026/4/23 18:45:15

今天我们继续DevOps内容Jenkins自动化部署PHP项目

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
今天我们继续DevOps内容Jenkins自动化部署PHP项目

1、实验环境

需要准备三台服务器充当:git、jenkins、web

2、准备git仓库

[root@git ~]# useradd git [root@git ~]# echo "123" | passwd --stdin git [root@git ~]# su - git 上一次登录:三 8月 23 20:41:53 CST 2023pts/0 上 [git@git ~]$ mkdir php.git [git@git ~]$ cd php.git #--bare:创建一个裸仓库。裸仓库是一种特殊的Git仓库,它不包含工作目录(没有文件的检出和编辑空间),主要用于共享,是作为远程仓#库被其他仓库推送(push)和拉取(pull)的中心存储库。 [git@git php.git]$ git --bare init #初始化空的 Git 版本库于 /home/git/php.git/ [git@git php.git]$ exit #登出

3、上传代码到仓库

[root@git ~]# git clone git@192.168.166.9:/home/git/php.git 正克隆到 'php'... git@192.168.200.111's password: warning: 您似乎克隆了一个空版本库。 [root@git ~]# cd php/ [root@git php]# cat << EOF > index.php <?php phpinfo(); ?> EOF [root@git php]# git add . [root@git php]# git commit -m "all" [master(根提交) 4ec0ba3] all 1 file changed, 3 insertions(+) create mode 100644 index.php [root@git php]# git push origin master git@192.168.166.9's password: Counting objects: 3, done. Writing objects: 100% (3/3), 218 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To git@192.168.166.9:/home/git/php.git * [new branch] master -> master

4、部署web主机环境

yum install -y nginx php php-mysqlnd mysql-server php-fpm cd /etc/nginx/ mv nginx.conf nginx.conf.back cp nginx.conf.default nginx.conf vim nginx.conf http { ... include conf.d/*.conf; ... server { ... location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; root html; fastcgi_pass php-fpm; fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi.conf; } ... } } systemctl start php-fpm mysqld nginx

6、基于rsync部署

创建一个Freestyle project

7、 基于ansible部署

[root@jenkins ~]# rpm -ivh epel-release-latest-7.noarch.rpm [root@jenkins ~]# yum -y install ansible [root@jenkins ~]# vim /etc/ansible/hosts [webserver] 192.168.166.6

修改jenkins运行用户

[root@jenkins ~]# vim /usr/lib/systemd/system/jenkins.service User=root Group=root [root@jenkins ~]# systemctl daemon-reload [root@jenkins ~]# systemctl restart jenkins ###设置SSH的免密登录 [root@jenkins ~]# ssh-keygen -N '' -f ~/.ssh/id_rsa [root@jenkins ~]# ssh-copy-id root@192.168.158.5 [root@jenkins ~]# ssh-copy-id git@192.168.158.4

添加Ansible插件

[root@web ~]# cat /etc/nginx/nginx.conf server { listen 80; listen [::]:80; server_name _; root /usr/share/nginx/html/php-ansible; index index.html index.php; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; ..... [root@web ~]# systemctl restart nginx
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/23 15:47:27

ARM Compiler 5.06入门要点:优化选项初步了解

ARM Compiler 5.06优化实战&#xff1a;如何在性能、体积与调试间找到最佳平衡&#xff1f;你有没有遇到过这样的情况&#xff1a;代码逻辑明明没问题&#xff0c;但烧录到板子上后系统却响应迟钝&#xff1f;或者项目越做越大&#xff0c;突然发现Flash快爆了&#xff0c;而你…

作者头像 李华
网站建设 2026/4/23 13:01:02

GPT-SoVITS长文本合成中断问题解决方案

GPT-SoVITS长文本合成中断问题解决方案 在语音合成技术快速演进的今天&#xff0c;个性化音色克隆已不再是实验室里的概念&#xff0c;而是逐步走向大众应用。像有声书、AI主播、智能客服这类需要长时间稳定输出的应用场景&#xff0c;对TTS系统提出了更高要求——不仅要“像人…

作者头像 李华
网站建设 2026/4/23 13:36:43

AHN:字节跳动推出高效长文本建模新方案

AHN&#xff1a;字节跳动推出高效长文本建模新方案 【免费下载链接】AHN-DN-for-Qwen-2.5-Instruct-3B 项目地址: https://ai.gitcode.com/hf_mirrors/ByteDance-Seed/AHN-DN-for-Qwen-2.5-Instruct-3B 字节跳动近日发布了名为AHN&#xff08;Artificial Hippocampus N…

作者头像 李华
网站建设 2026/4/22 23:11:57

uBlock Origin终极浏览器兼容指南:2025年完整安装与配置手册

你是否曾经在安装uBlock Origin后&#xff0c;发现某些功能无法使用&#xff0c;或者在不同浏览器中体验差异巨大&#xff1f;&#x1f914; 作为一款高效轻量级的宽频内容阻止程序&#xff0c;uBlock Origin&#xff08;uBO&#xff09;在不同浏览器平台上的表现确实存在显著区…

作者头像 李华
网站建设 2026/4/23 14:15:51

中文字体设计的困境与突破:Source Han Serif CN实战应用全解析

中文字体设计的困境与突破&#xff1a;Source Han Serif CN实战应用全解析 【免费下载链接】source-han-serif-ttf Source Han Serif TTF 项目地址: https://gitcode.com/gh_mirrors/so/source-han-serif-ttf 你是否曾经在设计中文内容时&#xff0c;为找不到合适的免费…

作者头像 李华
网站建设 2026/4/23 13:07:10

L298N电机驱动模块在STM32系统中的接线实践案例

如何用STM32精准驱动L298N电机&#xff1f;一文讲透接线、调速与抗干扰实战要点你有没有遇到过这种情况&#xff1a;代码写得没问题&#xff0c;PWM也启用了&#xff0c;可电机就是不转&#xff0c;或者一启动就发热严重&#xff0c;甚至STM32莫名其妙复位&#xff1f;如果你正…

作者头像 李华