Last active
December 18, 2015 15:09
-
-
Save huanga/5802477 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ -f /root/.provisioned ] | |
then | |
echo "Already provisioned!" | |
exit 0 | |
fi | |
############################################################################### | |
# | |
# Configure locales. Select en_US.UTF-8 to get rid og LC_* warnings. | |
# | |
############################################################################### | |
export LANGUAGE=en_US.UTF-8 | |
export LANG=en_US.UTF-8 | |
export LC_ALL=en_US.UTF-8 | |
locale-gen en_US.UTF-8 | |
dpkg-reconfigure locales | |
############################################################################### | |
# | |
# Configure the sources and update the packages. | |
# | |
############################################################################### | |
rm /etc/apt/sources.list | |
cat - > /etc/apt/sources.list <<EOF | |
deb http://ftp-mirror.internap.com/pub/debian stable main contrib non-free | |
deb-src http://ftp-mirror.internap.com/pub/debian stable main contrib non-free | |
deb http://ftp-mirror.internap.com/pub/debian/ wheezy-updates main contrib non-free | |
deb-src http://ftp-mirror.internap.com/pub/debian/ wheezy-updates main contrib non-free | |
deb http://security.debian.org/ wheezy/updates main contrib non-free | |
deb-src http://security.debian.org/ wheezy/updates main contrib non-free | |
deb http://mirror.us.leaseweb.net/dotdeb/ wheezy all | |
deb-src http://mirror.us.leaseweb.net/dotdeb/ wheezy all | |
deb http://ftp.osuosl.org/pub/mariadb/repo/10.0/debian wheezy main | |
deb-src http://ftp.osuosl.org/pub/mariadb/repo/10.0/debian wheezy main | |
EOF | |
wget -q -O - http://www.dotdeb.org/dotdeb.gpg | apt-key add - | |
apt-get -y update | |
apt-get install python-software-properties | |
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db | |
aptitude -y update && aptitude -y safe-upgrade | |
aptitude -y update && aptitude -y upgrade | |
############################################################################### | |
# | |
# Install common utilities. | |
# | |
############################################################################### | |
aptitude -y install pwgen vim nano locate telnet netcat build-essential git subversion | |
############################################################################### | |
# | |
# Install nginx, mysql and php. Do not select password for mysql user. | |
# | |
############################################################################### | |
aptitude -y install nginx | |
update-rc.d nginx defaults | |
/etc/init.d/nginx start | |
aptitude -y install mariadb-client | |
aptitude -y install php5-cgi php5-cli php5-dev php5-gd php5-imagick php5-imap php5-intl php5-mcrypt php5-mysql php-pear | |
############################################################################### | |
# | |
# Create an init.d script for spawning the php-fcgi processes. | |
# | |
############################################################################### | |
cat - > /etc/init.d/php-fastcgi <<'EOF' | |
#!/bin/bash | |
### BEGIN INIT INFO | |
# Provides: php-fastcgi | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: initscript for php-fastcgi | |
# Description: This script is used to spawn php5-cgi processes | |
### END INIT INFO | |
BIND=127.0.0.1:9898 | |
USER=www-data | |
PHP_FCGI_CHILDREN=15 | |
PHP_FCGI_MAX_REQUESTS=1000 | |
PHP_CGI=/usr/bin/php-cgi | |
PHP_CGI_NAME=`basename $PHP_CGI` | |
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND" | |
RETVAL=0 | |
start() { | |
echo -n "Starting PHP FastCGI: " | |
start-stop-daemon --quiet --start --background --chuid "$USER" --exec /usr/bin/env -- $PHP_CGI_ARGS | |
RETVAL=$? | |
echo "$PHP_CGI_NAME." | |
} | |
stop() { | |
echo -n "Stopping PHP FastCGI: " | |
killall -q -w -u $USER $PHP_CGI | |
RETVAL=$? | |
echo "$PHP_CGI_NAME." | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo "Usage: php-fastcgi {start|stop|restart}" | |
exit 1 | |
;; | |
esac | |
exit $RETVAL | |
EOF | |
chmod ugo+x /etc/init.d/php-fastcgi | |
/etc/init.d/php-fastcgi start | |
update-rc.d php-fastcgi defaults | |
############################################################################### | |
# | |
# Install memcached | |
# | |
############################################################################### | |
aptitude -y install memcached php5-memcached | |
############################################################################### | |
# | |
# Install phalcon | |
# | |
############################################################################### | |
git clone https://github.com/phalcon/cphalcon.git | |
cd cphalcon/build | |
./install | |
touch /etc/php5/cgi/conf.d/phalcon.ini && echo 'extension=phalcon.so' > /etc/php5/cgi/conf.d/phalcon.ini | |
cd ../../ | |
rm -fr cphalcon | |
############################################################################### | |
# | |
# Install supervisor | |
# | |
############################################################################### | |
aptitude -y install supervisor | |
############################################################################### | |
# | |
# create virtual host | |
# | |
############################################################################### | |
cat - > /etc/nginx/sites-available/phalcon <<'EOF' | |
server { | |
listen 80; | |
server_name localhost; | |
set $root_path '/var/www/public'; | |
root $root_path; | |
index index.php index.html index.htm; | |
try_files $uri $uri/ @rewrite; | |
location @rewrite { | |
rewrite ^/(.*)$ /index.php?_url=$1; | |
} | |
location ~ \.php { | |
# try_files $uri =404; | |
fastcgi_index /index.php; | |
fastcgi_pass 127.0.0.1:9898; | |
include fastcgi_params; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
} | |
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ { | |
root $root_path/public; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
} | |
EOF | |
ln -s /etc/nginx/sites-available/phalcon /etc/nginx/sites-enabled/phalcon | |
rm -f /etc/nginx/sites-enabled/default | |
############################################################################### | |
# | |
# Install xdebug | |
# | |
############################################################################### | |
pecl install xdebug | |
cat - > /etc/php5/cgi/conf.d/xdebug.ini <<EOF | |
zend_extension=extension=/usr/lib/php5/20100525+lfs/xdebug.so | |
xdebug.default_enable=1 | |
xdebug.remote_enable=1 | |
xdebug.remote_host=127.0.0.1 | |
xdebug.remote_port=9000 | |
xdebug.idekey=PHPSTORM | |
EOF | |
############################################################################### | |
# | |
# Finally restart the stack and updatedb with new packages. | |
# | |
############################################################################### | |
/etc/init.d/php-fastcgi restart | |
/etc/init.d/nginx restart | |
updatedb | |
touch /root/.provisioned | |
############################################################################### | |
# | |
# Finish the setup by configuring mysql | |
# ===================================== | |
# $ vim /etc/mysql/my.cnf | |
# bind-address = 10.84.20.10 | |
# | |
# Import database and grant permission for root | |
# | |
# grant all on phalcon.* to root@10.84.20.10; | |
# flush privileges; | |
# | |
# Configure phpstorm | |
# ================== | |
# File > Settings > PHP > Servers | |
# Name: vagrant-jarvis | |
# Host: 10.84.20.10 | |
# Port: 8080 | |
# Debugger: Xdebug | |
# | |
# Click Use path mappings | |
# | |
# File/Direcotory | Absolute path on the server | |
# ----------------+---------------------------- | |
# /path/to/www | /vargant | |
# | |
# Run > Debug Configurations | |
# | |
# Click "+" > PHP Remote Debug | |
# Name: Vagrant Debug | |
# Servers: localhost | |
# Ide key: PHPSTORM | |
# | |
############################################################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure("2") do |config| | |
# All Vagrant configuration is done here. The most common configuration | |
# options are documented and commented below. For a complete reference, | |
# please see the online documentation at vagrantup.com. | |
# Every Vagrant virtual environment requires a box to build off of. | |
config.vm.box = "wheezy64" | |
# The url from where the 'config.vm.box' box will be fetched if it | |
# doesn't already exist on the user's system. | |
# config.vm.box_url = "http://domain.com/path/to/above.box" | |
# Create a forwarded port mapping which allows access to a specific port | |
# within the machine from a port on the host machine. In the example below, | |
# accessing "localhost:8080" will access port 80 on the guest machine. | |
# config.vm.network :forwarded_port, guest: 80, host: 8080 | |
# Create a private network, which allows host-only access to the machine | |
# using a specific IP. | |
config.vm.network :private_network, ip: "10.84.20.10" | |
# Create a public network, which generally matched to bridged network. | |
# Bridged networks make the machine appear as another physical device on | |
# your network. | |
# config.vm.network :public_network | |
# Share an additional folder to the guest VM. The first argument is | |
# the path on the host to the actual folder. The second argument is | |
# the path on the guest to mount the folder. And the optional third | |
# argument is a set of non-required options. | |
# config.vm.synced_folder "../data", "/vagrant_data" | |
config.vm.synced_folder "/Users/andy/Documents/PHPStorm/Jarvis/trunk/src/jarvis", "/var/www" | |
# Provider-specific configuration so you can fine-tune various | |
# backing providers for Vagrant. These expose provider-specific options. | |
# Example for VirtualBox: | |
# | |
# config.vm.provider :virtualbox do |vb| | |
# # Don't boot with headless mode | |
# vb.gui = true | |
# | |
# # Use VBoxManage to customize the VM. For example to change memory: | |
# vb.customize ["modifyvm", :id, "--memory", "1024"] | |
# end | |
# | |
# View the documentation for the provider you're using for more | |
# information on available options. | |
# Enable provisioning with Puppet stand alone. Puppet manifests | |
# are contained in a directory path relative to this Vagrantfile. | |
# You will need to create the manifests directory and a manifest in | |
# the file precise32.pp in the manifests_path directory. | |
# | |
# An example Puppet manifest to provision the message of the day: | |
# | |
# # group { "puppet": | |
# # ensure => "present", | |
# # } | |
# # | |
# # File { owner => 0, group => 0, mode => 0644 } | |
# # | |
# # file { '/etc/motd': | |
# # content => "Welcome to your Vagrant-built virtual machine! | |
# # Managed by Puppet.\n" | |
# # } | |
# | |
# config.vm.provision :puppet do |puppet| | |
# puppet.manifests_path = "manifests" | |
# puppet.manifest_file = "init.pp" | |
# end | |
# Enable provisioning with chef solo, specifying a cookbooks path, roles | |
# path, and data_bags path (all relative to this Vagrantfile), and adding | |
# some recipes and/or roles. | |
# | |
# config.vm.provision :chef_solo do |chef| | |
# chef.cookbooks_path = "../my-recipes/cookbooks" | |
# chef.roles_path = "../my-recipes/roles" | |
# chef.data_bags_path = "../my-recipes/data_bags" | |
# chef.add_recipe "mysql" | |
# chef.add_role "web" | |
# | |
# # You may also specify custom JSON attributes: | |
# chef.json = { :mysql_password => "foo" } | |
# end | |
# Enable provisioning with chef server, specifying the chef server URL, | |
# and the path to the validation key (relative to this Vagrantfile). | |
# | |
# The Opscode Platform uses HTTPS. Substitute your organization for | |
# ORGNAME in the URL and validation key. | |
# | |
# If you have your own Chef Server, use the appropriate URL, which may be | |
# HTTP instead of HTTPS depending on your configuration. Also change the | |
# validation key to validation.pem. | |
# | |
# config.vm.provision :chef_client do |chef| | |
# chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" | |
# chef.validation_key_path = "ORGNAME-validator.pem" | |
# end | |
# | |
# If you're using the Opscode platform, your validator client is | |
# ORGNAME-validator, replacing ORGNAME with your organization name. | |
# | |
# If you have your own Chef Server, the default validation client name is | |
# chef-validator, unless you changed the configuration. | |
# | |
# chef.validation_client_name = "ORGNAME-validator" | |
config.vm.provision :shell, :path => "vagrant.sh" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment