In Part Two, we installed the operating system for our virtual machine (Debian), and performed some extra configuration steps. In Part Three, we will be installing some helpful applications to use with development – SSH, SFTP, Vim, and Git. Part Four will be where we start installing the bulk of our required applications.
Now our virtual machine and operating system have been installed, we can begin setting up our machine for web development.
You should be now in the virtual machine window, and shown a prompt to login. Log in as the root user – you should now be logged in as shown below:
Now we are logged in, we can begin to install needed applications. The first application we will be installing is SSH.
To install ssh, type in apt-get install ssh and press the Enter key. You will be asked to confirm the installation – enter y, then press the Enter key to proceed. If you have followed my guide completely so far, you will be shown a message asking us to insert a disk (typically the Debian ISO). To prevent this from showing every time we install or update applications, we will need to edit a file called ‘sources.list’, which should be located in /etc/apt/. To do this, press the Ctrl and c keys together, then type the command ‘vi /etc/apt/sources.list’ to the shell. This should open up the sources.list file as below:
We will now remove the two lines referencing the Debian CDROM, and the empty lines between the top and the first non-cdrom update. To do this enter ‘dd’ six times – this command is used to delete lines in an opened file. You should now have something like below:
Once you have confirmed you have something similar, press Ctrl and c keys, then type in ‘:wq’, and then press the Enter key. The :wq command will save the changes to sources.list file and exit out of the vi console.
Now the cdrom references have been removed, we can continue installing the software. Before we do so, we should update the system first. To do this, enter ‘apt-get update && apt-get upgrade’ to the shell. The first part of the command (before the && symbols) updates the software repository, and the second part executes the updating process. If you haven’t figured it out already, the && symbol can be used to run multiple commands in one line. Once you have entered the two commands and && symbol, press the Enter key. Thee repository should then be updated, and any updates scheduled for installation.
If you receive any errors (with the repository URL’s), do the following:
- Visit http://debgen.simplylinux.ch/ to generate source repository URLs.
- Fill out the information as in the image below:
You can select a different country if you wish.
- Click the ‘Generate sources.list’ button (as shown in the previous image).
- You should now be shown something similar to the following image:
- We will now replace the repository URLs in our sources.list file with the ones shown in the previous image. Open up our sources.list file by entering ‘vi /etc/apt/sources.list’, then pressing the Enter key.
- Replace the existing entries with the ones created by the online generator, save the changes, then close the file.
- You can now execute the update and upgrade commands ‘apt-get update && apt-get upgrade’.
- (Optional) You can reboot the machine then run the command if the process doesn’t work.
With our sources.list file sorted out, we can resume installing SSH and SFTP.
Enter ‘apt-get install ssh’ to the shell, and press the Enter key. If you get any prompts during the process, press the y and Enter keys to proceed. SSH should now be installed on our development machine.
As I like to copy and paste some commands into the shell, I prefer to connect to my development machine via a Git shell. To do this, you can create a file which can be executed to make the connection. On your native machine (e.g. my Windows machine), open up a text editor (I am using Notepad++) and enter the following information:
- ssh -p 2222 root@localhost
Save this file with the name ‘access-web-dev-machine’ with no file extension (done by selecting ‘all file types’ when you save the file).
We will now open up our Git shell. To do this, navigate to where you saved the file we created earlier, right-click in this location, then select ‘Git Bash Here’. On my machine, this looks like the following:
Clicking on this option should open the Git Bash Shell.
In order to execute the script we created earlier, we need to make it executable. In the Git Bash shell, enter ‘chmod u+x access-web-dev-machine’ (without the single quote marks) and press the Enter key.
In case you are wondering – ‘chmod’ means to change permissions for a file according to mode, ‘u’ stands for ‘user’, and ‘x’ stands for ‘executable’. To add executable permissions for the user, we append the executable mode to the user with a ‘+’ symbol – resulting in ‘u+x’, then set the permissions with ‘chmod’.
Now we have set executable permissions for our script, we can run it. To do so, type in ‘./access-web-dev-machine’ (without the single quote marks) and press the Enter key. You may get a message about an ECDSA key fingerprint – this is normal for a new virtual machine, so follow their prompt (in our case, type in ‘yes’, then press the Enter key. You will then be prompted to enter the password (for our root user). Enter this password (as defined when we set up our operating system), then press the Enter key. You should now be logged into your virtual web development server via Git Bash, and see something similar to the image below:
We should now be able to access our machine via an FTP/SFTP client – so we can upload files, like website owners do for their websites. I will be using FileZilla for this guide, but you can choose any reliable client (although my instructions will be for FileZilla).
Firstly, open up FileZilla. Then click on the icon below ‘File’, which is in the top left corner of the FileZilla application. Then click on the ‘New Site’ button. We will be saving our credentials in a ‘New Site’. You should now see something like the following:
For this guide, we will be naming our site ‘Debian Development Server’ – enter this where you see ‘New Site’ under ‘My Sites’.
In the ‘General’ tab, we will be entering in the following details:
- Host: localhost
- Port: 2222
- Protocol: SFTP – SSH File Transfer Protocol
- Logon Type: Normal
- User: root
- Password: debian
The rest of the fields are optional. When you have entered in the details, you should see something like the image below:
To see if our SFTP connection will work, click on the Connect button. If our details are correct, you might get something like the following:
If you get this, check the box as shown above, and click on the OK button. This will connect us to our virtual web development server’s file system. By default, we will be taken to the /root directory upon logging in – and see something like below:
IMPORTANT: Do not allow logging in as root for a live machine, via both SSH and FTP/SFTP (i.e. a machine that hosts a publically accessible website) – this is very insecure, and can leave the live machine vulnerable to malicious hackers.
Now we can access our virtual web development server via SSH (and FTP/SFTP), we can install more applications necessary for web development. We will be installing the following packages in this part of the guide:
Before we proceed, we will need to add some extra lines to our sources.list file. While logged into your virtual machine, via the Git Bash shell, open the sources.list file with the command ‘vi /etc/apt/sources.list’, and past the following lines at the bottom:
#To install the latest version of Apache, MySQL, PHP, phpMyAdmin, Memcached deb http://packages.dotdeb.org wheezy all deb-src http://packages.dotdeb.org wheezy all #To install varnish caching deb https://repo.varnish-cache.org/debian/ wheezy varnish-4.0 deb-src https://repo.varnish-cache.org/debian/ wheezy varnish-4.0
Your sources.list file should now look like the following:
We will then need to add DotDeb’s and Varnish Cache’s GnuPG keys to our system. We will need the ‘curl’ package for this, so run ‘apt-get install curl’ to install it. To add the GnuPG keys, run the following two commands:
wget http://www.dotdeb.org/dotdeb.gpg &amp;&amp; apt-key add dotdeb.gpg curl https://repo.varnish-cache.org/debian/GPG-key.txt | apt-key add -
Now run ‘apt-get update && apt-get upgrade’ to load the new configuration.
We will now install Vim and Git on our virtual web development server.
To install Vim, run the following command: apt-get install vim. If you get a prompt asking you to continue, type in the letter y and press the enter key. If all went well for you, Vim should now be installed.
Git is usually installed by default, but we need to install it manually for this virtual web development server. To install it, run the following command: apt-get install git. Accept any prompts to continue by typing the letter y and pressing the Enter key. Git should now be installed in our virtual machine.
This step concludes Part Three.
Part Three Conclusion
In Part Three, we installed the following applications on our Debian-based virtual web development server:
We also prepared our sources.list file with appropriate repository URL’s for future application installations and updates. We also connected to our virtual machine via Git Bash and FileZilla.
In Part Four, We will be installing the L.A.M.P stack on our virtual web development server. Parts Five and Six will then take us through installations of Varnish Caching, Memcached, and PhpMyAdmin.