Saturday, 20 August 2011

PHP - Create virtual host for Zend Framework

Hi,

These are tutorials how to create virtual host for Zend Framework
  1. Ubuntu:
    1. Apache:
      • sudo vim /etc/apache2/sites-available/domain.com
        • <VirtualHost *:80>
              ServerName   my.domain.com
              ServerRoot   /path/to/server/root/
              DocumentRoot /path/to/server/root/my.domain.com/public
              RewriteEngine off
              <Location />
                  RewriteEngine on
                  RewriteCond %{REQUEST_FILENAME} !-f
                  RewriteCond %{REQUEST_FILENAME} !-d
                  RewriteRule !\.(js|ico|gif|jpg|png|css|swf|json|xml)$ /index.php
              </Location>
          </VirtualHost>
      • sudo ln -s /etc/apache2/sites-available/domain.com /etc/apache2/sites-enabled/domain.com
      • sudo /etc/init.d/apache2 restart:
    2. Lighttpd:
      • sudo vim /etc/lighttpd/conf-enabled/10-simple-vhost.conf:
        • $HTTP["host"] == "hostname" {
              server.document-root = "/home/web/123do.tracking/public/"
              url.rewrite-once = (".*\.(js|ico|gif|jpg|png|css|swf|xml)$" => "$0", "" => "/index.php")
          }
          • --OR--
        • $HTTP["host"] == "hostname" {
              server.document-root = "/home/web/123do.tracking/public/"
              url.rewrite-once = ( "^(/(?!(favicon.ico$|scripts/|styles/|images/)).*)" => "index.php" )
          }
      • sudo /etc/init.d/lighttpd restart
  2. Centos:
    1. Apache:
      • sudo vi /etc/httpd/conf/httpd.conf
        • <VirtualHost *:80>
              ServerName   domain.com
              ServerRoot   /var/www/domain
              DocumentRoot /var/www/domain

              RewriteEngine off

              <Location />
          RewriteEngine on
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule !\.(js|ico|gif|jpg|png|css|swf|json|xml)$ /index.php
              </Location>
          </VirtualHost>
      • sudo /etc/init.d/httpd restart


Good luck!

No comments:

Post a Comment