Saturday, 20 August 2011

Ubuntu - Setup Apache

Install Apache2
  • sudo apt-get install apache2
  • sudo apt-get install libapache2-mod-php5
  • Enable Rewrite Module:
    • sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enable/rewrite.load


Create VirtualHost for Zend Framework Project
  • NameVirtualHost *:80
    <VirtualHost *:80>
        ServerName my.domain.com
        ServerAlias www.my.domain.com

        ServerAdmin support@my.domain.com
        DocumentRoot /path/to/server/root/

        ErrorLog /var/log/error_log-my.domain.log

        RewriteEngine on

        RewriteCond %{REQUEST_URI}              !\.(js|ico|gif|jpg|png|css|public|swf|xml)$
        RewriteRule ^/.*                        /index.php

        <Directory "/path/to/server/root/my.domain.com/public">
            Options FollowSymLinks
            AllowOverride None
            Order allow,deny
            Allow from all
        </Directory>

        <FilesMatch "\.(js|css|php)$">
            SetOutputFilter DEFLATE
        </FilesMatch>

    </VirtualHost>
  • <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>


Apache tricks
  • Could not reliably determine the server's fully qualified domain name
    • sudo vim /etc/apache2/httpd.conf
      • Add this line: "ServerName localhost"
    • sudo /etc/init.d/apache2 restart
  • Change request by client:
    • sudo vim /etc/apache2/apache2.conf
      • MaxClients your-request-number

No comments:

Post a Comment