User Tools

Site Tools


apache_vhost_centos

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
apache_vhost_centos [2015/12/14 11:11] luke7858apache_vhost_centos [2024/05/23 07:26] (current) – external edit 127.0.0.1
Line 1: Line 1:
-=== Configuring (all distributions) === +=== Vhosts (CentOS/RHEL) ===
-\\ +
-\\+
 Default configuration file: **/etc/httpd/conf.d/**\\ Default configuration file: **/etc/httpd/conf.d/**\\
 You will need to create a vhost in this directory, with the file ending in .conf.\\ You will need to create a vhost in this directory, with the file ending in .conf.\\
Line 9: Line 7:
 \\ \\
 \\ \\
-===== Example vhost for apache =====+==== Example vhost for apache ====
 <sxh bash> <sxh bash>
 <VirtualHost *:80> <VirtualHost *:80>
-    ServerName e.com +    ServerName example.com 
-    ServerAlias www.e.com +    ServerAlias www.example.com 
-    DocumentRoot /var/www/vhosts/e.com+    DocumentRoot /var/www/vhosts/example.com/public_html
  
-    <Directory /var/www/vhosts/e.com>+    <Directory /var/www/vhosts/example.com/public_html>
         Options Indexes FollowSymLinks         Options Indexes FollowSymLinks
         AllowOverride None         AllowOverride None
Line 28: Line 26:
 </sxh> </sxh>
 \\ \\
-\\+Globally change website from example.com to your required domain: 
 +<sxh bash> 
 +:%s/example.com/newwebsite.com 
 +</sxh>
 === Reloading Apache Configuration === === Reloading Apache Configuration ===
-Once the vhost has been created you will need to reload apache for the configuration to take effect:\\ +Once the vhost has been created you will need to reload apache for the configuration to take effect\\ 
-CentOS/RHL 5,6+ 
-<sxh bash>service httpd reload</sxh> +\\ 
-CentOS/RHL 7: +=== IMPORTANT === 
-<sxh bash>systemctl reload httpd</sxh>+It is important to note that apache WILL server hidden content (hidden files defined by '.' eg .hidden). 
 +\\ 
 +The httpd.conf or apache2.conf file comes with an entry preventing .htaccess and .htpasswd files being served
 +<sxh bash> 
 +# The following lines prevent .htaccess and .htpasswd files from being 
 +# viewed by Web clients. 
 +
 +<Files ~ "^\.ht"> 
 +    Order allow,deny 
 +    Deny from all 
 +    Satisfy All 
 +</Files> 
 +</sxh> 
 +\\  
 +Will will need to add an entry preventing other/all hidden files being served. Add the following content directly under the above content in the httpd.conf (apache2.conf file) 
 + 
 +<sxh bash> 
 +<LocationMatch ^(.*/)\..*> 
 +  Order Allow,Deny 
 +  Deny from All 
 +  Satisfy All 
 +</LocationMatch> 
 +</sxh>
apache_vhost_centos.1450091469.txt.gz · Last modified: 2024/05/23 07:26 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki