5CS022 Week 7 Azure Linux Server
5CS022 Week 7 Azure Linux Server
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana
● Make sure the Subscription is on "Azure for Students"
● Name the Virtual Machine name "lx"+ your student ID number, eg. "lx1234567"
● Make sure the Region is on (US) East US
● Set the Availability options to "No infrastructure redundancy required"
● Select the "Ubuntu Server 18.04 LTS – Gen 1" image
● Select the VM Size: "Standard_B1s – 1vcpu, 1GiB memory". This is an appropriate size and cost for the Linux
Server as it does not require as much as Windows.
● Create your administrator user account and password. Please note this information down somewhere. If you
forget, you will be locked out of your Virtual Machine and there will be nothing we can do.
● For the Inbound ports rules, select all available ones for now, and those are 80, 443,and 22.
Then click on "Review + create" to validate your Virtual Machine, and it should after a few moments say "Validation
passed"
● Please make a note of your server's Public IP address.( eg. 40.71.183.26), as you will need this to connect to it.
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana
Part 2 – Connect to virtual machine
● Start a command prompt on your Windows PC.
● Connect to your Ubuntu Linux server using SSH, by enter into the command prompt :
ssh jeffrey@40.71.183.26
Obviously use your own server's public IP address, and username, rather than mine.
● You can also use ssh program Putty to connect to your server.
● The first time you connect, you will be asked to accept the authentication key fingerprint:
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana
● When you have successfully logged in, you should see:
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana
Part 3 – Setting up Webmin on the Linux Server
● As the Linux server does not a graphical user interface, having a web-based control dashboard to help set up the
services on the server make it much easier to manage.
● We will install Webmin, a popular web-based control dashboard on this server.
● Issue the following command in terminal session to import the Webmin repository key:
wget http://www.webmin.com/jcameron-key.asc
● You will also add the Webmin repository into the /etc/apt/sources.list file. In this way, you will be able to install
Webmin. Issue the following 3 commands in Terminal to do this:
o sudo bash
o echo "deb http://download.webmin.com/download/repository sarge contrib" >> /etc/apt/sources.list
o exit
● Next, issue the following command in Terminal to update the repository index with that of the newly added
Webmin repository:
● The system might prompt you for confirmation by providing you with a y/n option. Hit y to continue the
installation process. Once installation is complete, you will see a message explaining how to access Webmin.
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana
Part 4 – Configuring network firewall settings to allow access to the Webmin control
panel
● In the web browser, switch back to the Overview panel for the virtual machine. You can find the VM under All
Resources.
● In the Settings section, select the Networking item.
● You should see the NSG rules for the subnet in the top section and the NSG rules for the network interface in the
bottom section of the same tab. In the bottom section, for the NSG rules for the network interface, select Add
inbound port rule.
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana
● Then add the following rule:
● You should then end up with these rules for your VM:
● Use your web browser and then go to the URL: https:// 35.86.108.54:10000. Substitute 35.86.108.54 with your
Linux server’s Public IP address. Also please note it’s https, not http.
● The web browser may complain about the website's security certificate:
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana
● Click on "Continue to this webpage (not recommended)."
● Login to Webmin with your Linux username and password.
● You should see a page similar to the following:
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana
Part 5 – Installing Apache web server
● The Apache web server is currently the most popular web server in the world, which makes it a great default
choice for hosting a website. Type this in your Windows Command window:
● Verify if apache was installed as planned by visiting your server's IP address in your web browser, for example
http://35.204.55.123 (it’s http this time, not https)
● You will see the default Apache web page, which is there for informational and testing purposes. It should look
something like this:
● Go back to Webmin. On the left hand side of Webmin, click on Servers. Apache server should figure on the list. If
not click on “Refresh Modules” at the bottom of the list to refresh these modules. Then reload webmin. Click on
Apache Webserver. You will see the following screen:
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana
Part 6 – Installing MySQL Database Server
● Now that you have a web server up and running, you need to install the database system to be able to store and
manage data for your site. MySQL is a popular database management system used within PHP environments.
● Again, use apt to acquire and install this software:
sudo mysql
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana
Part 7 – Installing PHP
● PHP is the component of our setup that will process code to display dynamic content. It can run scripts, connect
to our MySQL databases to get information, and hand the processed content over to our web server to display:
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana
Part 8 - Manipulating files on the Linux Server via Webmin
● In Webmin, click Tools and then File Manager.
● Navigate the File Manager by double-clicking the folders, to the directory "/var/www/html".
● Click on the "File” and Create new file. Name the file testpage.html
● Right click the testpage.html file you have just created, and select Edit
● Select the testpage.html file that you have just created, click on “Tools” then “Change permissions”. Change the
permissions to 0755.
● Now verify that your new website is working. Start a web browser and go to:
http://40.71.183.26/testpage.html
2) Using Webmin’s File Manager, create a file in the “/var/www/html” directory, called “info.php”.
5) Now with your web browser, go to http://35.204.55.123//info.php . Make sure you use your own server’s IP
address! You show see your version of the following page:
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana
Part 10 - Setting up the MySQL Database Server
1) On the left hand side of Webmin, under Servers and then click on “MySQL Database Server”.
2) Then in the right hand pane, click “Start MySQL Server” if it’s not running.
3) When the MySQL Database Server has started, you should see the right hand pane of Webmin change to
display “MySQL Databases” containing the “information_schema”, ”mysql” and ”performance_schema”
databases , as well as the “Global Options”.
4) Click on the “mysql” database and Webmin will display the database tables within the “mysql” database.
5) Then click “Return to database list” to return to the previous screen.
1) On the left hand side of Webmin, under Servers and then click on “MySQL Database Server”.
2) Click “Create a new database”
3) Give your new database the name of your student ID prefixed with the letters “db”. Thus if your student ID is
1234567, creating a new database with the name of “db1234567”. Make sure you use your student ID.
Name the initial table “Contacts” and populate it with the information shown below
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana
Part 11 - Entering data into the Contacts table
1) Go on “MySQL Database Server” and install the missing PERL modules as shown below (at the bottom)
4) Enter the following SQL statement into the box and then click the "Execute" button. Make sure you get the
spaces, commas, and single-quotes correct:
INSERT INTO Contacts VALUES ('Firstname Surname', 'Your address', 'Yourphone number',
'email@wlv.ac.uk');
7) You should see the data that you have just entered into the "Contacts" table.
8) Repeat the procedure to create 4 more different contacts, using different values, and then capture the
screen show all the contacts data, and paste it below:
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana
Part 12 - Connecting Apache/PHP to MySQL
● Create a new database user called "phpuser" with a password of "Password123!", set the Hosts to
"localhost", and select all the permissions:
● Click "Create".
● Click on “Database Permissions”, and then click on “Create new database permissions”
● Select the Database of “db1234567” (make sure you select your own database), and set the rest of the
details as shown below:
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana
● Click "Create".
● Enter the following code into the PHP file. Make sure you use your own database name:
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana
Find the code in the drive.
● Make sure you don't get the curly brackets {} mixed up with the round ones ()!
● Save the file and then set its permissions to 0755 and both ownership fields to “phpuser”
● Now with your web browser, go to http://35.204.55.123/contacts.php . Make sure you use your own
server’s IP address! You show see your version of the following page:
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana
This is the end of this workshop.
Note: Significant parts of this document were sourced from Dr Consolee Mbarushimana