您的位置:首页 > 其它

ubuntu10.04安装lamp的脚本

2010-08-06 15:36 387 查看
#!/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[/code] 
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: