This document provides a comprehensive guide on configuring various servers, including Apache, Samba, CUPS, Squid Proxy, and NFS on Linux systems. It outlines installation steps, configuration details, and firewall settings necessary for each service. The document serves as a practical reference for setting up and managing these server applications effectively.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
3 views62 pages
Unit 3 Oss
This document provides a comprehensive guide on configuring various servers, including Apache, Samba, CUPS, Squid Proxy, and NFS on Linux systems. It outlines installation steps, configuration details, and firewall settings necessary for each service. The document serves as a practical reference for setting up and managing these server applications effectively.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 62
UNIT 3 CONFIGURING SERVERS
Installing Apache: The Web Server
Samba Installation and Configuration: File Sharing -Compiling from Sources Installing - NFS (network file system) Installing Common Unix printing System Installing and Configuring Squid Proxy Installing and configuring Git Version Control System Installing Apache: The Web Server What is Apache? • Apache is an open-source web server software developed by the Apache Software Foundation. It is designed to serve web content over the Internet . • Virtual Hosting: • Apache supports virtual hosting, allowing multiple websites to be hosted on a single server. This is useful for web hosting providers and businesses that need to manage multiple domains efficiently. Installing Apache: The Web Server Installing Apache: The Web Server How Apache Web Server is Installed and Configured ? Also explain how to Configure new web hosting in Apache? • Installing and Configuring Apache Web Server on Linux • Apache is one of the most widely used web servers in the world. Here's how to install and configure it on a Linux-based system such as Ubuntu or Debian. Step 1: Update the server's package index. sudo apt update Step 2: Install the Apache web server package. Once the package repository is updated, you can install Apache using the following command: sudo apt install apache2 • This will download and install Apache and any necessary dependencies. Installing Apache: The Web Server Step 3: Start and Enable Apache After installation, start the Apache service and enable it to start on boot. sudo systemctl start apache2 sudo systemctl enable apache2 You can verify that Apache is running by checking its status: sudo systemctl status apache2 Step 4: Adjust Firewall Settings (if needed) If your system has a firewall enabled, you may need to allow HTTP and HTTPS traffic. sudo ufw app list sudo ufw allow 'Apache' To verify, run:sudo ufw status Installing Apache: The Web Server • Access your public server IP using a web browser such as Chrome and verify that the default Apache web page displays. http://SERVER-IP Installing Apache: The Web Server (virtual Host) • Step 1: Create the Document Root • Each website requires a document root where the website's files are stored. sudo mkdir -p /var/www/yourdomain.com/public_html • Set proper permissions to the directory: • sudo chown -R $USER:$USER /var/www/yourdomain.com/public_html • sudo chmod -R 755 /var/www/yourdomain.com • Step 2: Create an Index Page • Create a simple HTML file to test if the new host works. • sudo nano /var/www/yourdomain.com/public_html/index.html • Add the following content for testing: <html> • <head> • <title>Welcome to YourDomain!</title> • </head> • <body> • <h1>Success! Your new virtual host is working!</h1> • </body> • </html> Save and exit the file. • Step 3: Create a New Virtual Host File • Create a new virtual host file under /etc/apache2/sites-available/. • sudo nano /etc/apache2/sites-available/yourdomain.com.conf • Add the following configuration: • <VirtualHost *:80> • ServerAdmin webmaster@yourdomain.com • ServerName yourdomain.com • ServerAlias www.yourdomain.com • DocumentRoot /var/www/yourdomain.com/public_html • ErrorLog ${APACHE_LOG_DIR}/error.log • CustomLog ${APACHE_LOG_DIR}/access.log combined • </VirtualHost> • Make sure to replace yourdomain.com with your actual domain name. Step 4: Enable the Virtual Host • Enable the new virtual host using the following command: • sudo a2ensite yourdomain.com.conf • Then, reload Apache to apply the changes: • sudo systemctl reload apache2 • Step 5: Test the Configuration • To check if your configuration is correct, run: • sudo apache2ctl configtest • If the test is successful, you should see an output like Syntax OK. samba Installation • samba is a server used to communicate between windows and linux • it has two protocols • 1.server message block(smb) • 2.netBIOS message block(nmb) • the port numbers for samba are • 137,138 - UDP port • 139 ,445 - TCP port how to install and configure samba • Step server 1 :Update your system: • Before installing any new packages, update your system's package list. sudo apt update Install Samba: step2 :Install the Samba server package using the apt command. sudo apt install samba -y Check Samba installation: After installation, check if Samba is installed correctly by checking its version: smbd --version check the status of server:systemctl status smd how to install and configure samba server step 3 :Configure Samba: Create a Directory to Share: Create a directory that you want to share via Samba. sudo mkdir -p /srv/samba/shared step 4:Set appropriate permissions on this directory. For public access: sudo chmod 777 /srv/samba/shared create user : useradd user1 user add user2 and set a password smbpasswd -a user1 smbpasswd -auser2 how to install and configure samba server Edit the Samba configuration file: path: Directory to share. browsable: Makes the share visible when browsing the network. writable: Allows users to write files. read only: Set to no so the share is writable. guest ok: Allows guests (no authentication) to access the share. how to install and configure samba server • step 5 :Edit the Samba configuration file: • Open the Samba configuration file for editing: sudo nano /etc/samba/smb.conf • Add the following at the bottom of the file to create a simple shared folder: [shared] path = /srv/samba/shared valid users = user1,user2 browsable = yes writable = yes read only = no guest ok = yes how to install and configure samba server • step 6: Restart the Samba service: • After editing the configuration, restart the Samba services for the changes to take effect: sudo systemctl restart smbd how to install and configure samba •server Allow Samba through the firewall: • If you are using a firewall (like ufw), allow Samba traffic: sudo ufw allow 'Samba’ Verify Samba Status: Check if Samba is running properly: sudo systemctl status smbd sudo systemctl status nmbd Access the Samba Share: From a Windows or another Linux machine, you can access the share using the server's IP address or hostname. Windows: Open File Explorer and enter \\server-ip\shared. Linux: Use the file manager and enter smb://server-ip/shared in the address Installing Common Unix printing System • Step 1: Install CUPS • Update your package list: • sudo apt update • Install the CUPS package: • sudo apt install cups -y • Start and enable the CUPS service: • sudo systemctl start cups • sudo systemctl enable cups • Check the status of CUPS: Ensure CUPS is running by checking its status: • sudo systemctl status cups Installing Common Unix printing System • Step 2: Configure CUPS • Allow access to the CUPS web interface: By default, the CUPS web interface is restricted to localhost. To allow access from other systems on your network, you’ll need to edit the CUPS configuration file. • Open the CUPS configuration file: • sudo nano /etc/cups/cupsd.conf • Edit the Listen and Allow directives: Find and modify the following lines to allow access from any machine on your local network: • Listen 192.168.1.10:631 • Replace 192.168.1.10 with the IP address of your machine or use Listen 0.0.0.0:631 to allow access on all interfaces. • Also, modify the Location sections to allow access from your network (e.g., 192.168.1.0/24): Installing Common Unix printing System • <Location /> • Order allow,deny • Allow from 192.168.1.0/24 • </Location> • <Location /admin> • Order allow,deny • Allow from 192.168.1.0/24 </Location> Save and close the file (Ctrl+O, Ctrl+X). • Restart the CUPS service to apply the changes: • sudo systemctl restart cups Installing Common Unix printing System • Step 3: Configure Firewall (Optional) • If you are using a firewall (e.g., ufw), you will need to allow traffic on port 631 (CUPS port). • Allow CUPS through the firewall: • sudo ufw allow 631/tcp • Reload the firewall to apply the changes: • sudo ufw reload Installing Common Unix printing System • Step 4: Access the CUPS Web Interface • Open a web browser and navigate to the CUPS web interface. Use the following URL: http://localhost:631 • If you configured CUPS for network access, you can use the IP address of the server: • http://<server-ip>:631 • Manage CUPS: • From the web interface, you can manage printers, configure print jobs, and control access to your printers. Installing Common Unix printing System • Step 5: Add Printers • You can add printers through the CUPS web interface or via the command line. • From the CUPS web interface:Navigate to the Administration tab. • Click Add Printer and follow the prompts to add your printer. • You may need to enter the root or administrator credentials to add printers. • Using the command line: You can use lpadmin to add printers via the terminal. For example: • sudo lpadmin -p Printer_Name -E -v ipp://printer_address/ipp/print -m everywhere • Replace Printer_Name with the name of your printer and printer_address with the IP address of the printer. Installing Common Unix printing System • Step 6: Test the Printer • Once your printer is installed, you can test it by printing a test page: • From the CUPS web interface: • Go to the Printers tab. • Select the printer you’ve added. • Choose Print Test Page from the Maintenance drop-down. • Using the command line: You can use the lp command to print a file. For example: • lp /path/to/testfile.txt Installing Common Unix printing System • Step 7: Manage Print Jobs • You can manage print jobs from the CUPS web interface under the Jobs section or use the following command to list jobs: • lpstat -o • To cancel a print job: • cancel <job-id> • Step 8: Auto-detect Network Printers (Optional) • CUPS can auto-detect network printers that support the Internet Printing Protocol (IPP). • Install printer drivers: • sudo apt install printer-driver-all • Restart CUPS and auto-detection will typically add available network printers. • How to Install Print Server in Ubuntu and Share On The Network CUPS • YouTube • root tech • 39.7K views • Aug 26, 2020 Installing and Configuring Squid Proxy • Narrate how Squid proxy is installed and configured Step 1 :Install Squid Proxy:Update the system's package index: sudo apt update Install Squid using the package manage sudo apt install squid -y Once installed, Squid will start automatically. You can check the status with: sudo systemctl status squid step 2. Basic Squid Configuration: Squid's main configuration file is located at /etc/squid/squid.conf. To modify Squid's behavior, you need to edit this file. sudo nano /etc/squid/squid.conf Narrate how Squid proxy is installed and configured • 3. Setting Up Access Control Lists (ACLs): • ACLs in Squid are used to control who can access the proxy server and what resources are available. Here’s how you can configure some basic ACLs: • Insert in your own rule(s) Here allow access From your client. • acl localnet src 192.168.7.237 • acl blocksite dstdomain “/etc/squid/blocksite” • http_access deny blocksite • http_acess allow localnet • and finally deny all • https - access allow all • http port 3128 (checking the port) Narrate how Squid proxy is installed and configured • sudo nano /etc/squid/blocksite • open the editor • www.facebook.com • save and quit • restart squid • systemctl restart squid • then goto browser • go to preferences • search proxy go to setting select manual proxy config http proxy 192.168.7.237 port 3128 also use this proxy ftp, http and select ok Narrate how Squid proxy is installed and configured • select you tube,com its working • check facebook its not working Write ACL to configure the following in SQUID proxy • Write ACL to configure the following in SQUID proxy (7) - AP • Configure a acl/http_access directives that will allow times of usage of the Internet to lunchtime and after 5pm. • Configure an acl/http_access directive to allow users on the 172.16.43 network, but deny particular hosts 172.16.43.149 and 153 • Configure an acl/http_access directive to disallow users with the MAC addresses 00:10:11:96:A1:C3, C5 and 96:EF:15 Write ACL to configure the following • in SQUID proxy Time-based ACLs for internet usage • acl lunchtime time MTWHF 12:00-14:00 • acl afterhours time MTWHF 17:00-23:59
• # Network-based ACL for the 172.16.43.0/24 network and denied hosts
• acl allowed_network src 172.16.43.0/24 • acl denied_hosts src 172.16.43.149 172.16.43.153 • # MAC-based ACL for blocked MAC addresses • acl blocked_macs arp 00:10:11:96:A1:C3 00:10:11:96:A1:C5 00:10:11:96:EF:15 Write ACL to configure the following in SQUID proxy • # HTTP access rules • http_access allow lunchtime • http_access allow afterhours • http_access deny denied_hosts • http_access allow allowed_network • http_access deny blocked_macs • http_access deny all Install NFS (Network FILe SYStem) [Ubuntu 22.04] How to Install and Configure NFS Server? 💻 🔥 YouTube vCloudBitsBytes Install NFS (Network FILe SYStem) Step 1. Install NFS Server on Ubuntu 24 • Update the package list: sudo apt update step 2: Install the NFS server package: Configure NFS Server Create a directory to be shared (or use an existing one): 1.sudo mkdir -p /mnt/nfs_share Set the appropriate permissions for the directory: 2.sudo chown nobody:nogroup /mnt/nfs_share/ (chown change ownership) 3.sudo chmod 777 /mnt/nfs_share/ Install NFS (Network FILe SYStem) Step 3: Configure NFS Exports Edit the NFS configuration file (/etc/exports) to specify which directories to share and the permissions for each. For example, to allow a client (e.g., IP 192.168.1.0/24) to access the shared folder: sudo nano /etc/exports Add the following line: /mnt/nfs_share 192.168.1.0/24(rw,sync,no_subtree_check) rw: Grants read/write permissions. sync: Ensures changes are written to disk before the client is notified. no_subtree_check: Prevents subtree checking, which can improve reliability. Save and close the file. Install NFS (Network FILe SYStem) • Step 4: Apply NFS Export Changes • Update the NFS server with the new export settings: sudo exportfs -a Step 5: Start and Enable the NFS Server Start and enable the nfs-kernel-server service to run on boot: sudo systemctl start nfs-kernel-server sudo systemctl enable nfs-kernel-server step 6: Configure Firewall (Optional) If you have a firewall enabled, allow NFS traffic: sudo ufw allow from 192.168.1.0/24 to any port nfs sudo ufw enable sudo ufw status Install NFS (Network FILe SYStem) • Mount the NFS Share on a Client • step 1: • Install the NFS client package: • sudo apt install nfs-common -y • step 2 Create a mount point for the NFS share: sudo mkdir -p /mnt/nfs_client_share step 3 :Mount the NFS share: sudo mount 192.168.1.100:/srv/nfs_share /mnt/nfs_client_share (Replace 192.168.1.100 with the IP address of your NFS server.) Install NFS (Network FILe SYStem) • IN server side type : cd /mnt/nfs_share/ • and then create file using • touch file1.txt file2.txt file3.txt • In client side type ls -l /mnt/nfs_client_share/
then the file1.txt and file2.txt file 3.txt displayed..
Installing and configuring Git Version Control System • Install Git in Ubuntu 20.04 LTS, 22.04 LTS (Linux) and Push/Publish your work in Github • YouTube • Code With Arjun Installing and configuring Git Version Control System Before configuring GitHub, you need to install Git, which is the version control system that GitHub is based on. Step 1: Update the Package Index sudo apt update • This ensures your package list is up to date. • Step 2: Install Git sudo apt install git • Once installed, verify the installation: git --version • This should return the installed Git version. Installing and configuring Git Version Control System • Configuring Git • Before using Git, configure your identity so that commits can be associated with your name and email address. • Step 1: Set Your Username • Replace "Your Name" with your actual name: • git config --global user.name "Your Name" • Step 2: Set Your Email • Replace "your_email@example.com" with your actual email: • git config --global user.email "your_email@example.com" • Step 3: Verify Git Configuration • Check your configuration to verify that the settings were applied: • git config --list Installing and configuring Git Version Control System • Creating a GitHub Account • If you don't have a GitHub account, you need to create one: • Go to GitHub's sign-up page. • Follow the instructions to create your account. Installing and configuring Git Version Control System • Pushing Changes to GitHub • Once you've cloned a repository, you can make changes and push them to GitHub. • Step 1: Navigate to Your Repository • cd repository • Step 2: Make Changes and Stage Them • Make changes to files, then stage them for commit: • git add . • Step 3: Commit the Changes • git commit -m "Your commit message" Installing and configuring Git Version Control System step 4: Push the Changes to GitHub • git push -u origin master • Replace main with the branch name if it's different. Installing and configuring Git Version Control System • write the Git command for the following : (7) • To check which version of Git (if any) is installed. • Initialize Git on the current folder: • Stage all new, modified, and deleted files. • Commit the changes to the current repository with the message "First release!" • Commit the updated files directly, skipping the staging environment • View the history of commits for the repository. write the Git command for the following 1. Check which version :of Git (if any) is installed • This command checks whether Git is installed on your system and shows the installed version. git --version • Steps: Open a terminal (in Ubuntu, you can press Ctrl+Alt+T). • Type the command above and press Enter. • If Git is installed, you’ll see the version number (e.g., git version 2.25.1). If it’s not installed, the terminal will tell you. write the Git command for the following : • 2. Initialize Git on the current folder • This command initializes a new Git repository in the current folder. This means Git will start tracking changes in this directory. git init • Steps: • Navigate to the folder where you want to initialize Git. • Open the terminal in this folder (right-click inside the folder and select “Open Terminal”). • Type git init and press Enter. write the Git command for the following 3. Stage : deleted files all new, modified, and • This command stages all the files in your directory, including any newly added files, modified files, or files that have been deleted. Staging means preparing them to be committed to the repository. git add . • Steps: • Make changes to your files in the folder. • Run the command git add . to stage all the changes. • The . (dot) signifies that Git should stage all files from the current directory. write the Git command for the following • 4. Commit the changes to :the current repository with the message "First release!" • This command commits all the staged files and adds a commit message. The commit message helps describe what changes were made. git commit -m "First release!" • Steps: • After staging the files (git add .), run the git commit command. • The -m flag is used to include a commit message in quotes. This describes the changes in the commit (in this case, "First release!"). write the Git command for the following : 5. Commit the updated files directly, skipping the staging environment • This command skips the usual git add step and directly commits changes to files that are already being tracked by Git. It will commit only the changes made to tracked files (not new or deleted files). • git commit -a -m "Commit message" • Steps: • This will automatically add all modified files and commit them, skipping the staging phase. write the Git command for the following : 6. View the history of commits for the repository • This command shows the history of all commits made to the repository. Each commit will have a unique hash, the author's name, the date, and the commit message. git log • Steps: Open the terminal in your repository’s directory. • Run the git log command. • You will see a list of all the commits made, starting with the most recent. Each commit will include: git commands home work • Create a new branch called hello-world-images • List the existing branches • Move to the hello-world-images branch • Create, and move to a new branch with the name hello-you • Merge the hello-you branch with the current branch • Remove the hello-you branch from the local repository The -Wall option in GCC (GNU Compiler Collection) The -Wall option in GCC (GNU Compiler Collection) enables a comprehensive set of warnings that help programmers detect potential issues in their code. While these warnings may not prevent the code from compiling, they often indicate areas that could cause bugs, undefined behavior, or non-optimal code execution. Understanding the warnings enabled by -Wall helps developers write better and more reliable code. The -Wall option in GCC (GNU Compiler Here are the mainCollection) warnings enabled by the -Wall option: 1. Uninitialized Variables: -Wuninitialized This warning is triggered when a variable is used without being initialized. Using uninitialized variables can lead to undefined behavior, and this warning helps catch such issues. Example: • int x; • printf("%d\n", x); // Warning: 'x' is used uninitialized. • Enable all warnings set through -Wall option • $ gcc -Wall main.c -o main • This option enables all the warnings in GCC. The -Wall option in GCC (GNU Compiler Convert Collection) warnings into errors with -Werror option Through this option, any warning that gcc could report gets converted into error. Here is an example : #include<stdio.h> int main(void) { char c; // Print the string printf("\n The Geek Stuff [%d]\n", c); return 0; } The compilation of above code should generate warning related to undefined variable c and this should get converted into error by using -Werror option. $ gcc -Wall -Werror main.c -o main The -Wall option in GCC (GNU Compiler Collection) 1.Produce only the preprocessor output with -E option • The output of preprocessing stage can be produced using the -E option. • $ gcc -E main.c > main.i • The gcc command produces the output on stdout so you can redirect the output in any file. In our case(above), the file main.i would contain the preprocessed output. 2.Produce only the assembly code using -S option • The assembly level output can be produced using the -S option. • gcc -S main.c > main.s • In this case, the file main.s would contain the assembly output. The -Wall option in GCC (GNU Compiler Collection) 3.Produce only the compiled code using the -C option • To produce only the compiled code (without any linking), use the -C option. • gcc -C main.c • The command above would produce a file main.o that would contain machine level code or the compiled code. Linking External Libraries in GCC • External libraries are collections of precompiled code that you can link to your program. There are two main types of libraries you can link in GCC: 1.Static Libraries 2.Shared Libraries Shared Libraries (Dynamic Libraries) These libraries are loaded into memory at runtime, and multiple programs can share a single copy of the library in memory. Shared libraries typically have the file extension .so (Shared Object). Advantages: Smaller binary size (since the library isn't included in the program itself). Easier updates: you can update the library without recompiling the application. Efficient memory usage: the same shared library can be loaded into memory by multiple programs. Linking External Libraries in GCC • Example of Shared Libraries: • libm.so: Math library (contains functions like sin, cos, sqrt, etc.). • libpthread.so: POSIX thread library for multi-threaded applications. • libssl.so: Secure Sockets Layer library for secure communication. • libX11.so: X Window System client library. • Static Libraries • These libraries are linked to the program at compile time, and their code becomes part of the executable. • Static libraries typically have the file extension .a (Archive). • Advantages: • No runtime dependency on external library files. • Useful in embedded systems where you want all dependencies bundled together. Linking External Libraries in GCC Command to Link Static Libraries: • gcc source.o -L/path/to/library -lmylib -o myprogram • -L/path/to/library: Specifies the directory where the static library is located. • -lmylib: Links the static library libmylib.a. • The -l option tells GCC to link the library without the lib prefix and .a extension. • Example: • gcc main.o -L/usr/local/lib -lfoo -o myprogram • This command links the program with the static library libfoo.a located in /usr/local/lib. Linking External Libraries in GCC Command to Link Shared Libraries: gcc source.o -L/path/to/library -lmylib -o myprogram example:gcc main.o -L/usr/local/lib -lfoo -o myprogram
This command links the program with the shared library libfoo.so located in /usr/local/lib and ensures that the library path is included in the final executable.