Thursday, May 19, 2011

Script to install Apache, PHP and MySql on Ubuntu

Here is a shell script i wrote to download and install LAMP on Ubuntu.


#!/bin/bash

echo "current OS information:"
cat /etc/lsb-release

echo "install patches"
sudo apt-get install update

echo "install apache2 and php5..."
sudo apt-get install apache2 php5 libapache2-mod-php5


echo "create test.php at /var/www/test.php"
echo "" | sudo tee /var/www/test.php

echo "restart apache2"
sudo /etc/init.d/apache2 restart

echo "start firefox to check the test page"
firefox "http://localhost/test.php" &

echo "install mysql"
sudo apt-get install mysql-server mysql-client php5-mysql


echo "install PhpMyAdmin"
sudo apt-get install phpmyadmin

sudo echo "Include /etc/phpmyadmin/apache.conf" >> /etc/apache2/apache2.conf
sudo /etc/init.d/apache2 restart

firefox "http://localhost/phpmyadmin" &

#need to set the default character to gb2312 to support chinese character
#mysql> set names 'gb2312'





Enjoy!

No comments: