Back to Course |
Deploy Laravel Project to AWS EC2: Step-By-Step

Update EC2 Ubuntu Server

We continue preparing our server for the upcoming Laravel project. Usually, the first thing after fresh installation, before everything else, are OS and software updates. So, let's take care of that.

  1. Since updates are system-wide changes, you need root privileges for that. Very often, tutorials prepend all commands with sudo which is not super convenient when doing administrative work on servers. To elevate privileges to root enter:
ubuntu@ip-172-31-44-101:~$ sudo su -
root@ip-172-31-44-101:~#
  1. The most overlooked command when administrating the server is the screen command. It provides the ability to launch and use multiple shell sessions. What's the deal with the screen command and updates you may ask?

While it may be not a big deal executing simple commands such as cd or ls, on processes that take more time and do system-wide changes such as updates it is crucial. Imagine you lose your connection to the server due to whatever reason, then the whole session terminates and the running process in the foreground gets interrupted. Combine that with system updates and your server might get bricked and not even boot anymore. When running commands in the screen session it persists on the server even if you get disconnected.

Open a screen session and press <space> to continue:

root@ip-172-31-44-101:~# screen

In case you get disconnected reconnect to the server and resume where you left off by issuing:

root@ip-172-31-44-101:~# screen -r

More information on the screen command can be found on man pages or directly in the shell man screen.

  1. To install updates enter:
root@ip-172-31-44-101:~# apt-get update && apt-get upgrade
  1. While writing this article it didn't go as well as planned.

If you didn't encounter this error just skip to step 5.

During the apt-get upgrade command error message appeared:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
 
The following packages have unmet dependencies:
grub-efi-amd64-signed : Depends: grub-efi-amd64-bin (= 2.06-2ubuntu7) but 2.06-2ubuntu10 is to be installed
E: Broken packages

To quickly fix that enter:

root@ip-172-31-44-101:~# apt --only-upgrade install grub-efi-amd64-signed

And repeat step 3.

  1. You will get a prompt if you want to continue, so enter Y to proceed
69 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
39 standard security updates
Need to get 44.6 MB/78.4 MB of archives.
After this operation, 6882 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y

After a few miles of text you get another prompt to choose which services to restart:

Package configuration

At this point, just press the <TAB> key to select the <Ok> button and press <Enter>, what you pick doesn't matter at all this time, because we are going to reboot the server anyway to boot up into newest kernel if any were installed.

Finally, reboot the server:

root@ip-172-31-44-101:~# reboot

Your connection will get closed and in 1-3 minutes updated server should be up and running so you will be able to reconnect.

Congratulations, you've installed the latest updates on your server!