Last active
January 5, 2016 06:03
-
-
Save ankur13secret/e932cba4bd5e967aa5b2 to your computer and use it in GitHub Desktop.
To Setup Nginx server on Ubuntu
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
#!/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 | |
sudo su -i | |
# 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 | sudo php -- --install-dir=/usr/local/bin --filename=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 php5-mcrypt php-apc php5-mysql -y > /dev/null | |
# to make the installation format of mysql in automation format | |
apt-get install debconf-utils -y > /dev/null | |
# to set the password | |
debconf-set-selections <<< "mysql-server mysql-server/root_password password secret" | |
# to confirm the password | |
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password secret" | |
apt-get install mysql-server -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 | |
echo "Congratulations... Nginx, PHP and Mysql is installed on server." | |
echo "Thankyou..." | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment