Technical Blog Of JackCHAN

July 7, 2010

How to change the upload and post maximum size in LAMP Enviroment

Filed under: apache, linux — Tags: , — kaisechen @ 5:06 am

In many situations, PHP developer need to change the upload and post maximum size in LAMP Enviroment.

There are more than one way to extend the limitation.

1) modify php.ini

  • upload_max_filesize = 20M
  • post_max_size = 20M

There are obvious advantages/disadvantages about this way.

a) It is a  system-wide setting            b) It will not be effect until Apache is restarted

2) add and modify .htaccess file

a) Add content into the file

php_value upload_max_filesize 15M
php_value post_max_size 15M

b) change the privilege of the file

chmod 777 .htaccess

There are obvious advantages/disadvantages about this way.

a) It is not a system-wide setting, the .htaccess under DIR only take effection under DIR

b) It will  be effect immediately, don’t need to restart Apache.

June 7, 2010

The Apache URL Rewriting Example

Filed under: apache, Technology — Tags: — kaisechen @ 2:33 am

This article describes one example to use Apache’s mod_rewrite to solve typical URL-based problems webmasters might be usually confronted with in practice.

Firstly,  load ‘mod_rewrite’.

Open conf/httpd.conf, find ‘Dynamic Shared Object (DSO) Support’.

input :

LoadModule rewrite_module modules/mod_rewrite.so

mod_rewrite is sophisticated and powerful module.

With it webmasters can nearly do all types of URL manipulations ever dreamed about. The price  have to pay is to accept complexity.

Secondly,configue URL Layout.

Canonical Hostnames

RewriteEngine on
RewriteCond   %{HTTP_HOST} ^www\.[^.]+
RewriteRule   ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule   ^www\.([^.]+)(.*) http://$1$2 [L,R]

Thirdly,Configure how the server determines its own name and port.

With UseCanonicalName Off Apache will form self-referential URLs using the hostname and port supplied by the client if any are supplied (otherwise it will use the canonical name, as defined above). These values are the same that are used to implement name based virtual hosts, and are available with the same clients. The CGI variables SERVER_NAME and SERVER_PORT will be constructed from the client supplied values as well.

UseCanonicalName Off

VirtualDocumentRoot “C:\www\%0\html”

<Directory “C:\www\*\html”>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

VirtualScriptAlias “C:\www\%0\cgi”
<Directory “C:\www\*\cgi”>
Options None
Order allow,deny
Allow from all
</Directory>

Fourthly,modify the hosts file in desk machine(winxp).

windows/system32/drivers/etc/hosts.

Add:

127.0.0.1       localhost
127.0.0.1       test.com.au
127.0.0.1       my.company.com.au

Finally, build application directories.

C:\www\test.com.au\html

C:\www\my.company.com.au\html

when your type test.com.au, you can visit the test.com.au application hosting in C:\www\test.com.au\html.

Create a free website or blog at WordPress.com.