{"id":13217,"date":"2026-04-14T10:34:08","date_gmt":"2026-04-14T05:04:08","guid":{"rendered":"https:\/\/www.youstable.com\/blog\/?p=13217"},"modified":"2026-04-14T10:34:10","modified_gmt":"2026-04-14T05:04:10","slug":"use-apache-on-linux","status":"publish","type":"post","link":"https:\/\/www.youstable.com\/blog\/use-apache-on-linux","title":{"rendered":"How to Use Apache on Linux Server 2026 &#8211; (Beginners Guide)"},"content":{"rendered":"\n<p>How to use Apache on a Linux server: install Apache (apache2\/httpd), allow ports 80\/443 in the firewall, start and enable the service, create VirtualHosts for your domains, deploy site files to the document roots, enable HTTPS with Let\u2019s Encrypt, and tune modules, logging, and performance (MPM, caching, PHP-FPM) for your workload.<\/p>\n\n\n\n<p>Apache on Linux Server is a robust, flexible web server stack used to host websites, APIs, and applications. In this guide, I\u2019ll show you exactly how to install, configure, secure, and optimize Apache on popular Linux distributions, using beginner friendly steps and production proven practices from 12+ years of hosting and server management experience at YouStable.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"what-is-apache-and-why-use-it\">What Is Apache and Why Use It?<\/h2>\n\n\n\n<p>Apache HTTP Server (often just \u201cApache\u201d) is a modular, open source web server known for stability, extensive documentation, and unmatched flexibility through modules like <code>mod_ssl<\/code>, <code>mod_proxy<\/code>, <code>mod_rewrite<\/code>, and MPMs (worker models) that adapt to different workloads. It excels at .htaccess driven sites, legacy PHP apps, and complex rewrite rules.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"720\" src=\"https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2025\/12\/What-Is-Apache-and-Why-Use-It.jpg\" alt=\"Use Apache on Linux\" class=\"wp-image-19895\"\/><\/figure>\n\n\n\n<p>Search intent for this topic is largely \u201chow to install and <a href=\"https:\/\/www.youstable.com\/blog\/how-to-configure-apache-on-linux\/\">configure Apache<\/a>, create virtual hosts, enable HTTPS, and manage performance and security.\u201d We\u2019ll cover all of that with distro specific commands (Ubuntu\/Debian and RHEL\/CentOS\/AlmaLinux\/Rocky).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"prerequisites\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A <a href=\"https:\/\/www.youstable.com\/blog\/install-mongodb-on-linux\/\">Linux server<\/a> (Ubuntu, Debian, CentOS, AlmaLinux, or Rocky Linux)<\/li>\n\n\n\n<li>Root or sudo access<\/li>\n\n\n\n<li>DNS A\/AAAA records pointing your domains to the server\u2019s IP<\/li>\n\n\n\n<li>Port 80 (HTTP) and 443 (HTTPS) accessible<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"install-apache-on-popular-linux-distributions\">Install Apache on Popular Linux Distributions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"ubuntu-debian-apache2\">Ubuntu\/Debian (apache2)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install -y apache2\nsudo systemctl enable --now apache2\n\n# UFW firewall (if enabled)\nsudo ufw allow \"Apache Full\"  # opens 80 and 443\nsudo ufw status<\/code><\/pre>\n\n\n\n<p>Ubuntu enables useful modules by default (e.g., <code>mime<\/code>, <code>status<\/code>). The default web root is <code>\/var\/www\/html<\/code>, and the default site config lives in <code>\/etc\/apache2\/sites-available\/000-default.conf<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"rhel-centos-almalinux-rocky-httpd\">RHEL\/CentOS\/AlmaLinux\/Rocky (httpd)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf install -y httpd\nsudo systemctl enable --now httpd\n\n# Firewalld\nsudo firewall-cmd --add-service=http --add-service=https --permanent\nsudo firewall-cmd --reload\n\n# SELinux: ensure correct contexts for web content\nsudo semanage fcontext -a -t httpd_sys_content_t \"\/var\/www(\/.*)?\"\nsudo restorecon -Rv \/var\/www<\/code><\/pre>\n\n\n\n<p>RHEL-based systems use <code>\/etc\/httpd\/conf\/httpd.conf<\/code> plus additional configs in <code>\/etc\/httpd\/conf.d\/<\/code>. The default web root is <code>\/var\/www\/html<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"verify-apache-is-running\">Verify Apache Is Running<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl status apache2   # Ubuntu\/Debian\nsystemctl status httpd     # RHEL-based\n\n# Test locally\ncurl -I http:\/\/127.0.0.1\n# Expect: HTTP\/1.1 200 OK<\/code><\/pre>\n\n\n\n<p>Open your server\u2019s IP in a browser and you should see the Apache default page. If not, re-check firewall rules and service status.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"manage-the-apache-service-systemd\">Manage the Apache Service (systemd)<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># Start\/stop\/restart\nsudo systemctl start apache2    # or: httpd\nsudo systemctl stop apache2\nsudo systemctl restart apache2\n\n# Graceful reload after config changes\nsudo systemctl reload apache2\n\n# Test configuration syntax\nsudo apachectl configtest       # or: sudo httpd -t<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"create-name-based-virtual-hosts\">Create Name Based Virtual Hosts<\/h2>\n\n\n\n<p>Virtual Hosts let you run multiple websites on one server. Point each domain\u2019s DNS to your server, then create a vhost per site.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"ubuntu-debian-virtualhost-example\">Ubuntu\/Debian VirtualHost Example<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkdir -p \/var\/www\/example.com\/public_html\nsudo chown -R $USER:$USER \/var\/www\/example.com\/public_html\necho \"&lt;h1&gt;Hello from example.com&lt;\/h1&gt;\" | sudo tee \/var\/www\/example.com\/public_html\/index.html\n\nsudo tee \/etc\/apache2\/sites-available\/example.com.conf &gt;\/dev\/null &lt;&lt;'EOF'\n&lt;VirtualHost *:80&gt;\n    ServerName example.com\n    ServerAlias www.example.com\n    DocumentRoot \/var\/www\/example.com\/public_html\n\n    ErrorLog ${APACHE_LOG_DIR}\/example.com-error.log\n    CustomLog ${APACHE_LOG_DIR}\/example.com-access.log combined\n&lt;\/VirtualHost&gt;\nEOF\n\nsudo a2ensite example.com.conf\nsudo a2dissite 000-default.conf\nsudo systemctl reload apache2<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"rhel-centos-almalinux-rocky-virtualhost-example\">RHEL\/CentOS\/AlmaLinux\/Rocky VirtualHost Example<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkdir -p \/var\/www\/example.com\/public_html\nsudo chown -R apache:apache \/var\/www\/example.com\/public_html\necho \"&lt;h1&gt;Hello from example.com&lt;\/h1&gt;\" | sudo tee \/var\/www\/example.com\/public_html\/index.html\n\nsudo tee \/etc\/httpd\/conf.d\/example.com.conf &gt;\/dev\/null &lt;&lt;'EOF'\n&lt;VirtualHost *:80&gt;\n    ServerName example.com\n    ServerAlias www.example.com\n    DocumentRoot \/var\/www\/example.com\/public_html\n\n    ErrorLog logs\/example.com-error.log\n    CustomLog logs\/example.com-access.log combined\n&lt;\/VirtualHost&gt;\nEOF\n\nsudo systemctl reload httpd<\/code><\/pre>\n\n\n\n<p>If SELinux is enforcing, ensure the document root has the correct context and allow Apache to connect to the network if using upstream services:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo restorecon -Rv \/var\/www\nsudo setsebool -P httpd_can_network_connect on<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"enable-https-with-lets-encrypt-certbot\">Enable HTTPS with Let\u2019s Encrypt (Certbot)<\/h2>\n\n\n\n<p>HTTPS is essential for security and SEO. <a href=\"https:\/\/www.youstable.com\/blog\/what-is-lets-encrypt-on-linux-server\/\">Let\u2019s Encrypt<\/a> provides free TLS certificates. Ensure DNS is in place and ports 80\/443 are open.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"ubuntu-debian\">Ubuntu\/Debian<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install -y certbot python3-certbot-apache\nsudo certbot --apache -d example.com -d www.example.com\n\n# Auto-renewal is installed via systemd timer\/cron\nsudo certbot renew --dry-run<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"rhel-centos-almalinux-rocky\">RHEL\/CentOS\/AlmaLinux\/Rocky<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf install -y certbot python3-certbot-apache\nsudo certbot --apache -d example.com -d www.example.com\nsudo systemctl list-timers | grep certbot<\/code><\/pre>\n\n\n\n<p>Certbot can also configure <a href=\"https:\/\/www.youstable.com\/blog\/redirect-http-to-https\/\">HTTP to HTTPS redirection<\/a> automatically. For manual rewrites, enable <code>mod_rewrite<\/code> and add a rule in your vhost.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Ubuntu\/Debian\nsudo a2enmod rewrite headers http2 ssl\nsudo systemctl reload apache2\n\n# RHEL-based: ensure modules are loaded by default (ssl, http2)\n# Add rewrite rule inside your :443 vhost or a .htaccess if AllowOverride is set\nRewriteEngine On\nRewriteCond %{HTTPS} !=on\nRewriteRule ^ https:\/\/%{HTTP_HOST}%{REQUEST_URI} &#91;R=301,L]<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"add-php-and-dynamic-apps-lamp\">Add PHP and Dynamic Apps (LAMP)<\/h2>\n\n\n\n<p>For PHP applications, use PHP-FPM with Apache\u2019s <code>event<\/code> MPM for better concurrency. Avoid legacy <code>mod_php<\/code> unless you have specific needs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"ubuntu-debian-php-fpm\">Ubuntu\/Debian (PHP-FPM)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install -y php-fpm php-mysql\nsudo a2dismod mpm_prefork php*\nsudo a2enmod mpm_event proxy_fcgi setenvif\nsudo a2enconf php*-fpm\nsudo systemctl reload apache2<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"rhel-based-php-fpm\">RHEL-based (PHP-FPM)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf install -y php-fpm php-mysqlnd\nsudo systemctl enable --now php-fpm\n\n# In your vhost or a conf.d snippet:\n# Proxy PHP requests to PHP-FPM socket\n&lt;FilesMatch \\.php$&gt;\n    SetHandler \"proxy:unix:\/run\/php-fpm\/www.sock|fcgi:\/\/localhost\/\"\n&lt;\/FilesMatch&gt;\n\nsudo systemctl reload httpd<\/code><\/pre>\n\n\n\n<p><strong>Place a quick test file to verify PHP is working:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"&lt;?php phpinfo(); ?&gt;\" | sudo tee \/var\/www\/example.com\/public_html\/info.php<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"security-hardening-essentials\">Security Hardening Essentials<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Hide version info: <\/strong>set <code>ServerTokens Prod<\/code> and <code>ServerSignature Off<\/code>.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.youstable.com\/blog\/disable-directory-browsing-listing-using-htaccess\/\">Disable directory<\/a> listing: Options -Indexes.<\/li>\n\n\n\n<li><strong>Use HTTPS everywhere:<\/strong> enforce <a href=\"https:\/\/www.youstable.com\/blog\/redirect-http-to-https-using-htaccess\/\">HTTP to HTTPS redirects<\/a> and enable HSTS via Header always set Strict-Transport-Security &#8220;max-age=31536000; includeSubDomains; preload.<\/li>\n\n\n\n<li><strong>Limit .htaccess: <\/strong>prefer vhost configs; if needed, set <code>AllowOverride<\/code> narrowly (e.g., <code>AllowOverride FileInfo<\/code>).<\/li>\n\n\n\n<li><strong>Permissions:<\/strong> web files owned by a deploy user, readable by Apache; avoid 777.<\/li>\n\n\n\n<li>WAF: consider <code>mod_security<\/code> + OWASP CRS; rate-limit with Fail2ban.<\/li>\n\n\n\n<li>Keep Apache, OpenSSL, PHP, and system packages updated regularly.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># Ubuntu\/Debian hardening snippet (add to vhost or a conf.d file)\nsudo tee \/etc\/apache2\/conf-available\/security-hardening.conf &gt;\/dev\/null &lt;&lt;'EOF'\nServerTokens Prod\nServerSignature Off\nTraceEnable Off\n\n# Disable legacy protocols where possible (TLS only)\nSSLProtocol all -SSLv3 -TLSv1 -TLSv1.1\nSSLCipherSuite HIGH:!aNULL:!MD5:!3DES\nSSLHonorCipherOrder on\n\nHeader always set X-Content-Type-Options \"nosniff\"\nHeader always set X-Frame-Options \"SAMEORIGIN\"\nHeader always set Referrer-Policy \"strict-origin-when-cross-origin\"\nEOF\n\nsudo a2enconf security-hardening\nsudo a2enmod headers ssl\nsudo systemctl reload apache2<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"performance-tuning-basics\">Performance Tuning Basics<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>MPM: use <strong>event<\/strong> with PHP-FPM for high concurrency; avoid <strong>prefork<\/strong> unless required.<\/li>\n\n\n\n<li><strong>KeepAlive:<\/strong> enable with sensible <code>KeepAliveTimeout<\/code> (2\u20135s) and <code>MaxKeepAliveRequests<\/code> (100\u2013200).<\/li>\n\n\n\n<li><strong>Compression:<\/strong> enable <code>mod_deflate<\/code> (gzip) or <code>mod_brotli<\/code> if available.<\/li>\n\n\n\n<li><strong>Caching:<\/strong> set far-future cache headers for static assets using <code>mod_expires<\/code>.<\/li>\n\n\n\n<li><strong>HTTP\/2: <\/strong>enable for TLS virtual hosts to improve multiplexing.<\/li>\n\n\n\n<li><strong>Logs:<\/strong> rotate and compress logs to prevent disk I\/O bottlenecks.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># Ubuntu\/Debian enable modules\nsudo a2enmod http2 deflate headers expires brotli\nsudo systemctl reload apache2\n\n# Example tuning snippet\nsudo tee \/etc\/apache2\/conf-available\/perf.conf >\/dev\/null &lt;&lt;'EOF'\nProtocols h2 http\/1.1\nH2ModernTLSOnly on\n\nKeepAlive On\nMaxKeepAliveRequests 200\nKeepAliveTimeout 3\n\n&lt;IfModule mod_deflate.c>\n  AddOutputFilterByType DEFLATE text\/html text\/plain text\/xml text\/css application\/javascript application\/json\n&lt;\/IfModule>\n\n&lt;IfModule mod_expires.c>\n  ExpiresActive On\n  ExpiresByType text\/css \"access plus 7 days\"\n  ExpiresByType application\/javascript \"access plus 7 days\"\n  ExpiresByType image\/* \"access plus 30 days\"\n&lt;\/IfModule>\nEOF\n\nsudo a2enconf perf\nsudo systemctl reload apache2<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"logging-monitoring-and-troubleshooting\">Logging, Monitoring, and Troubleshooting<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Log locations:<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Ubuntu\/Debian:<\/strong> <code>\/var\/log\/apache2\/access.log<\/code>, <code>\/var\/log\/apache2\/error.log<\/code><\/li>\n\n\n\n<li><strong>RHEL-based:<\/strong> <code>\/var\/log\/httpd\/access_log<\/code>, <code>\/var\/log\/httpd\/error_log<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Tail logs during deploys: <\/strong><code>sudo tail -f \/var\/log\/apache2\/error.log<\/code><\/li>\n\n\n\n<li><strong>Check service state:<\/strong> <code>systemctl status apache2|httpd<\/code>, <code>journalctl -u apache2 -b<\/code><\/li>\n\n\n\n<li><strong>Validate config:<\/strong> <code>apachectl configtest<\/code> or <code>httpd -t<\/code><\/li>\n\n\n\n<li><strong>Firewall\/SELinux: <\/strong>confirm ports 80\/443 are open; on RHEL, use <code>restorecon<\/code> and <code>semanage<\/code> for contexts.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># Quick health check\ncurl -I https:\/\/example.com\n# Expect: HTTP\/2 200 or 301 (if redirecting to HTTPS)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"scaling-and-deployment-tips\">Scaling and Deployment Tips<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Reverse proxy: <\/strong>use <code>mod_proxy<\/code> to front Node.js, Python (Gunicorn), or Go services.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.youstable.com\/blog\/install-load-balancer-on-linux\/\"><strong>Load balancing:<\/strong><\/a> mod_proxy_balancer with sticky sessions for multi node backends.<\/li>\n\n\n\n<li><strong>Zero downtime reloads:<\/strong> use <code>systemctl reload<\/code> after config changes.<\/li>\n\n\n\n<li><strong>CI\/CD:<\/strong> template vhosts with Ansible; store configs in version control.<\/li>\n\n\n\n<li><strong>Backups:<\/strong> regularly archive <code>\/etc\/apache2<\/code> or <code>\/etc\/httpd<\/code> and your site roots.<\/li>\n<\/ul>\n\n\n\n<p>If you prefer a managed setup, YouStable\u2019s VPS and Dedicated plans ship with optimized LAMP stacks, free SSL, global CDN pairing, and 24\u00d77 support. We handle security updates, monitoring, and performance tuning so you can focus on your application.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"common-apache-commands-cheat-sheet\">Common Apache Commands Cheat Sheet<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># Ubuntu\/Debian module and site helpers\nsudo a2enmod rewrite ssl http2 headers\nsudo a2dismod mpm_prefork\nsudo a2ensite example.com.conf\nsudo a2dissite 000-default.conf\nsudo apachectl configtest\nsudo systemctl reload apache2\n\n# RHEL-based\nsudo httpd -M | sort\nsudo systemctl reload httpd\nsudo httpd -t<\/code><\/pre>\n\n\n\n<p>You now know how to use Apache on a <a href=\"https:\/\/www.youstable.com\/blog\/best-linux-dedicated-server\">Linux server<\/a>, from installation and vhosts to TLS, security, and tuning. Build confidently, keep configs versioned, and consider managed hosting from YouStable when you\u2019re ready to focus purely on growth.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"faqs\">FAQs<\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1765782312911\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \" class=\"rank-math-question \" id=\"is-apache-or-nginx-better-and-when-should-i-use-apache\">Is Apache or Nginx better, and when should I use Apache?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Apache is ideal for .htaccess-heavy sites, complex rewrites, and legacy PHP apps. Nginx often excels at static file throughput and as a reverse proxy. With PHP-FPM and the event MPM, Apache handles high concurrency well. Choose based on your app\u2019s needs, team familiarity, and existing tooling.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1765782325066\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \" class=\"rank-math-question \" id=\"how-do-i-redirect-http-to-https-in-apache\">How do I redirect HTTP to HTTPS in Apache?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Enable <code>mod_rewrite<\/code> and add a 301 rule in your port 80 vhost or use Certbot\u2019s auto-redirect. Example:<\/p>\n<p>RewriteEngine On<br \/>RewriteCond %{HTTPS} !=on<br \/>RewriteRule ^ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [R=301,L]\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1765782351716\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \" class=\"rank-math-question \" id=\"where-are-apache-configuration-files-on-ubuntu-vs-centos\">Where are Apache configuration files on Ubuntu vs. CentOS?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Ubuntu\/Debian: <code>\/etc\/apache2\/<\/code> with <code>sites-available<\/code>, <code>sites-enabled<\/code>, and <code>mods-available<\/code>. RHEL-based: <code>\/etc\/httpd\/<\/code> with <code>conf\/httpd.conf<\/code> and per-site files in <code>conf.d\/<\/code>. Logs live in <code>\/var\/log\/apache2\/<\/code> (Ubuntu) or <code>\/var\/log\/httpd\/<\/code> (RHEL).<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1765782363783\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \" class=\"rank-math-question \" id=\"how-do-i-enable-htaccess-and-what-are-the-risks\">How do I enable .htaccess and what are the risks?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Set <code>AllowOverride<\/code> for the directory that needs it (e.g., <code>AllowOverride FileInfo<\/code>). .htaccess adds per-request file lookups and can be misused. Prefer placing rules in the main vhost whenever possible for performance and security.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1765782373001\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \" class=\"rank-math-question \" id=\"how-many-websites-can-apache-host-on-one-server\">How many websites can Apache host on one server?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Technically hundreds or thousands via VirtualHosts. The real limit is CPU, RAM, storage IOPS, and your application stack (PHP workers, databases). Monitor load, memory, and connection counts; scale vertically or horizontally (load balancer) as traffic grows.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>How to use Apache on a Linux server: install Apache (apache2\/httpd), allow ports 80\/443 in the firewall, start and enable [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":13221,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1134],"tags":[],"class_list":["post-13217","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"acf":[],"featured_image_src":"https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2025\/12\/Beginners-Guide-Use-Apache-on-Linux-Like-a-Pro.jpg","author_info":{"display_name":"Prahlad Prajapati","author_link":"https:\/\/www.youstable.com\/blog\/author\/prahladblog"},"_links":{"self":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/13217","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/comments?post=13217"}],"version-history":[{"count":4,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/13217\/revisions"}],"predecessor-version":[{"id":19896,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/13217\/revisions\/19896"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/media\/13221"}],"wp:attachment":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/media?parent=13217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/categories?post=13217"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/tags?post=13217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}