Script for installing Apache, Mysql, phpMyAdmin on Centos

I create a simple script for installing Apache, Mysql, phpMyAdmin on Centos

Create a sh file in tmp directory

cd /tmp
nano install.sh

Paste below content in install.sh file

#!/bin/bash

clear
echo 'Going to install phpmyadmin, httpd, mysql on server..'

echo 'installing wget..'
yum install -y wget

echo 'Installing httpd, mysql, mysql-server, php, php-mysql'
yum install -y httpd mysql mysql-server php php-mysql

echo 'now adding epel-release-6-8.noarch.rpm'
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

echo 'Installing php-mcrypt'
yum install -y php-mcrypt

echo 'Installing phpmyadmin'
yum install -y phpmyadmin

echo 'Create symlink for phpmyadmin'
if [ -s /var/www/html/phpmyadmin ]
then
    rm /var/www/html/phpmyadmin
fi
ln -s /usr/share/phpMyAdmin /var/www/html/phpmyadmin


echo 'Find server IP'
ip=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`
echo "IP detected as $ip"

echo "Modify phpMyAdmin.conf.."
if [ -s /etc/httpd/conf.d/phpMyAdmin.conf ]
then 
    rm /etc/httpd/conf.d/phpMyAdmin.conf
fi

cat > /etc/httpd/conf.d/phpMyAdmin.conf << DELIM
Alias /phpmyadmin /var/www/html/phpmyadmin
<Directory /var/www/html/phpmyadmin>
 Options -Indexes
 Order Deny,Allow
 Allow from localhost $ip
</Directory>
<Directory /var/www/html/phpmyadmin/setup>
 Order Deny,Allow
 Deny from All
</Directory>
<Directory /var/www/html/phpmyadmin/libraries>
 Order Deny,Allow
 Deny from All
</Directory>
DELIM

echo 'Start Apache and Mysql server'

service httpd start
service mysqld start

echo 'Add httpd, mysql on boot'

chkconfig httpd on
chkconfig mysqld on

clear
echo 'Setting mysql'
mysql_secure_installation

clear
echo "Done. Reboot server. After reboot you can launch phpmyadmin: http://id-address/phpmyadmin"

Now  launch installing process

chmod +x install.sh
./install.sh

Leave a Reply

Your email address will not be published. Required fields are marked *