Skip to content

Instantly share code, notes, and snippets.

@ngfw
Last active July 31, 2016 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngfw/76528a018224060f26d58d87f89b7f36 to your computer and use it in GitHub Desktop.
Save ngfw/76528a018224060f26d58d87f89b7f36 to your computer and use it in GitHub Desktop.
Installes rsync, vim, nginx, php-fpm mredis, git and php
#!/bin/bash
#
# Cantos 7 quick webserver installation
# Installes rsync, vim, nginx, php-fpm mredis, git and php
# Default Webserver Directory: /home/webserver
# NOTE: script disables SeLinux
#
######## CONFIG ##########
router="index.php"
serverRoot="/home/webserver"
domain="change_me.com"
timezone="America/New_York"
##########################
echo -e "\n\n\n" > install.log
printf "\nNG installation initiated\n\n"
printf "Installing repos "
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm >> install.log 2>>install.log
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm >> install.log 2>>install.log
#nginx repo
echo "
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/\$releasever/\$basearch/
gpgcheck=0
enabled=1" > /etc/yum.repos.d/nginx.repo
printf "[DONE]\n"
printf "Installing rsync "
yum install rsync -y >> install.log 2>>install.log
printf "[DONE]\n"
printf "Installing vim "
yum install vim -y >> install.log 2>>install.log
printf "[DONE]\n"
printf "Installing nginx "
yum install nginx -y >> install.log 2>>install.log
printf "[DONE]\n"
printf "Installing redis "
yum install redis -y >> install.log 2>>install.log
printf "[DONE]\n"
printf "Installing git "
yum install git -y >> install.log 2>>install.log
printf "[DONE]\n"
printf "Installing php "
yum install php-fpm php-pecl-xdebug php-pgsql php-mysql php-pdo php-mbstring php-bcmath php-xml php-opcache -y >> install.log 2>>install.log
printf "[DONE]\n"
printf "Disabling SeLinux "
setenforce Permissive
sed -i "s@SELINUX=enforcing@SELINUX=disabled@g" /etc/sysconfig/selinux
printf "[DONE]\n"
printf "Configuring php "
sed -i "s@;date.timezone =@date.timezone = $timezone@g" /etc/php.ini
sed -i "s@;cgi.fix_pathinfo=1@cgi.fix_pathinfo=0@g" /etc/php.ini
printf "[DONE]\n"
printf "Configuring nginx "
mkdir $serverRoot
echo "
<?php
echo '<h1>Server configured successfully!</h1>';
" > $serverRoot/$router
chmod 644 $serverRoot/$router
rm -f /etc/nginx/conf.d/*
echo "
server {
listen 80;
server_name l localhost $domain www.$domain;
location / {
root $serverRoot;
index $router;
try_files \$uri \$uri/ /$router;
}
location ~ \.php$ {
root $serverRoot;
fastcgi_index $router;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
}
}
" > /etc/nginx/conf.d/server.conf
printf "[DONE]\n"
printf "Setting programs to start at boot "
chkconfig --levels 235 php-fpm on
chkconfig --levels 235 redis on
chkconfig --levels 235 nginx on
printf "[DONE]\n"
printf "Starting services "
service php-fpm start >> install.log 2>>install.log
service redis start >> install.log 2>>install.log
service nginx start >> install.log 2>>install.log
printf "[DONE]\n"
echo "ALL DONE!"
printf "\n You can find installation log in install.log file."
printf "\n Please check your webserver at http://$domain/ \n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment