Open Source Web Development with LAMP Using Linux, Apache, MySQL, Perl, and PHP [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Open Source Web Development with LAMP Using Linux, Apache, MySQL, Perl, and PHP [Electronic resources] - نسخه متنی

James Lee, Brent Ware

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید










10.3 Apache Configuration


Apache needs to be reconfigured to use Embperl to process HTML files. This requires a decision about how to use this module: whether to process every file with Embperl or to tag Embperl files with a special extension (.epl is commonly used) so that only those files are processed.

Processing only the files with the different filename extension is more efficient. The drawbacks are that the extension gives out information about the server, and URLs aren't uniform, which presents a human factors issuepeople remember l and don't remember .epl.

There is another good reason not to use special filenames. Suppose you have a page that has no Embperl and is linked everywhere else in your site. If you decide that page needs Embperl, it must be renamed, and all references to that file changed everywhere on your site. If that page is linked externally, it will be wrong on all the search engines.

If you do decide to create a special filename extension such as .epl, add this to Apache's configuration file:


<Files *.epl>
SetHandler perl-script
PerlHandler HTML::Embperl
Options ExecCGI
</Files>
AddType text/html .epl

We choose to not use a special extension. Instead, we'll limit the use of Embperl to a certain directory within the web document tree for only HTML files (files ending in l).

By limiting it to one directory, only the l files under that directory and its subdirectories will be processed by Embperll files in other directories will not be affected by Embperl. This is a good compromise.

Make a directory for the Embperl stuff:


$ mkdir /var/www/html/embperl
$ chmod a+rx /var/www/html/embperl

As root, add the following to the bottom of /etc/httpd/conf/httpd.conf:


SetEnv EMBPERL_DEBUG 2285
PerlSetEnv EMBPERL_LOG /var/log/embperl.log
<Directory /var/www/html/embperl>
<Files *l>
SetHandler perl-script
PerlHandler HTML::Embperl
Options ExecCGI
</Files>
</Location>

The SetEnv directive sets the variable EMBPERL_DEBUG to the value 2285. This sets the debugging level to a very high value, causing a great deal of output to be written to the log file (here configured to be /var/log/embperl. log).

To have a minimal amount of log information, set EMBPERL_DEBUG to 1. More is good for nowyou can change it later after you get used to using it. For fun, run tail -f /var/log/embperl.log in a terminal to see the debug information as it is generated.

Configuring the log file to be in /var/log/embperl.log requires that the webserver apache be able to write to this file.
[2] So, as root, execute these commands to create the file and give it the proper owner and permissions:

[2] The Embperl default is /tmp/embperl.log, which is a security problem because anyone else who uses your machine can write to this file; so don't use it.



# touch /var/log/embperl.log
# chmod gw-rwx /var/log/embperl.log
# chown apache /var/log/embperl.log

The <Directory> directive says that for the directory /var/www/html/embperl and its subdirectories, the following specifications are applied. The <Files *l> directive tells Apache to process only l files with HTML::Embperl! Files with .txt and .jpg extensions in these directories are normal files that should not processed by Embperl and should be served up plain. See perldoc HTML::Embperl for all the different ways to configure this directory.

Now, load the changed Apache configuration file:


# /etc/init.d/httpd graceful


/ 136