Skip to content

Instantly share code, notes, and snippets.

@sahibalejandro
Last active August 29, 2015 14:01
Show Gist options
  • Save sahibalejandro/86622ed45b5f96c69854 to your computer and use it in GitHub Desktop.
Save sahibalejandro/86622ed45b5f96c69854 to your computer and use it in GitHub Desktop.
vagrant machine provisioning, Apache 2.2 + PHP 5.3.20
#!/usr/bin/env bash
# Instalacion de paquetes necesarios
apt-get update
apt-get install -y build-essential autoconf libxml2-dev libmcrypt-dev libmysqlclient-dev openssl pkg-config libjpeg-dev libpng-dev libxslt1-dev libcurl4-gnutls-dev libbz2-dev libxpm-dev libfreetype6-dev
apt-get install -y curl
mkdir /home/vagrant/provisioning
cd /home/vagrant/provisioning
# Instalacion de Apache 2.0.65
wget http://archive.apache.org/dist/httpd/httpd-2.0.65.tar.gz
tar -xf httpd-2.0.65.tar.gz
cd httpd-2.0.65
./configure --prefix=/etc/apache2 --enable-so --enable-rewrite
make
make install
cd ..
# Instalacion de PHP 5.3.5
wget http://museum.php.net/php5/php-5.3.5.tar.bz2
tar -xf php-5.3.5.tar.bz2
cd php-5.3.5
# Some libs must be on /usr/lib to configure correctly
ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/libjpeg.so
ln -s /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/libpng.so
ln -s /usr/lib/x86_64-linux-gnu/libXpm.so /usr/lib/libXpm.so
# Apply Open SSL patch (https://bugs.php.net/bug.php?id=54736)
patch ext/openssl/xp_ssl.c /vagrant/php5.3.5-openssl.patch
./configure \
--prefix=/etc/php5 \
--with-apxs2=/etc/apache2/bin/apxs \
--with-config-file-path=/etc/php5 \
--with-config-file-scan-dir=/etc/php5/conf.d \
--disable-cgi \
--with-mcrypt \
--with-openssl \
--enable-soap \
--disable-debug \
--with-bz2 \
--with-curl \
--with-xsl \
--enable-exif \
--enable-ftp \
--with-gd \
--enable-gd-native-ttf \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-xpm-dir=/usr \
--with-freetype-dir=/usr \
--with-gettext \
--enable-sockets \
--enable-wddx \
--with-xmlrpc \
--with-sqlite \
--enable-pdo \
--enable-mbstring \
--with-iconv \
--with-mhash \
--with-pdo-mysql=mysqlnd \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-zlib \
--enable-zip
make
make install
ln -s /etc/php5/bin/php /bin/php
cp php.ini-development /etc/php5/php.ini
# Create custom php.ini
mkdir /etc/php5/conf.d
touch /etc/php5/conf.d/php.ini
cat > /etc/php5/conf.d/php.ini <<EOF
file_uploads = On
error_reporting = E_ALL
display_errors = On
memory_limit = 110M
post_max_size = 105M
upload_max_filesize = 100M
max_input_time = 300
EOF
cd ..
# Install Composer
curl -sS https://getcomposer.org/installer | php -- --filename=composer --install-dir=/bin
# Configure apache
rm -rf /etc/apache2/htdocs
ln -s /vagrant /etc/apache2/htdocs
cd /etc/apache2
sed -i '/LoadModule php5_module/ a AddHandler php5-script .php' conf/httpd.conf
sed -i 's/DirectoryIndex index.html/DirectoryIndex index.php index.html/' conf/httpd.conf
sed -i 's/User nobody/User vagrant/' conf/httpd.conf
sed -i 's/Group #-1/Group vagrant/' conf/httpd.conf
sed -i 's/AllowOverride None/AllowOverride All/g' conf/httpd.conf
sed -i 's/#EnableSendfile off/EnableSendfile off/g' conf/httpd.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment