Skip to content

Instantly share code, notes, and snippets.

@trthanhbk
Last active March 29, 2017 08:49
Show Gist options
  • Save trthanhbk/f8f84de50f3ae5f5de1af36cf4fb48cd to your computer and use it in GitHub Desktop.
Save trthanhbk/f8f84de50f3ae5f5de1af36cf4fb48cd to your computer and use it in GitHub Desktop.
read -p "MySQL Password: " rootpassword
yum update
# Apache php mysql mysql-server installing
echo "Installing httpd"
yum install -y httpd
echo "Installing MYSQL"
touch /etc/yum.repos.d/MariaDB.repo
echo "
# MariaDB 10.1 CentOS repository list - created 2015-12-14 02:58 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
" > /etc/yum.repos.d/MariaDB.repo
#yum install -y mariadb-server mariadb
yum install -y MariaDB-server MariaDB-client
echo "Installing PHP 7"
cd ~
curl 'https://setup.ius.io/' -o setup-ius.sh
bash setup-ius.sh
yum remove -y php-cli mod_php php-common
yum install -y mod_php71u php71u-cli php71u-mysqlnd php71u-xml php71u-mbstring php71u-mcrypt php71u-json php71u-gd
# Starting httpd mysqld service
systemctl restart httpd.service
systemctl start mariadb
# Adding to auto Start httpd mysqld service
systemctl enable httpd.service
systemctl enable mariadb.service
/usr/bin/mysqladmin -u root password $rootpassword
clear
echo "Installing phpMyAdmin"
#phpMyadmin
yum -y install epel-release
yum -y install phpmyadmin
sed -e '/<IfModule mod_authz_core\.c>/,/<\/IfModule>/ s/Require ip 127.0.0.1//' -i.bak "/etc/httpd/conf.d/phpMyAdmin.conf"
sed -e '/<IfModule mod_authz_core\.c>/,/<\/IfModule>/ s/Require ip ::1/Require all granted/' -i.bak "/etc/httpd/conf.d/phpMyAdmin.conf"
systemctl restart httpd.service
echo "Installing crontabs"
#crontab
yum -y install crontabs
echo "Installing Git"
#git
yum install -y git
echo "Installing Unzip"
#unzip
yum install -y unzip
#edit apache config
cd /etc/httpd/conf
mv httpd.conf httpd.conf.bak
wget https://gist.githubusercontent.com/trthanhbk/64cec9caa7f18ed8958444b610186be0/raw/b82da36a80543d194feab7bab5621638530e9ded/httpd.conf
cd /etc/httpd
mkdir sites-enabled
cd /etc/httpd/sites-enabled
wget https://gist.githubusercontent.com/trthanhbk/bd4132ef3f7dbb3061a0c03eb17c832a/raw/2add3ca072ae0369801bbc9f61ca28a6cee548d5/default.conf.example
cd /var/www
mkdir sites
#install FTP
yum -y install vsftpd
mv /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak
cd /etc/vsftpd
wget https://gist.githubusercontent.com/trthanhbk/2ea6f79f866775954eddf8f14bdb4eb5/raw/f71d368bfbd51fd0cd65d94c6c8bb889851e7e63/vsftpd.conf
systemctl restart vsftpd
systemctl enable vsftpd
#chown www:wheel
cd /var/www
chown -R www:wheel sites/
cd /etc/httpd/
chown -R www:wheel sites-enabled/
cd /var/log
chown -R www:wheel httpd/
#add ssh-key to www
echo "Adding ssh-key"
cd /home/www/
mkdir .ssh
cd .ssh/
wget https://gist.githubusercontent.com/trthanhbk/576424772871fe222c93aa6a5808aeee/raw/3bfaeb654eb1b83c268838f61a92ac5fd846686c/authorized_keys
cd /home/www/
chown -R www:wheel .ssh/
echo "Adding ssh-key DONE"
#Install Composer
echo "Install Composer"
cd ~
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { 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
echo "Install Composer - Done"
#Making swap file
echo "Making swap file"
mkdir /var/www/sites/swap
fallocate -l 4G /var/www/sites/swap/swapfile
chown -R www:wheel /var/www/sites/swap/
chmod 600 /var/www/sites/swap/swapfile
mkswap /var/www/sites/swap/swapfile
#swapon /var/www/sites/swap/swapfile // Coment due to swap cause io overload
#echo "/var/www/sites/swap/swapfile swap swap sw 0 0" >> /etc/fstab // Coment due to swap cause io overload
echo "vm.swappiness = 10" >> /etc/sysctl.conf
echo "vm.vfs_cache_pressure = 50" >> /etc/sysctl.conf
sysctl vm.swappiness=10
sysctl vm.vfs_cache_pressure=50
echo "Making Swap - DONE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment