User Tools

Site Tools


apache_vhost_centos

Differences

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

Link to this comparison view

Next revision
Previous revision
apache_vhost_centos [2015/03/28 10:44] – created 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 7: Line 5:
 __For example:__\\ __For example:__\\
 **/etc/httpd/conf.d/example.co.uk.conf** **/etc/httpd/conf.d/example.co.uk.conf**
- +\\ 
- +\\ 
-===== Example vhost for apache =====+==== Example vhost for apache ====
 <sxh bash> <sxh bash>
 <VirtualHost *:80> <VirtualHost *:80>
-    ServerAdmin [email protected] 
- 
     ServerName example.com     ServerName example.com
     ServerAlias www.example.com     ServerAlias www.example.com
-    DocumentRoot /var/www/vhosts/example.com+    DocumentRoot /var/www/vhosts/example.com/public_html
  
-    <Directory /var/www/vhosts/example.com>+    <Directory /var/www/vhosts/example.com/public_html>
         Options Indexes FollowSymLinks         Options Indexes FollowSymLinks
         AllowOverride None         AllowOverride None
Line 25: Line 21:
     </Directory>     </Directory>
  
-    ErrorLog logs/example.com-error_log +    ErrorLog /var/log/httpd/example.com-error_log 
-    CustomLog logs/example.com-access_log common+    CustomLog /var/log/httpd/example.com-access_log common
 </VirtualHost> </VirtualHost>
 </sxh> </sxh>
 +\\
 +Globally change website from example.com to your required domain:
 +<sxh bash>
 +:%s/example.com/newwebsite.com
 +</sxh>
 +=== Reloading Apache Configuration ===
 +Once the vhost has been created you will need to reload apache for the configuration to take effect\\
  
 +\\
 +=== IMPORTANT ===
 +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)
  
-Once the vhost has been created you will need to reload apache for the configuration to take effect:\\ +<sxh bash> 
-CentOS/RHL 5,6: +<LocationMatch ^(.*/)\..*
-<sxh bash>service httpd restart</sxh+  Order Allow,Deny 
-CentOS/RHL 7: +  Deny from All 
-<sxh bash>systemctl restart httpd</sxh>+  Satisfy All 
 +</LocationMatch> 
 +</sxh>
apache_vhost_centos.1427539496.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