Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
add comment

1 Answer

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):

#!/bin/sh

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\
-ml-linux.sh

#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-\

ml-linux.sh
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/

#C++
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
add comment

Your Answer

 
discard

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.