在WordPress方面,基本WordPress Vagrant Environment已准备就绪,可以与任何WordPress版本一起使用(需要一些帮助)。您仍然需要找到一种配置PHP的方法,但是中有一个提示https://github.com/ideasonpurpose/basic-wordpress-box/blob/master/ansible/roles/php/tasks/php.yml
。
开箱即用 将项目下载或克隆到wplatest-php55.dev/
并运行vagrant up
安装Vagrant Host Manager将自动将IP链接到您的文件夹http://wplatest-php55.dev/
通过install-wp.sh从WP版本生成多个环境
检查档案中可能的WordPress版本 https://wordpress.org/download/release-archive/
# PWD (script directory)
# ├── common_folder
# ├── wp39-php55.dev
# │ └── site/common_folder
# ├── wp42-php55.dev
# │ └── site/common_folder
# └── wp431-php55.dev
# └── site/common_folder
这是一个脚本,该脚本将Vagrant环境主目录拉到bash脚本的目录中,为阵列中的每个版本克隆一个站点,将安装任务配置为使用该WP版本,并允许您指定要复制到所有站点的文件/文件夹你vagrant up
。
将其放在文件中,install-wp.sh
然后运行chmod +x install-wp.sh
以使其可执行。找到您要在其中创建所有这些框并运行的文件夹./install-wp.sh
。它将生成上面的结构。
由于要测试所有版本的插件,因此请在与脚本相同的目录中创建一个文件夹,wp-content/plugins/your-plugin
然后运行install-wp.sh wp-content
。该文件/文件夹被复制到每个站点的根目录,这就是我建议的原因wp-content
。
安装wp.sh
#!/bin/bash
#
# Author: Jesse Graupmann @jgraup - http://www.justgooddesign.com - 2015
#
# Create multiple WordPress sites based on version numbers in array.
#
# ( OPTIONAL )
# Copy common file/folder to all sites - Pass as parameter $1
#
# Each site runs in a Vagrant Environment:
# https://github.com/ideasonpurpose/basic-wordpress-vagrant
#
# Best if used with:
# https://github.com/smdahlen/vagrant-hostmanager
#
# PWD (script directory)
# ├── common_folder
# ├── wp39-php55.dev
# │ └── site/common_folder
# ├── wp42-php55.dev
# │ └── site/common_folder
# └── wp431-php55.dev
# └── site/common_folder
# WordPress Versions
versions=( 3.9 4.2 4.3.1 )
# Move to the current directory
base=$(pwd); cd $base
# Vagrant Environment
remote_master="https://github.com/ideasonpurpose/basic-wordpress-vagrant/archive/master.zip"
vagrant_master_zip=$base/basic-wordpress-vagrant.zip
# Download Latest Environment - overwrite file for latest
wget -v -O $vagrant_master_zip $remote_master
# Loop through version #s
for VERSION in "${versions[@]}" ; do
flatv="${VERSION//.}"
dirname=wp$flatv-php55.dev
# Clone Environment
echo -e "\nCloning to: $base/$dirname\n"
mkdir -p $base/$dirname
tar -zxvf $vagrant_master_zip -C $base/$dirname --strip-components=1
# WordPress Versions
# Archives: https://wordpress.org/download/release-archive/
# Version: https://wordpress.org/wordpress-{{ wp-version }}.tar.gz
# Latest: https://wordpress.org/latest.tar.gz
# Path to Ansible task
yml=$(cat $base/$dirname/ansible/roles/wordpress/tasks/install.yml)
### REPLACE THE ANSIBLE WP VERSION w/OUR VERSION
wp_url_latest="https:\/\/wordpress.org\/latest.tar.gz"
wp_url_version="https://wordpress.org/wordpress-$VERSION.tar.gz"
echo "${yml/$wp_url_latest/$wp_url_version}" > $base/$dirname/ansible/roles/wordpress/tasks/install.yml
# (OPTIONAL) Copy common file/folder to all sites!
# pass as argument to .sh
#
# Example Folder:
# Make a common wp-content folder, then run install with
#
# ./install-wp.sh wp-content
#
# Example File:
# Make a text file, then run install with
#
# ./install-wp.sh my_file.txt
#
common_dest=$base/$dirname/site/
# Copy Folder
if [ -d "$1" ]; then
echo "Copying $1 --> $common"
# Directory must exist
if [ -d "$1" ]; then
folder_name=$(basename $1)
mkdir -p $common_dest/$folder_name;
fi
cp -r $1 $common_dest
# or File
elif [ -f "$1" ]; then
echo "Copying $1 --> $common_dest"
file_name=$(basename $1)
cp $1 $common_dest/$file_name
fi
## Create doc for quick glance at version number
dest="$base/$dirname"
remotewpzip="https://wordpress.org/wordpress-$VERSION.tar.gz"
txt=$dest/download-wp-$VERSION.txt
touch $txt
printf "WordPress Version: $VERSION - https://wordpress.org/download/release-archive/\n\nDownload Zip: $remotewpzip\n" > $txt
done
# The rest is just for show
echo -e "\nDone!\n\nNow just run 'vagrant up' in any of these:\n"
for VERSION in "${versions[@]}" ; do
flatv="${VERSION//.}"
dirname=wp$flatv-php55.dev
echo -e "\t"$base/$dirname "\thttp://"$dirname
done
echo -e "\nMore Vagrant env info @ https://github.com/ideasonpurpose/basic-wordpress-vagrant"
echo -e "Best if used with https://github.com/smdahlen/vagrant-hostmanager\n\nENJOY!"
更新:
事实证明,基本WordPress Vagrant Environment并未真正设置为可以处理多个php版本,但如果您调整PHP任务,则可能是Basic Wordpress Box。我想我会留下一个脚本的外壳,该脚本可以处理多个php版本。
#!/bin/bash
############################################
#
# PWD (script directory)
# ├── wp39-php55.dev
# ├── wp42-php55.dev
# └── wp431-php55.dev
#
############################################
# WordPress Versions
versions=( 3.9 4.2 4.3.1 )
# PHP Versions
pversions=( 5.4 5.5 5.6 )
############################################
# Move to the current directory
base=$(pwd); cd $base
############################################
# PHP Loop
for PVERSION in "${pversions[@]}" ; do
pflatv="${PVERSION//.}"
echo -e "==> PHP: $PVERSION\n"
# WordPress loop
for VERSION in "${versions[@]}" ; do
flatv="${VERSION//.}"
############################################
dirname=wp$flatv-php$pflatv.dev
############################################
# Environment
echo -e "\t"$base/$dirname "\thttp://"$dirname
mkdir -p $base/$dirname
############################################
# WordPress Versions
# Archives: https://wordpress.org/download/release-archive/
# Version: https://wordpress.org/wordpress-{{ wp-version }}.tar.gz
# Latest: https://wordpress.org/latest.tar.gz
############################################
wp_url_latest="https:\/\/wordpress.org\/latest.tar.gz"
wp_url_version="https://wordpress.org/wordpress-$VERSION.tar.gz"
# Download WP
echo -e "\tDownload WP: $wp_url_version"
############################################
# PHP Packages at https://launchpad.net/~ondrej
# You can get more information about the packages at https://deb.sury.org
# For PHP 5.6 use: ppa:ondrej/php5-5.6
# For PHP 5.5 use: ppa:ondrej/php5
# For PHP 5.4 use: ppa:ondrej/php5-oldstable
############################################
# Config PHP
echo -e "\tConfigure PHP: $PVERSION\n"
done # WordPress version
done # PHP version
exit 1
phpenv
用来管理不同的PHP版本。也许将其与整个WordPress存储库(其中包含下的所有版本/tags
)的SVN Checkout结合起来会是一个开始吗?