Friday, July 20, 2007

"Automate Installation of Web Server in openSUSE 10.2 (installs Apache, MySQL, and PHP) - bash script"

A nice script written by Scott Morris, good for lazy/newbie. Full details at http://www.suseblog.com/?p=240

http://www.suseblog.com/install-lamp-stack.sh.tar.bz2 (tar -jxvf install-lamp-stack.sh.tar.bz2)

#!/bin/sh
# Bash script to install a lamp stack on an opensuse 10.2 system.

printf "##############################################################################
##\n"
printf "INSTALL SCRIPT FOR APACHE, MYSQL, AND PHP ON openSUSE 10.2\n"
printf "by Scott Morris (2007-06-21)\n"
printf "http://www.suseblog.com/\n\n"
printf "##############################################################################
##\n"

# Make sure we are root.
if [ "$EUID" != "0" ]; then
echo "You must have root privileges to run this script!"
exit 1
fi

printf "\n############################################################################
####\n"
printf "Installing Apache, MySQL, and PHP...\n"
printf "##############################################################################
##\n"

yast -i apache2-mod_php5 php5 php5-bz2 php5-gd php5-iconv php5-mbstring php5-mcrypt ph
p5-mysql php5-snmp php5-zlib mysql mysql-client mysql-devel mysql-shared perl-DBD-mysq
l apache2 apache2-mod_perl apache2-prefork libapr-util1 libapr1 php5-pdo

printf "\n############################################################################
####\n"
printf "Starting Apache and MySQL...\n"
blah@winnt:/tmp/attack_lab> vim install-lamp-stack.sh
blah@winnt:/tmp/attack_lab> cat install-lamp-stack.sh
#!/bin/sh
# Bash script to install a lamp stack on an opensuse 10.2 system.

printf "################################################################################\n"
printf "INSTALL SCRIPT FOR APACHE, MYSQL, AND PHP ON openSUSE 10.2\n"
printf "by Scott Morris (2007-06-21)\n"
printf "http://www.suseblog.com/\n\n"
printf "################################################################################\n"

# Make sure we are root.
if [ "$EUID" != "0" ]; then
echo "You must have root privileges to run this script!"
exit 1
fi

printf "\n################################################################################\n"
printf "Installing Apache, MySQL, and PHP...\n"
printf "################################################################################\n"

yast -i apache2-mod_php5 php5 php5-bz2 php5-gd php5-iconv php5-mbstring php5-mcrypt php5-mysql php5-snmp php5-zlib mysql mysql-client mysql-devel mysql-shared perl-DBD-mysql apache2 apache2-mod_perl apache2-prefork libapr-util1 libapr1 php5-pdo

printf "\n################################################################################\n"
printf "Starting Apache and MySQL...\n"
printf "################################################################################\n"

/etc/init.d/apache2 start
/etc/init.d/mysql start

printf "\n################################################################################\n"
printf "Adding Apache and MySQL to boot sequence...\n"
printf "################################################################################\n"

chkconfig -a apache2
chkconfig -a mysql

printf "\n################################################################################\n"
printf "Status of Apache and MySQL...\n"
printf "################################################################################\n"

/etc/init.d/apache2 status
/etc/init.d/mysql status

printf "\n################################################################################\n"
printf "You must now run the following command to initialize your MySQL root password:\n"
printf "/usr/bin/mysqladmin -u root password 'new-password'\n"
printf "/usr/bin/mysqladmin -u root -h `hostname`.`dnsdomainname` password 'new-password'\n"
printf "Note that unless you've set it up to be different, your web root is here:\n"
printf "/srv/www/htdocs\n"
printf "################################################################################\n"

No comments: