Skip to content

Instantly share code, notes, and snippets.

@ankur13secret
Last active January 5, 2016 06:02
Show Gist options
  • Save ankur13secret/ee322c067f1d8acbdc27 to your computer and use it in GitHub Desktop.
Save ankur13secret/ee322c067f1d8acbdc27 to your computer and use it in GitHub Desktop.
To setup the nginx server with PgSQL database
#!/usr/bin/env bash
echo "Written By Ankur Mishra"
echo "Starting Server Setup....."
echo "Be Sure you are are a super user..."
# To become a super user
# to update the packages from repositories
apt-get update
# to install or upgrade package necessary to upgrade
apt-get dist-upgrade
# to install git
echo "Installing Git..."
apt-get install git -y > /dev/null
# to install composer
echo "Installing and setting up composer..."
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
# to install nginx server
echo "deb http://ppa.launchpad.net/nginx/stable/ubuntu $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/nginx-stable.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C
apt-get update
echo "Installing Nginx Server..."
apt-get install nginx
# to restart the service
service nginx restart
# to install php5 and all required components
echo "Updating PHP repository"
apt-get install python-software-properties build-essential -y > /dev/null
add-apt-repository ppa:ondrej/php5 -y > /dev/null
apt-get update > /dev/null
echo "Installing PHP"
apt-get install php5-common php5-dev php5-cli php5-fpm -y > /dev/null
# PHP-APC is a free and open PHP opcode cacher for caching and optimizing PHP intermediate code, which helps to optimize the php page processing
echo "Installing PHP extensions"
apt-get install curl php5-curl php5-gd php-apc php5-pgsql -y > /dev/null
# setting the value to zero to increase the security by processing th exact path and in more faster way
echo "Setting Fix Path"
sed -i 's/cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php5/fpm/php.ini
sed -i 's/listen/listen = /var/run/php5-fpm.sock/g' /etc/php5/fpm/pool.d/www.conf
# configuring php5-mcrypt
ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/mcrypt.ini
# enabling php5 mcrypt
php5enmod mcrypt
# to restart the service
service php5-fpm restart
# to install postgreSQL
echo "Installing PostgreSQL..."
apt-get install postgresql postgresql-contrib
# to restart the service
echo "Restarting PostgreSQL..."
service pgsql restart
echo "Login into PostgreSQL.."
echo "The Default password is: postgres and Username is : postgres. You can change it when you will get the prompt below."
echo "Type psql to enter into the postgre shell"
sudo -i -u postgres
echo "Congratulations... Nginx, PHP and PostgreSQL is installed on server."
echo "Thankyou..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment