Is there a way to set up and pre-configure a lamp environment within a bash script without user prompting by dpkg and present data like mysql or root user password and such kinds of things?


Yes but you need to create the installation script yourself.

Example that installs Apache 2, PHP 5, MySQL, the Java JDK, NetBeans, and C++. Where PASSWORD needs to be your MySQL password (found that here):


apt-get update
apt-get -y install apache2
apt-get -y install php5 libapache2-mod-php5
/etc/init.d/apache2 restart

echo mysql-server-5.1 mysql-server/root_password password PASSWORD | debconf-set-selections
echo mysql-server-5.1 mysql-server/root_password_again password PASSWORD | debconf-set-selections
apt-get install -y mysql-server

echo '' >/var/www/phpinfo.php
apt-get -y install openjdk-6-jdk openjdk-6-jre
apt-get -y install libnb-platform12-java
apt-get -y install libnb-platform12-java-doc
mget http://download.netbeans.org/netbeans/7.1.2/final/bundles/netbeans-7.1.2\

#Clean out /tmp...
sudo rm -rf /tmp/*
cd /tmp

#Update this line to reflect newer versions of Netbeans or replace 'javase with 'javaee' or add jee manually via
#Netbeans 'plugins as needed.
wget http://download.netbeans.org/netbeans/7.1.2/final/bundles/netbeans-7.1.2-\

sh /tmp/netbeans-7.1.2-ml-linux.sh --silent

#Add Netbeans launcher to your PATH. Doing so allows you to run 'netbeans' command from the terminal
ln -s /usr/local/netbeans-7.1.2/bin/netbeans /usr/local/bin/

apt-get -y install build-essential
apt-get -y install synaptic

exit 0

If there is more in this script than you need (like C++, netbeans) just remove the apt-get lines. Also might need to change version numbers to the latest stable versions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.