Skip to content

Instantly share code, notes, and snippets.

@mansurali901
Forked from sheikhwaqas/setup-webserver.sh
Last active August 29, 2015 14:17
Show Gist options
  • Save mansurali901/8d1b133276bdeeac17a5 to your computer and use it in GitHub Desktop.
Save mansurali901/8d1b133276bdeeac17a5 to your computer and use it in GitHub Desktop.
# Download and Install the Latest Updates for the OS
apt-get update && apt-get upgrade -y
# Set the Server Timezone to CST
echo "America/Chicago" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
# Enable Ubuntu Firewall and allow SSH, HTTP & HTTPS Ports
ufw enable
ufw allow 22
ufw allow 80
ufw allow 443
ufw allow 10050
# Install essential packages
apt-get -y install \
gcc g++ autoconf automake make sendmail git zsh acl zip unzip \
pkg-config gettext curl enchant \
libpcre3-dev libssl-dev libxml2 libxml2-dev libcurl4-openssl-dev libenchant-dev libfreetype6 libfreetype6-dev libbz2-dev \
libedit-dev libedit2 libtidy-dev libxslt1.1 libxslt1-dev libvpx-dev libxpm-dev libedit-dev libreadline-dev \
libmcrypt4 libmcrypt-dev libmhash-dev libmhash2 mcrypt libc-client2007e libc-client2007e-dev
# Install Ruby
cd /usr/local/src
wget -O- https://s3-us-west-2.amazonaws.com/lamp-software/latest/ruby-2.1.3.tar.gz | tar -zxf -
cd ruby-2.1.3
./configure && make && make install
# Install SASS & Compass
gem install sass
gem install compass
# Apache2 Installation
#
# Download Apache Source from Apache's Website and Extract it
# http://httpd.apache.org/download.cgi
cd /usr/local/src
wget -O- https://s3-us-west-2.amazonaws.com/lamp-software/latest/httpd-2.4.10.tar.gz | tar -zxf -
# Download Apache Portable Runtime (APR) and Apache Portable Runtime Utility (APR-Util) from Apache's Website
# http://apr.apache.org/download.cgi
wget -O- https://s3-us-west-2.amazonaws.com/lamp-software/latest/apr-1.5.1.tar.gz | tar -zxf -
wget -O- https://s3-us-west-2.amazonaws.com/lamp-software/latest/apr-util-1.5.4.tar.gz | tar -zxf -
# Move the APR & APR-UTIL to Apache's srclib directory for compilation
mv apr-1.5.1 /usr/local/src/httpd-2.4.10/srclib/apr
mv apr-util-1.5.4 /usr/local/src/httpd-2.4.10/srclib/apr-util
# Compile and Install Apache 2
cd /usr/local/src/httpd-2.4.10
./configure \
--prefix=/usr/local/apache2 \
--enable-mods-shared="reallyall ssl" \
--enable-watchdog \
--enable-deflate \
--enable-expires \
--enable-ssl \
--enable-heartbeat \
--enable-heartmonitor \
--enable-vhost-alias \
--enable-rewrite \
--with-mpm=prefork
make && make install
# Setup Apache as a service by making a Symbolic Link to the apachectl binary
ln -s /usr/local/apache2/bin/apachectl /etc/init.d/apache
update-rc.d apache defaults
# Start Apache service
service apache start
# Add PHP MIME Type to Apache
echo "application/x-httpd-php php" >> /usr/local/apache2/conf/mime.types
# Test if Apache is running
# Open your browser and point it to your server's IP Address. You should be able to see the It Works! text
# Install JPEG library (Used for PHP GD Library Extension)
cd /usr/local/src
wget -O- https://s3-us-west-2.amazonaws.com/lamp-software/latest/jpegsrc.v9.tar.gz | tar -zxf -
cd jpeg-9
./configure && make && make install
# Install libpng (Used for PHP GD Library Extension)
cd /usr/local/src
wget -O- https://s3-us-west-2.amazonaws.com/lamp-software/latest/libpng-1.6.10.tar.gz | tar -zxf -
cd libpng-1.6.10
./configure && make && make install
# Install Free TDS (Used for PHP MySQL Extension)
cd /usr/local/src
wget -O- ftp://ftp.freetds.org/pub/freetds/stable/freetds-stable.tgz | tar -zxf -
cd freetds-0.91
./configure \
--prefix=/usr/local/freetds \
--sysconfdir=/usr/local/freetds/conf \
--disable-libiconv \
--enable-msdblib
make && make install
# Compile / Install PHP from Source
cd /usr/local/src
wget -O- https://s3-us-west-2.amazonaws.com/lamp-software/latest/php-5.4.33.tar.gz | tar -zxf -
cd php-5.4.33
./configure \
--prefix=/usr \
--sysconfdir=/private/etc \
--infodir=/usr/share/info \
--mandir=/usr/share/man \
--with-apxs2=/usr/local/apache2/bin/apxs \
--enable-cli \
--enable-fpm \
--with-config-file-path=/etc \
--enable-libxml=shared \
--with-openssl=shared \
--with-kerberos \
--with-imap=shared,/usr/lib \
--with-imap-ssl=shared,/usr/lib \
--with-pcre-regex \
--with-zlib=shared \
--enable-bcmath=shared \
--with-bz2=shared \
--enable-calendar=shared \
--enable-ctype=shared \
--with-curl=shared \
--enable-dba=shared \
--enable-exif=shared \
--enable-fileinfo=shared \
--enable-ftp=shared \
--with-gd \
--with-jpeg-dir=/usr/local/lib \
--with-png-dir=/usr/local/lib \
--with-freetype-dir=/usr/lib \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gettext=shared \
--with-mhash=shared \
--with-icu-dir=shared \
--enable-json=shared \
--without-ldap \
--without-ldap-sasl \
--enable-mbstring=shared \
--enable-mbregex \
--with-mcrypt=shared \
--enable-mysqlnd \
--disable-mysqlnd-compression-support \
--with-mssql=shared,/usr/local/freetds \
--with-mysql=shared \
--with-mysql-sock=shared,/var/lib/mysql/mysql.sock \
--with-mysqli=shared \
--without-iodbc \
--enable-pdo=shared \
--with-pdo-dblib=shared,/usr/local/freetds \
--with-pdo-mysql=shared \
--without-pdo-pgsql \
--with-pdo-sqlite=shared \
--without-pgsql \
--enable-phar=shared \
--with-libedit=shared \
--with-readline=shared \
--enable-shmop=shared \
--enable-simplexml=shared \
--without-snmp \
--enable-soap=shared \
--enable-sockets=shared \
--enable-sysvmsg=shared \
--enable-sysvsem=shared \
--enable-sysvshm=shared \
--with-tidy=shared \
--enable-wddx=shared \
--enable-xml=shared \
--enable-xmlreader=shared \
--with-xmlrpc=shared \
--enable-xmlwriter=shared \
--with-xsl=shared \
--enable-zip=shared \
--with-pear
make
make install
# Install MongoDB PHP Extension
cd /usr/local/src
wget -O- http://pecl.php.net/get/mongo-1.4.5.tgz | tar -zxf -
cd mongo-1.4.5
phpize && ./configure && make && make install
# Install XDebug PHP Extension
cd /usr/local/src
wget -O- http://pecl.php.net/get/xdebug-2.2.3.tgz | tar -zxf -
cd xdebug-2.2.3
phpize && ./configure && make && make install
# Move all the PHP Extensions to the extensions directory and remove the temp directory
mv /usr/lib/php/extensions/no-debug-non-zts-20100525/*.so /usr/lib/php/extensions/
rm -rf /usr/lib/php/extensions/no-debug-non-zts-20100525
# Download and place the configured php.ini file
cd /etc
wget https://gist.githubusercontent.com/sheikhwaqas/87ee16e1f6e4591b9daf/raw/293fbc23e65a7eb14540037c40548502568820cd/php.ini
# Download and place the configured httpd.conf file in the directory and restart apache
cd /usr/local/apache2/conf
rm -f httpd.conf
wget https://gist.github.com/sheikhwaqas/c6afc6f6db94e4d000fd/raw/dfdfac1cf02f53e1c11a8994e4fcfc87fa5f2622/httpd.conf
service apache restart
# Install Composer (Install it after PHP is installed)
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment