LAMP一键安装脚本

该脚本集成了apache,mysql,php,并且添加了phpmyadmin工具

lamp-install.sh

1#!/bin/bash 2# 3#LAMP Install Script V1.0 4#DATE 2015.3.6 5#MAINTAINER Pengfei.Shi--<shipengfei92@gmail.com> 6# 7#Replace the mysql root password for your own 8 9MYSQL_ROOT_PASS=$1 10#Replace the mysql phpmyadmin password for your own 11 12MYSQL_PHPMYADMIN_PASS=$2 13 14#Set the DNS of SJTU 15echo "nameserver 202.120.2.101" > /etc/resolv.conf 16#Change the sources.list to SJTU Local Sources 17sed -i "s/nova.clouds.archive.ubuntu.com/ftp.sjtu.edu.cn/g" /etc/apt/sources.list 18 19apt-get update 20 21echo mysql-server mysql-server/root_password password $MYSQL_ROOT_PASS | sudo debconf-set-selections 22echo mysql-server mysql-server/root_password_again password $MYSQL_ROOT_PASS | sudo debconf-set-selections 23 24echo "phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2" | debconf-set-selections 25echo "phpmyadmin phpmyadmin/dbconfig-install boolean true" | debconf-set-selections 26echo "phpmyadmin phpmyadmin/mysql/admin-user string root" | debconf-set-selections 27echo "phpmyadmin phpmyadmin/mysql/admin-pass password $MYSQL_ROOT_PASS" | debconf-set-selections 28echo "phpmyadmin phpmyadmin/mysql/app-pass password $MYSQL_PHPMYADMIN_PASS" |debconf-set-selections 29echo "phpmyadmin phpmyadmin/app-password-confirm password $MYSQL_PHPMYADMIN_PASS" | debconf-set-selections 30 31apt-get install -y mysql-server-5.5 32apt-get install -y apache2 33apt-get install -y php5 php5-mysql 34apt-get install -y phpmyadmin 35#Create the test file for php 36echo "<?php phpinfo() ?>" >> /var/www/html/test.php 37#Link the phpmyadmin to apache2 dir 38ln -s /usr/share/phpmyadmin/ /var/www/html/ 39 40
1 用法: 2

./lamp-install <mysql-root-password-you-want-to-set> <mysql-phpmyadmin-password-you-want-to-set>

具体可根据个人设定修改安装脚本

代码交流 2021