Report writing for fundamental of computing (week 12 and 13)
On 12th and 13th week week we worked on practical 10 which was about configuring web(apache) and FTP servers.
Practical 10
We will configure the Web server and FTP server in our system(Ubuntu 20.04LTS). We will
make use of the virtual machine. You can get help related to ftp command with the command
<man ftp>.
Note: If you get permission issues while doing the practical. Please use the concept of previous
practicals and solve it.
Configuring Apache Web Server
What is an Apache web server?
- An Apache web server is a software program that runs on a computer and makeswebsites accessible on the internet. It receives requests from web browsers (likeChrome or Firefox) and sends back the web pages and other files that make up awebsite.
Which port number is used by the Apache webserver by default?
- The default port number used by the Apache web server is port 80 ( secure port forcommunicating with world for Apache is 443.)
1. Install the Apache webserver with the command <sudo apt install apache2>
2. Once the installation is done, use the command <sudo systemctl status apache2> to
check the server's status. You should see the output similar to the picture below.
Note: If you get the status inactive, use the following command to activate it.
1. <sudo systemctl start apache2>2. <sudo systemctl status apache2> [ Now you should be able to see the statusas active]3. <sudo systemctl enable apache2 > [This will make sure when your system
boots, it will automatically start the apache2]
3. Open the web browser, and access the following URL:
a. http://localhostb. http://127.0.0.1
You should be able to see the output similar to the picture below.
4. Your web server code resides in the location /var/www/html directory. Paste the
screenshot of the content inside the html directory.
5. Inside it, you can upload your website code base. The starting point of the website
should be an index.html file. Since the default index.html file already exists, you can
delete it can create your own file or if you want to keep it, then rename it to something
else.[Optional]
6. Now create an index.html file, it should have the following things inside it:
a. Title: <Module Code of Fundamental of Computing>b. Body: It should have your name, registration number, and your picture.
Paste the screenshot of your website below.
Note: In case you get the file permission issues, then use the concept of Practical 09 to solve
it.
Virtual Host Configuration
What is a virtual host in an Apache web server? Explain in detail.
- Apache web server is a virtual host which is a configuration that allows a single physicalserver to host multiple websites or web applications. Each virtual host has its ownseparate configuration and settings, enabling it to serve web content independently. Thisis a powerful feature that enables shared hosting, hosting multiple websites on a singleserver, and efficiently managing various web projects
We will create two websites using the same Apache web server.
1. Create two folders called “teach“ and “learn” inside the /var/www/ folder.
2. See the group name and user name of both folders, in case if the user and group areroot then change it back to your username. You can use the command <sudo chownuser_name:group_name learn>. Replace the user_name and group_name with youruser_name. In case you are not sure what is your user_name, you can use thecommand <whoami>. Similarly, change the group and user name for folder teach.3. Now inside both folders, create an index.html file. Write a few HTML codes inside it. Youcan make use of your Front End Web Development module concept. Make sure thecontent inside each index.html file is different.4. Navigate inside the folder /etc/apache2/sites-available/. Inside it, you will find a defaultconfiguration file called 000-default.conf. For our virtual host, we will create a similar
configuration file. For that, we will create learn.conf and teach.conf files. Since the
configuration will be similar, we will just copy the content of the default file.
a. <sudo cp 000-default.conf learn.conf>b. <sudo cp 000-default.conf teach.conf>
5. Now open both files in your choice of code editor. We will modify it with the following
content.
6. Now let’s disable the default configuration file with the command <sudo a2dissite 000-default.conf> and let’s enable our new configuration file with the following commands
a. <sudo a2ensite learn.conf>b. <sudo a2ensite teach.conf>
7. Now finally restart the Apache web server with the command <sudo systemctl restartapache2>.8. Finally in order to access the website by the name, let's configure the /etc/hosts file. Ihope you remember the purpose of this file. Open the /etc/hosts file, enter these twolines of instructions in it, and save it.9. Now you will be able to access the website with the following URL:
a. http://www.learn.localb. http://www.teach.local
10. Take the screenshot of both websites and paste it below.LearnTeach
11. Explain what the following attributes represent in the above configuration file:
a. ServerNameb. ServerAdminc. DocumentRootd. ErrorLoge. CustomLog
FTP Server Configuration
What is the FTP server? Give an example of an FTP server.
- FTP servers are the software solutions used for transferring files across the internet.They are primarily used for two essential functions, “Put” and “Get.” It allows uploading(Put) files to the server from the client device and downloading (Get) files from the serveron the client device- An example of FTP server could be FileZilla Server.
What is the default port number that your FTP server uses?- By default the port number used by FTP server is TCP port 21.
We will set up the vsftpd FTP server in our system.
1. You can install it with the command <sudo apt install vsftpd>.2. Check whether the FTP server is running or not. The service name is called vsftpd.Paste the screenshot below.
3. The configuration file related to the server can be accessed from “/etc/vsftpd.conf”.Open the file and observe the content in it. Also, the location for the FTP server iscreated at “/srv/ftp” which is empty. You can check it.4. By default, the user in your system can log in to the FTP server using the command <ftp127.0.0.1>. Provide the username and password. You should be then inside the FTPserver. You should see the output similar to the picture given below.Paste the screenshot of your login. Also, what is the directory name you are providedwith when you log in? Use the relevant command that you have learned in Linux todisplay the directory name.
- /home/karmatenzin
5. You can use most of the commands that you have learned in Linux. Try out some andsee whether it is working or not.6. Go inside the directory “/srv/ftp/” and create a file called ftp.txt as a normal user(i.e.,you don’t have to log in as an ftp user). Basically, you can keep any kind of files. For thedemonstration purpose, we are using the ftp.txt file. Write some dummy text inside it. Sothat when we download it we can verify that we have downloaded the right file.7. Now log in as the FTP user from your home directory using the Step 3 command. Afterthat navigate to the directory “/srv/ftp/”. Now you can download that file with thecommand <get ftp.txt>. Paste the screenshot of the command output.8. Now log out from the FTP server with the command <bye> or <exit>. You should beable to see the file ftp.txt in your home directory. You can check with the command<ls>. You can see the content of the ftp.txt file using the command <cat> to make surethat is the correct file.9. By default, you won’t be able to upload files to the ftp server. So to upload the file, let’schange the configuration file called “/etc/vsftpd.conf>.10. Open it using your choice of editor, then search for the line #write_enable=YES.Uncomment the line by deleting the #(hash) symbol. Then save the file. In case youencounter the permission issue resolve it [Practical 09].11. Now restart the FTP server. You can use the command < sudo systemctl restartvsftpd>. Check the status of the server. Just to make sure that the changes have notbroken/crashed the server. It should be active and running without any errors.12. In your home directory, create another file called ftpUpload.txt and write some dummytext in it. Now we will try to upload this file to the FTP server.13. Log in to the FTP server, then navigate to the directory “/srv/ftp/”. We will upload it tothis directory. Now to upload the file, use the command <put/home/sumukus/ftpUpload.txt backup_ftpUpload.txt>. Right after the put command, it isthe absolute path to the file. In your case, replace that with your file path. Then next isthe file name of the FTP server. In case you get the permission issue, resolve it. [Hint:Set the file permission for directory “/srv/ftp”. Paste the screenshot of the put command
below. You can check the file in the FTP server with the command <ls>. A file calledbackup_ftpUload.txt should be there.
14. If you notice, when the default user login to the FTP server, it has the present workingdirectory as its home directory. But I want the FTP user to be in the location “/srv/ftp”as its working directory. So to do that let’s create the FTP user with the working directoryat “/srv/ftp”. We will create a user called ftp1 with its working directory at “/srv/ftp/”.You can use the command <sudo adduser --home srv/ftp ftp1>. Also, set thepassword for the user ftp1. You will need it when you log in to the FTP server using thisuser.
15. Now login as the user ftp1 in the FTP server. Then run the command <pwd>. Youshould see the output as “/srv/ftp/”. Paste the screenshot below.16. Now let’s try to access the FTP server from our host operating system. Open the CMDand log in to the FTP server using the command <ftp ip_address_of_ftp_server>.Replace the ip_address_of_ftp_server with your FTP server IP address. You shouldbe able to access it.
17. Let’s take the FTP server public to the local private network your laptop is connected to.For this, in the Virtual Machine change the connection type to “Host Only”. Check thenetwork information of the virtual machine. It should be the same as that of your hostmachine network. Paste the screenshot of both the virtual machine and the hostmachine network information. Finally, you can ask your friend to access your FTP serverfrom his/her laptop. Provide him the IP address of your FTP server, username, andpassword. They should be able to access it.So far what are the commands that you have used in this practical? List all. Just the command,not the entire command usage.- sudo apt install apache2- sudo systemctl status apache2- sudo mv index.html old_index.html- sudo service apache2 restart- sudo nano index.html- cp /home/karmatenzin/Downloads/my_image.jpg ./- cd /var/www/- whoami- cd learn- cd teach- sudo cp 000-default.conf learn.conf- sudo cp 000-default.conf teach.conf- cd learn.conf- cd teach.conf- sudo nano learn.conf- sudo nano teach.conf- sudo a2dissite 000-default.conf- sudo a2ensite learn.conf- sudo a2ensite teach.conf- sudo systemctl restart apache2- sudo nano /etc/hosts- sudo apt install vsftpd- sudo systemctl status vsftpd- ftp 127.0.0.1- cd /srv/ftp/- sudo nano ftp.txt- sudo nano /etc/vsftpd.conf- sudo systemctl restart vsdtpd- sudo nano ftpUpload.txt- sudo chmod 777 /srv/ftp- sudo adduser --home /srv/ftp ftp1- ip addressFOC Practical 10Page 17 of 17- pwd- put /home/sumukus/ftpUpload.txt backup_ftpUpload.txt<End of the Practical. All the Best of Luck for the Practical Exam and Prepare Well>
Comments
Post a Comment