Last active
July 18, 2019 21:01
-
-
Save sheikhwaqas/9088911 to your computer and use it in GitHub Desktop.
Install Apache & PHP with MongoDB and XDebug Extensions on Ubuntu 14.04 LTS
This file contains hidden or 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/bash | |
# 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 allow 22 | |
ufw allow 80 | |
ufw allow 443 | |
# 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 libffi-dev libicu-dev \ | |
libevent-dev tcl8.5 | |
# Install Ruby | |
cd /usr/local/src | |
wget -O- https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.gz | tar -zxf - | |
cd ruby* | |
./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- http://www-us.apache.org/dist//httpd/httpd-2.4.23.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- http://www-us.apache.org/dist//apr/apr-1.5.2.tar.gz | tar -zxf - | |
wget -O- http://www-us.apache.org/dist//apr/apr-util-1.5.4.tar.gz | tar -zxf - | |
# Move the APR & APR-UTIL to Apache's srclib directory for compilation | |
mv apr-util-* /usr/local/src/httpd-2.4.23/srclib/apr-util | |
mv apr-* /usr/local/src/httpd-2.4.23/srclib/apr | |
# Compile and Install Apache 2 | |
cd /usr/local/src/httpd* | |
./configure \ | |
--prefix=/usr/local/apache2 \ | |
--enable-mods-shared="reallyall ssl" \ | |
--enable-watchdog \ | |
--enable-deflate \ | |
--enable-expires \ | |
--enable-ssl \ | |
--enable-mpms-shared="all" \ | |
--enable-heartbeat \ | |
--enable-heartmonitor \ | |
--enable-vhost-alias \ | |
--enable-rewrite | |
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- http://www.ijg.org/files/jpegsrc.v9b.tar.gz | tar -zxf - | |
cd jpeg* | |
./configure && make && make install | |
# Install libpng (Used for PHP GD Library Extension) | |
cd /usr/local/src | |
wget -O- https://sourceforge.net/projects/libpng/files/libpng16/1.6.24/libpng-1.6.24.tar.gz/download | tar -zxf - | |
cd libpng* | |
./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-patched.tar.gz | tar -zxf - | |
cd freetds* | |
./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- http://php.net/distributions/php-5.6.26.tar.gz | tar -zxf - | |
cd php* | |
./configure \ | |
--prefix=/usr/local \ | |
--with-apxs2=/usr/local/apache2/bin/apxs \ | |
--enable-cli \ | |
--enable-fpm \ | |
--enable-phpdbg \ | |
--with-config-file-path=/etc \ | |
--disable-short-tags \ | |
--enable-libxml=shared \ | |
--with-openssl \ | |
--with-kerberos \ | |
--with-pcre-regex \ | |
--with-sqlite3 \ | |
--with-zlib \ | |
--enable-bcmath=shared \ | |
--with-bz2 \ | |
--enable-calendar=shared \ | |
--enable-ctype=shared \ | |
--with-curl=shared \ | |
--enable-dba=shared \ | |
--with-enchant \ | |
--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 \ | |
--enable-hash \ | |
--with-imap=shared,/usr/lib \ | |
--with-imap-ssl=shared,/usr/lib \ | |
--enable-intl \ | |
--enable-json=shared \ | |
--without-ldap \ | |
--without-ldap-sasl \ | |
--enable-mbstring=shared \ | |
--enable-mbregex \ | |
--with-mcrypt=shared \ | |
--with-mssql=shared,/usr/local/freetds \ | |
--with-mysql=shared \ | |
--with-mysql-sock=/var/lib/mysql/mysql.sock \ | |
--with-mysqli=shared \ | |
--without-iodbc \ | |
--enable-opcache \ | |
--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 \ | |
--with-readline \ | |
--enable-session \ | |
--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-tokenizer \ | |
--enable-wddx=shared \ | |
--enable-xml=shared \ | |
--enable-xmlreader=shared \ | |
--with-xmlrpc=shared \ | |
--enable-xmlwriter=shared \ | |
--with-xsl=shared \ | |
--enable-zip=shared \ | |
--enable-mysqlnd \ | |
--disable-mysqlnd-compression-support \ | |
--with-pear | |
make | |
make install | |
# Install MongoDB PHP Extension | |
cd /usr/local/src | |
wget -O- http://pecl.php.net/get/mongo-1.6.14.tgz | tar -zxf - | |
cd mongo* | |
phpize && ./configure && make && make install | |
# Install XDebug PHP Extension | |
cd /usr/local/src | |
wget -O- http://pecl.php.net/get/xdebug-2.4.1.tgz | tar -zxf - | |
cd xdebug* | |
phpize && ./configure && make && make install | |
# Move all the PHP Extensions to the extensions directory and remove the temp directory | |
cd /usr/local/lib/php/extensions/no-debug* | |
mv *.so /usr/local/lib/php/extensions/ | |
cd .. | |
rm -rf no-debug* | |
# Install Composer (Install it after PHP is installed) | |
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" | |
php composer-setup.php | |
php -r "unlink('composer-setup.php');" | |
mv composer.phar /usr/local/bin/composer | |
# Install NodeJS | |
cd /usr/local/src | |
wget -O- https://nodejs.org/dist/v6.6.0/node-v6.6.0.tar.gz | tar -zxf - | |
cd node* | |
./configure && make && make install | |
# Install Gulp & Bower | |
npm install -g gulp bower |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment