Apache Essentials: Install, Configure, Maintain, 2nd Edition by Darren James Harkness Table of Contents About the Author About the Technical Reviewer Acknowledgments Introduction Chapter 1: Getting Started with Apache How Web Servers Work The HyperText Transfer Protocol A (Very) Brief History of Apache Before You Begin… Keep Notes Get Familiar with Your Terminal Be Prepared to Read Documentation What to Know Before Installing Apache Using the Right Development Environment Apache vs. Other Web Servers Choosing Apache Over Nginx Apache over npm start for Node Development Obtaining Apache Installing Apache on macOS Installing Apache Through Homebrew Running Apache as a Service Through Homebrew Installing Apache on Linux Choosing the Source Installation The Benefit of Binary Installation Installing on Windows Installing Apache Through XAMPP Installing Apache as a Service in Windows Basic Configuration Where to Put Your Website Files Configuration Directory Structure httpd.conf/apache2.conf mime.types Configuring a Default Site Summing It Up Chapter 2: Configuration Essentials How Apache’s Configuration Is Structured Where Do I Find Modules? Installing Modules Adding File Types Configuring Modules All About Directives Directive Configuration DocumentRoot /var/www Configuring Your Primary Apache Site Creating the New Directory Updating Your Apache Configuration Updating the Location of Your Website’s Files Directory Options Configuring Your Primary Index File Configuring Logging Using .htaccess Files Other Configuration Options You Should Know Rewriting URLs Using URL Slugs Updating the URL for an Existing Page Fixing a Trailing Slash Creating Custom Error Messages ErrorDocument Syntax Redirecting to External Error Documents Authenticating Users Through Apache Creating a .htpasswd File Basic Configuration Adding New File Types Configuring mime.types Including External Configuration Files Applying Changes Summing It Up Chapter 3: Configuring Virtual Hosts A Quick and Dirty Guide to Domains What Are Virtual Hosts? Creating Development Domains Using the hosts File to Manage Local Domains Using ngrok to Manage Local Domains Setting up a Subdomain Pointing to Your Local Environment Why Develop Locally? Configuring Apache’s Virtual Hosts A Sample Apache Configuration ServerAdmin DocumentRoot ServerName and ServerAlias ErrorLog and CustomLog ScriptAlias Directory Using Separate Configuration Files Putting It All to Work Pointing the Virtual Domains to Your Local Computer Configuring Apache for Multiple Virtual Hosts Summing It Up Chapter 4: Scripting Languages PHP Installing PHP Installing PHP on macOS Installing PHP on Linux Configuring Apache for PHP On macOS On Linux Configuring PHP Updating Default Configuration Increasing the Memory Usage Limit Increasing the Upload File Size Configuring Noisy Error Reporting Increasing Max Execution Time Installing PHP Extensions Recommended php.ini Testing It Out Configuring Node.js on Apache Configuring Your Node.js Application for Apache Installing pm2 Configuring the Application Adding Your Application as a Service Configuring Apache’s Reverse Proxy Enabling Apache’s Proxy Modules On macOS and Windows On Linux Creating a Virtual Host Configuration Testing It Out Configuring React Apps on Apache Summing It Up Chapter 5: Securing Your Setup SSL at a Glance Configuring SSL for Subdomains Installing Certbot On macOS On Linux On Windows Running Certbot Configuring HTTPS for Local Domains Setting up a Local SSL Certificate Authority Installing OpenSSL macOS Linux Windows Storing Your Certificates Generating the CA Private Key Creating a Public CA Certificate Signing Your Own Certificates The sign.sh Script Configuring Apache for HTTPS Creating a Separate Configuration File Loading the SSL Module Configuring the Apache’s SSL Module Configuring the Global Options Configuring the Secure Site in Apache Summing It Up Chapter 6: Log Files Error.log Configuring the Error Log access.log Formatting the Access Log Where Can I Find Apache’s Log Files? Configuring Apache Logs Log Files for Virtual Hosts Rotating Logs Configuring Log Rotation Reading Archived Log Files What Do I Do with Log Files? Using Log Analysis Programs Creating Custom Scripts Apache Configuration Tracking Down 404 Errors and Why They Occur Troubleshooting PHP Writing to the Error Log An Example Summing It Up Chapter 7: Sample Apache Configurations Basic Apache Configuration (with PHP) httpd.conf Basic HTTPS Configuration httpd.conf extra/httpd-ssl.conf Adding Rewrite Rules to Provide Human-Readable URLs .htaccess Setting up Multiple Hosts (One PHP and One Node.js) httpd.conf macOS and Windows Linux portfolio.local.conf nodejs.local.conf Protected Directory httpd.conf macOS and Windows Linux dev.mydomain.com.conf Epilogue Appendix: HTTP Status Codes HTTP Status Codes 1xx Informational Response 2xx Success 3xx Redirection 4xx Client Errors 5xx Server Errors Index