• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

基于Jenkins自动化部署PHP环境

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

1、准备 git 仓库

[root@git ~]# su - git
上一次登录:五 5月 8 17:33:05 CST 2020从 192.168.200.117pts/0 上
[git@git ~]$ mkdir php.git
[git@git ~]$ cd php.git
[git@git php.git]$ git --bare init
初始化空的 Git 版本库于 /home/git/php.git/
[git@git php.git]$ exit
登出

2、上传代码到仓库

[root@git ~]# git clone [email protected]:/home/git/php.git
正克隆到 'php'...
The authenticity of host '192.168.200.127 (192.168.200.127)' can't be established.
ECDSA key fingerprint is SHA256:HIdLjuU1wd017CkzkNL+Llz+agZ5zOCMVGbwbHPfmes.
ECDSA key fingerprint is MD5:6c:eb:89:cf:b3:52:d6:f5:50:46:56:30:23:09:7b:59.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.200.127' (ECDSA) to the list of known hosts.
[email protected]'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(根提交) ae1aa93] all
1 file changed, 3 insertions(+)
create mode 100644 index.php
[root@git php]# git push origin master
[email protected]'s password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 219 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To [email protected]:/home/git/php.git
* [new branch] master -> master

3、部署 web 主机环境

[root@tomcat ~]# yum -y install httpd mariadb-server mariadb mariadb-devel php php-mbstring php-mysql php-bcmath php-gd php-xmlrpc php-ldap php-xml libevent libevent-devel net-snmp net-snmp-devel libxml2 libxml2-devel ntpdate

[root@tomcat ~]# systemctl start httpd
[root@tomcat ~]# systemctl start mariadb

 

 Jenkins 主机将密钥发布到 web 主机

[root@jenkins ~]# su -s /bin/bash jenkins

bash-4.2$ ssh-keygen

bash-4.2$ ssh-copy-id [email protected]

基于 rsync 部署

创建一个 Freestyle project

 

 

rsync -avz  --delete * [email protected]:/var/www/html/

 

 

 

[root@tomcat ~]# ls /var/www/html/

index.php
[root@tomcat ~]# cat /var/www/html/index.php
<?php
phpinfo();
?>

 

 

 基于 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.200.128

修改 Jenkins 运行用户

[root@jenkins ~]# vim /etc/sysconfig/jenkins

JENKINS_USER="root"

[root@jenkins ~]# /etc/init.d/jenkins restart
Restarting jenkins (via systemctl): [ 确定 ]

添加 Ansible 插件

 

[root@jenkins ~]# ssh-keygen

[root@jenkins ~]# ssh-copy-id [email protected]

[root@jenkins ~]# ssh-copy-id [email protected]

 

 

 

 

 

 

 

[root@tomcat ~]# ls /var/www/html/

index.php php-ansible

 

 

 

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP生成随机字符串发布时间:2022-07-10
下一篇:
OneinStack——PHP多版本共存发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap