1. 环境准备
git服务器: 10.10.95.2 web服务器: 10.10.95.3 jenkins服务器:10.10.95.4
2. 创建git仓库,接收本地Pipeline配置文件
su - git mkdir -p /home/git/repos/jenkinsfile git --bare init #初始化仓库
3.web服务器创建文件夹,拉去git服务器
/root/sxw/jenkinsfile vi jenkinsfile git clone git@10.10.95.2:/home/git/repos/jenkinsfile vi jenkinsfile-php # 添加Pipeline 内容 git add . git commit -m "" git push origin master
4.jenkinsfile 内容
node ("web") { //配置slave 节点 stage('git checkout') { checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'git@10.10.95.2:/home/git/repos/wordpress.git']]]) //获取项目代码 } stage('code copy') { sh '''rm -rf ${WORKSPACE}/.git mv /usr/share/nginx/html/www.compress.com /data/backup/www.compress.com-$(date +"%F_%T") cp -rf ${WORKSPACE} /usr/share/nginx/html/www.compress.com''' } stage('test') { sh "curl http://www.compress.com/status.html" } }
5. 安装EPEL源
yum install -y epel-release
6.EPEL源安装nginx php
yum install -y nginx php-fpm
7.安装PHP mysql扩展选项
yum install -y php-mysql
8.安装mysql服务端
yum install mariadb-server -y
9. 启动
systemctl start php-fpm systemctl start nginx systemctl start mariadb
10.登录数据库
mysqladmin -uroot password “123456”
11.修改本地host参数,配置本地访问域名
转载于:https://blog.51cto.com/11726705/2345340