Skip to content

Instantly share code, notes, and snippets.

@nboubakr
Created February 27, 2013 15:44
Show Gist options
  • Save nboubakr/5048869 to your computer and use it in GitHub Desktop.
Save nboubakr/5048869 to your computer and use it in GitHub Desktop.
Install LAMP Server on Fedora
#!/bin/bash
#
# Install LAMP Server on Fedora
#
# Syntax: sudo ./LAMP-installer.sh
#
# Boubakr NOUR <n.boubakr@gmail.com>
# Distributed under the GPL version 3 license
boldRed='\e[1;31m'
boldGreen='\e[1;32m'
boldBlue='\e[1;34m'
reset='\e[0m'
isRoot() {
if [[ $EUID -ne 0 ]]; then
return 0
else
return 1
fi
}
checkInternet() {
wget -q --tries=10 --timeout=5 http://www.google.com -O /tmp/index.google &> /dev/null
if [ ! -s /tmp/index.google ];then
return 0
else
return 1
fi
}
clear
echo
echo -e $boldGreen"Install LAMP Server on Fedora..." $reset
if [[ checkInternet = 0 ]]; then
echo -e $boldYellow"[!] Please check you Internet Connection..." $reset
exit 1
fi
if [[ ! isRoot ]]; then
echo
echo -e $boldRed"[!] This script must be run as root..." $reset 1>&2
exit 1
else
echo
echo -e $boldBlue"[!] Updating the system..." $reset
yum update -y
echo
echo -e $boldBlue"[!] Installing Apache Server..." $reset
yum groupinstall -y web-server
echo
echo -e $boldBlue"[!] Starting Apache HTTP Server..." $reset
systemctl start httpd.service
echo
read -p "Do you want to autostart Apache HTTP Server on boot ? (y/N) " answer
if [ "$answer" = 'y' ]; then
systemctl enable httpd.service
fi
echo
echo -e $boldBlue"[!] Enable Remote Connection to Apache HTTP Server..." $reset
echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT" >> /etc/sysconfig/iptables
echo
echo -e $boldBlue"[!] Installing MySQL Database Server..." $reset
yum groupinstall -y mysql
echo
echo -e $boldBlue"[!] Starting MySQL Server..." $reset
systemctl start mysqld.service
echo
read -p "Do you want to autostart MySQL Server on boot ? (y/N) " answer
if [ "$answer" = 'y' ]; then
systemctl enable mysqld.service
fi
echo
echo -e $boldBlue"[!] MySQL Secure Installation..." $reset
# /usr/bin/mysql_secure_installation
echo
echo -e $boldBlue"[!] Enable Remote Connection to Apache HTTP Server..." $reset
echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT" >> /etc/sysconfig/iptables
echo
echo -e $boldBlue"[!] Installing PHPMyAdmin..." $reset
yum install -y phpMyAdmin
echo
echo -e $boldGreen"All Done..." $reset
fi
#!/bin/bash
#
# Simple script to control webServer
#
# Syntax: sudo ./webServer.sh [start|restart|stop]
#
# Boubakr NOUR <n.boubakr@gmail.com>
# Distributed under the GPL version 3 license
case "$1" in
"start")
echo "Starting Web Server"
systemctl start httpd.service
systemctl start mysqld.service
;;
"restart")
echo "Restarting Web Server"
systemctl restart httpd.service
systemctl restart mysqld.service
;;
"stop")
echo "Stopping Web Server"
systemctl stop httpd.service
systemctl stop mysqld.service
;;
* )
echo "Usage: $0 [start|restart|stop]"
;;
esac
@nclslbrn
Copy link

For login once only:

systemctl start httpd.service && start mariadb.service

or

systemctl start httpd.service && start mysqld.service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment