jump to navigation

Ubuntu Updates and Installs December 20, 2008

Posted by ModelR in UBUNTU LAMP Project.
trackback
THIS IS A SUBSECTION OF THE VERY VITAL UBUNTU LAMP SERVER PROJECT

You can find the full outline of this project here:
LINK: Very Vital Ubuntu LAMP Server Project Outline

Please support this project.
Make A Donation

Just a quick recap. Basically we have installed the Jeos server. Now it’s fresh and ready for us to customize.

First we will run a check for updates with the following command:
$ sudo apt-get update && sudo apt-get upgrade

Then we will move on to installing VMware Tools
You can also refer to this documentation: Ubuntu Help on installing VMware Tools
Or documentation more specific to Jeos:Installing VMware Tools on Jeos
Here are the commands we will run:
$ sudo aptitude install build-essential linux-headers-$(uname -r)

$ sudo aptitude install psmisc

On the VMware server console, click: VM -> Install VMware Tools

$ mount /media/cdrom0

$ sudo cp -a /media/cdrom0/VMwareTools*.gz /tmp/
$ cd /tmp/
$ sudo tar -xzvf VMwareTools*.gz

$ cd vmware-tools-distrib/
$ sudo ./vmware-install.pl

Accept all the default settings when asked for input

—-
Now that all that is out of the way we will install the LAMP package
NOTE: To install the various LAMP components on a Debian system, see this article here: http://www.howtoforge.com/ubuntu_debian_lamp_server

$ sudo apt-get install lamp-server^

Install the OpenSSH server
$ sudo apt-get install openssh-server

Install the Samba server
$ sudo apt-get install samba

Install phpMyAdmin
$ sudo apt-get install phpmyadmin

Install GD Graphics Library
$ sudo apt-get install php5-gd

Installed the Nano text editor (it’s more convenient to use than vi)
$ sudo apt-get install nano

Installed cURL
$ sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

Give the tmp directory proper permissions
$ sudo chmod 1777 /tmp

On the STANDARD version, enabled the userdirectory module
Now each user can store their own website in their /home/username/public_html directory
$ sudo a2enmod userdir

—–
We will create a first run script to change the user1 password and the MySQL root password

add the following to bottom of /etc/bash.bashrc:

if [ ! -e /etc/opt/first-run/initial_config_done ]; then
/opt/first-run/initial_config.sh
sudo touch /etc/opt/first-run/initial_config_done
fi

create a sub-directory called first-run in /opt/
$ sudo mkdir /opt/first-run/

create a sub-directory called first-run in /etc/opt/
$ sudo mkdir /etc/opt/first-run/

create this file:
/opt/first-run/initial_config.sh

edit the file initial_config with a text editor, entering this:
#!/bin/bash

# FIX THE NETWORK BY DELETING A FILE
echo ""
echo ""
sudo rm -rf /etc/udev/rules.d/70-persistent-net.rules
echo ""
echo ""
echo ""
echo "Thank you for choosing the Very Vital LAMP Server"
echo "This is the FIRST RUN of this server"
echo "We are going to go through a few setup steps"
echo "Then we will reboot the server"
echo ""
echo "For your security we will now change your password"
let done=0
while [ $done -eq 0 ]; do
read -s -p "New password: " NEWPASS1
echo""
read -s -p "Confirm new password: " NEWPASS2
echo ""
if [ "$NEWPASS1" == "$NEWPASS2" ]; then
let done=1
(echo $NEWPASS1; echo $NEWPASS1) | passwd
else
echo "The passwords do not match, please try again."
echo ""
fi
done

# Now change the mysql password
echo ""
echo ""
echo "Please specify a new MySQL root password"
let done=0
while [ $done -eq 0 ]; do
read -e -s -r -p "New MySQL root password:" PASS1
echo ""
read -e -s -r -p "Confirm the MySQL root password:" PASS2
if [[ "$PASS1" == "$PASS2" ]]; then
let done=1
#perfrom the actual change assuming that our initial password is root
mysqladmin -u root --password='root' password $PASS1
else
echo "The passwords do not match, please try again."
fi
done

#Perform the reinstall of openssh so that the key is regenerated
echo ""
echo ""
echo "Would you like to create new SSH keys?"
echo "Please note that you will require an internet connection"
echo "If you do not have an internet connection type NO"
echo "Otherwise you will not be able to use SSH to connect to this server"
read -p "Create new SSH keys? Type YES to create new: " confirm
if [ "$confirm" == "YES" ]; then
echo "We are now going to generate your ssh keys"
sudo apt-get .purge -y remove openssh-server
sudo apt-get install -y openssh-server
echo ""
else
echo ""
echo "SSH new key creation successfully aborted."
echo ""
fi
# ADDITIONAL FIRST USER LOGIN ACTIONS BELOW
echo ""
echo "The current hostname is: "$(hostname)
read -p "Would you like to change it? Type YES to change: " change
if [ "$change" == "YES" ]; then
echo ""
echo "Note: After name change system will reboot"
read -p "Enter new hostname : " newhost
cat /etc/hostname | sed -e {'s/'$(hostname)'/'$newhost'/'} > /tmp/hostname2
cat /etc/hosts | sed -e {'s/'$(hostname)'/'$newhost'/'} > /tmp/hosts2
sudo rm -rf /etc/hostname
sudo mv /tmp/hostname2 /etc/hostname
sudo rm -rf /etc/hosts
sudo mv /tmp/hosts2 /etc/hosts
echo "The hostname has been changed to: "$newhost
echo ""
else
echo ""
echo "Current hostname is still the same: "$(hostname)
echo ""
fi
echo "You have completed the FIRST RUN"
echo "Before you start please reboot the system"
echo "Type this command to reboot the system: sudo init 6"
echo ""

Then we’ll make the above script executable
$ sudo chmod a+x /opt/first-run/initial_config.sh
—–
Now we will start cleaning up the VM
$ sudo apt-get clean

We right null to a file
$ sudo dd if=/dev/null of=junk
Then we run this command
$ sync

We will fill the unused space with zeros
$ sudo dd if=/dev/zero of=junk
After running this you will get the message
“dd: writing to ‘junk’: No space left on device”

Then we run this command
$ sync
And now we remove the junk file
$ sudo rm junk

Clear the commands that we have typed
$ history -c
or we can edit this file and delete it's contents:
/home/user1/.bash_history

Advertisements

Comments»

No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: