Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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

#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.
sh /tmp/ --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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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