![]() That's it! You've installed, configured, and tested a very basic web server deployment in just a few steps. For example, type the following to see log entries indicating the file download transactions: $ sudo cat /var/log/httpd/access_log | grep -I download-this.txt Wrap up Check the logsĬheck the Apache log files for access information. You might have two copies of the file if you tested the download using both the curl and wget commands. ![]() $ wget Did you receive the download-this.txt file? Use ls to display the file and cat to read its contents. Run these two commands to confirm file download functionality: $ sudo dnf -y install curl This ability is particularly handy for hands-free downloads in scripts or other automation scenarios. Sysadmins frequently use curl or wget to download files using HTTP. In the address bar, type the web server's IP address.ĭon't forget, you can launch a browser and point it at a site from the terminal: $ firefox Do you see your welcome page? Use a different system on the same segment to test the web service. Look at filesĪssuming that works, do a test download of the download-this.txt file. Your site's homepage is by default index.html, and it's located in /var/file and create a new one containing the following code: Īdditionally, create a new text file called download-this.txt with the following content so that you can test the curl and wget commands later: If you can read this, the download succeeded! You can also create a text file to test downloads from the site. Feel free to make this as simple or complex as you'd like. To make your server a little more interesting, launch your favorite text editor using sudo, and create a few pages to simulate a website. You probably didn't install a web server just to see "It works!" in your browser. Launch Firefox and navigate to localhost:80 to see the Apache web server's default confirmation page. Test the serverįirst, test the server with a browser. You may need to adjust the zone value, depending on your distribution. $ sudo firewall-cmd -list-all -zone=public I'll assume you're using firewalld, so type the following commands to permit HTTP traffic into the server: $ sudo firewall-cmd -permanent -zone=public -add-service=http Now that the site is configured (and in a real-world situation, secured), it's time to open the firewall. To make your web server start automatically after a reboot, use the enable subcommand: $ sudo systemctl enable -now httpd Open port 80 Starting a service doesn't mean it will start automatically from now on. Use the systemctl command to start and enable the httpd service: $ sudo systemctl start httpd You've installed a web server, but you haven't started running it yet. ![]() In this case, use the standard port 80 for HTTP. The Listen directive simply indicates which port the service listens on. This article uses the standard location at /var/www/html. You may need to uncomment the DocumentRoot stanza. Use the search function in your editor to find the appropriate stanzas. These two values may already be set in that file, but confirm them to be sure: DocumentRoot /var/www/html Using your text editor of choice (mine is Vim, but Nano or others work just as well), open /etc/httpd/conf/nf. If your Linux distribution doesn't already include Apache, run the following command to install the package: $ sudo dnf install httpdĪdjust the command accordingly if you use a different package manager. To be production-ready, you must configure firewalls and audit your server settings. It's not suitable for internet-facing web servers. Note that this is a very basic test deployment. I'll begin with installation, then continue with editing a basic configuration file, creating a few documents, setting the firewall, and finally, testing the service. The steps below cover how to do that using the venerable Apache HTTP Server. Old Linux commands and their modern replacements.Linux system administration skills assessment.A guide to installing applications on Linux.Download RHEL 9 at no charge through the Red Hat Developer program.
0 Comments
Leave a Reply. |