I’ve been honing my HTML & CSS recently by utilizing a host of mostly free online resources. Using the online editors that these resources have is a very easy way to view how HTML pages are rendered.
However, creating your own lab environment that allows you to build web pages in your own directories on your own server will lead to greater familiarity with actual production environments.
LAMP is an open source software stack/bundle that provides developers with the tools needed to create dynamic web pages. These tools are Linux, Apache, MySql, and PHP (LAMP). In this project I’ll be installing the LAMP stack on an Ubuntu 16 Server running in VMware vSphere that will be given the hostname of Torvalds in homage to the creator of Linux.
Virtual Machine Creation
First, I downloaded the most up to date Ubuntu Server 16 ISO from the Ubuntu website. Then I created a new virtual machine in vSphere with 2 CPUs, 2 GB of memory, 40 GB of thin provisioned storage, and my downloaded ISO file as the CD/DVD drive file that would be connected at power up. Then I spun up the VM to configure Ubuntu.
I chose the default options when configuring Ubuntu and logged into the server for the first time once it’d rebooted at the end of the configuration process. I then installed Ubuntu desktop because I’m a sucker for having GUIs on my servers. I installed the GUI through apt-get by using the simple following commands and then rebooting:
sudo apt-get update
sudo apt-get install ubuntu-desktop
Then I gave my server a static IP address so that I could find it on my network. This is done by editing the /etc/network/interfaces file. First I had to give my user permission to edit this file by using the following, substituting in my username:
sudo chown username /etc/network/interfaces
sudo chmod ug+rwx /etc/network/interfaces
Then I found my network adapter listed within the file and changed it to ‘static’ and appended the following network information, substituting my network info for the capital letters, and saved the doc:
Next, Apache, MySQL, and PHP need to be installed on the Ubuntu Server. This can be accomplished by using these simple apt-get commands:
sudo apt-get install apache2
sudo apt-get install mysql-server
sudo apt-get install php7 libapache2-mod-php7
MySQL will run you through additional basic configuration steps, such as setting a user password. To verify that apache had successfully installed, I just needed to plug the host IP address into a browser window to make sure I got this:
Next, I verified that PHP was up and working by creating a simple PHP file called /var/www/info.php with the following bit of code in the file:
Then I restarted the apache service by entering ‘sudo service apache2 restart’ and then navigated to HOSTNAME/info.php in a browser to verify that everything was kosher.
I wanted to set up LAN FTP access to my new LAMP server to mimic development on a production web server. To accomplish this, I installed vsftpd which is a lightweight FTP server. I did this with the following command:
sudo apt-get install vsftpd
Then I edited the /etc/vsftpd.conf file to ensure proper access for my user. I uncommented out the following commands within the doc to do so:
And appended these commands to the end of the document:
Next, I ensured that my user had access to the directory where the HTML and PHP files will live, so I entered the following commands:
sudo chmod -R ugo+rw /var/www
Then I plugged in the host and username info and selected port 21 in my FTP client and was able to connect to the LAMP server. Yay!!
I then added an A record and PTR record in my network’s DNS server to associate my new LAMP server’s hostname with it’s IP on my network (and vice versa). Torvalds is a very insecure apache server as it is only meant for internal LAN hosting and isn’t accessible to the internet. However, I may install encryption/SSH onto the server in the future to give added security and for learning purposes.