#!/bin/bash

 #first install
 #attention to input root passwd
 sudo apt-get install apache2 mysql-server mysql-client php5 php5-gd php5-mysql
 #then change the authority of the directory
 sudo chmod 777 /var/www/
 sudo apt-get install phpmyadmin
 sudo ln -s /usr/share/phpmyadmin /var/www
 #cannot load mcrypt
 sudo apt-get install libmcrypt4 php5-mcrypt
 #start rewrite service
 sudo a2enmod rewrite
 #restart the service
 sudo /etc/init.d/apache2 restart
 #modify the config file
 sudo cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak
 #support php
 sudo echo 'AddType application/x-httpd-php .php .htm .html' >>/etc/apache2/apache2.conf
 #encode 
 sudo echo 'AddDefaultCharset UTF-8' >>/etc/apache2/apache2.conf
 #Restarting web server apache2 apache2: 
 #Could not reliably determine the server's fully qualified domain name,
 # using 127.0.1.1 for ServerName
 sudo echo 'ServerName 127.0.0.1' >>/etc/apache2/apache2.conf
 sudo /etc/init.d/apache2 restart
 #test
 cat <<END >/var/www/test.php
 <?php
         $result = @mysql_connect("localhost","root","passwd");
         if (!$result)
         {
                 die('无法连接! ' . mysql_error());
          }
          else echo "Mysql已经正确配置";
          mysql_close($result);
 ?>


END

firefox http://localhost/test.php

 

#!/bin/bash
#first install
#attention to input root passwd
sudo apt-get install apache2 mysql-server mysql-client php5 php5-gd php5-mysql
#then change the authority of the directory
sudo chmod 777 /var/www/
sudo apt-get install phpmyadmin
sudo ln -s /usr/share/phpmyadmin /var/www
#cannot load mcrypt
sudo apt-get install libmcrypt4 php5-mcrypt
#start rewrite service
sudo a2enmod rewrite
#restart the service
sudo /etc/init.d/apache2 restart
#modify the config file
sudo cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak
#support php
sudo echo 'AddType application/x-httpd-php .php .htm .html' >>/etc/apache2/apache2.conf
#encode 
sudo echo 'AddDefaultCharset UTF-8' >>/etc/apache2/apache2.conf
#Restarting web server apache2 apache2: 
#Could not reliably determine the server's fully qualified domain name,
# using 127.0.1.1 for ServerName
sudo echo 'ServerName 127.0.0.1' >>/etc/apache2/apache2.conf
sudo /etc/init.d/apache2 restart
#test
cat <<END >/var/www/test.php
<?php
        $result = @mysql_connect("localhost","root","passwd");
        if (!$result)
        {
                die('无法连接! ' . mysql_error());
         }
         else echo "Mysql已经正确配置";
         mysql_close($result);
?>
END
firefox http://localhost/test.php