Created
September 17, 2012 10:05
-
-
Save theDisco/3736536 to your computer and use it in GitHub Desktop.
Vagrant setup for phalcon projects
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 | |
aptitude -y safe-upgrade | |
############################################################################### | |
# | |
# 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.informatik.rwth-aachen.de/ftp/pub/Linux/debian/ squeeze main | |
deb-src http://ftp.informatik.rwth-aachen.de/ftp/pub/Linux/debian/ squeeze main | |
deb http://security.debian.org/ squeeze/updates main | |
deb-src http://security.debian.org/ squeeze/updates main | |
deb http://ftp.informatik.rwth-aachen.de/ftp/pub/Linux/debian/ squeeze-updates main | |
deb-src http://ftp.informatik.rwth-aachen.de/ftp/pub/Linux/debian/ squeeze-updates main | |
deb http://packages.dotdeb.org squeeze all | |
deb http://packages.dotdeb.org squeeze-php54 all | |
EOF | |
wget -q -O - http://www.dotdeb.org/dotdeb.gpg | apt-key add - | |
aptitude -y update && aptitude -y upgrade | |
############################################################################### | |
# | |
# Install common utilities. | |
# | |
############################################################################### | |
aptitude -y install pwgen vim locate telnet netcat build-essential git | |
############################################################################### | |
# | |
# 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 mysql-server-5.5 | |
aptitude -y install php5-cgi php5-cli php5-dev php5-gd php5-imagick php5-imap php5-intl php5-mcrypt php5-mysql php5-suhosin 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 beanstalk | |
# | |
############################################################################### | |
aptitude -y install beanstalkd | |
############################################################################### | |
# | |
# Install mongo and php extension | |
# | |
############################################################################### | |
aptitude -y install mongodb | |
pecl install mongo | |
touch /etc/php5/mods-available/mongo.ini && echo 'extension=/usr/lib/php5/20100525+lfs/mongo.so' > /etc/php5/mods-available/mongo.ini | |
############################################################################### | |
# | |
# Install phalcon | |
# | |
############################################################################### | |
git clone https://github.com/phalcon/cphalcon.git | |
cd cphalcon/build | |
export CFLAGS="-O2 -fno-delete-null-pointer-checks" | |
phpize | |
./configure --enable-phalcon | |
make && make install | |
touch /etc/php5/cgi/conf.d/phalcon.ini && echo 'extension=/usr/lib/php5/20100525+lfs/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; | |
charset utf-8; | |
root /vagrant/public; | |
index index.php index.html index.htm; | |
location / { | |
try_files $uri $uri/ /index.html; | |
rewrite ^(.+)$ /index.php?_url=$1 last; | |
} | |
location ~ \.php { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass 127.0.0.1:9898; | |
include fastcgi_params; | |
} | |
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ { | |
root /vagrant/public; | |
} | |
} | |
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=192.168.50.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 | |
############################################################################### | |
# | |
# Finish the setup by configuring mysql | |
# ===================================== | |
# $ vim /etc/mysql/my.cnf | |
# bind-address = 192.168.50.100 | |
# | |
# Import database and grant permission for root | |
# | |
# grant all on phalcon.* to root@192.168.50.1; | |
# flush privileges; | |
# | |
# Configure phpstorm | |
# ================== | |
# File > Settings > PHP > Servers | |
# Name: localhost | |
# Host: localhost | |
# 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
Vagrant::Config.run do |config| | |
config.vm.box = "squeeze32" | |
config.vm.network :hostonly, "192.168.50.100" | |
config.vm.forward_port 80, 8080 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment