Home directory websites using vhost

Needs / Issues

  • Develop websites located inside home directory;
  • No need for special (root/web server) privileges to develop sites;
  • Websites are referenced with DNS, not aliases.

Audience

  • Administrator / Power user;
  • Developer user.

Initial Setting

  • Apache 2.2 (or newer).

Steps

  • In a shell session (as user):
    Apache logo
    1. Create your "root" directory
      mkdir ~/public_html
      This is where the site will be hosted.
       
    2. Make sure the Apache user can access that root directory:
      namei -l ~/public_html
      All directories in the output list should be at least executable by the Apache user.
  • In a shell session (as root):
    1. Enable VHosts in Apache's configuration:
      vi /etc/httpd/conf/httpd.conf
      Uncomment the following line:
      NameVirtualHost *:80
       
    2. Create an Apache configuration file for your website:
      vi /etc/httpd/conf.d/YOUR_WEBSITE.conf
      Have it contain:
      <VirtualHost *:80>   ServerName YOUR_WEBSITE.localhost
        DocumentRoot /home/YOUR_USERNAME/public_html
        <Directory "/home/YOUR_USERNAME/public_html">
          AllowOverride All
          Order Allow,Deny
          Allow from All
        </Directory>
        ErrorLog logs/YOUR_WEBSITE.localhost-error_log
        CustomLog logs/YOUR_WEBSITE.localhost-access_log common
      </VirtualHost>
    3. Restart the web server:
      service httpd restart
       
    4. Add a local DNS entry to your website:
      vi /etc/hosts
      Add the following line:
      127.0.0.1  YOUR_WEBSITE.localhost
  • In your web browser:
    1. Browse to the URL you created:
      http://YOUR_WEBSITE.localhost/
    2. You should be served your new website.

Nhận xét

Bài đăng phổ biến từ blog này

CLEANING UP THE ZABBIX DATABASE

Configuring DHCP Relay service on the FortiGate unit

[Resolved] Amazon EC2 Redhat 7 using 6GB for the root space