UbuntuWiki:UserDirectoryPHP

来自Ubuntu中文
Oneleaf留言 | 贡献2007年5月15日 (二) 05:12的版本 (New page: {{From|https://wiki.ubuntu.com/UserDirectoryPHP}} {{Languages|UbuntuWiki:UserDirectoryPHP}} === Purpose === When completed, this procedure allows users to securely run PHP files from <code...)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳到导航跳到搜索

{{#ifexist: :UbuntuWiki:UserDirectoryPHP/zh | | {{#ifexist: UbuntuWiki:UserDirectoryPHP/zh | | {{#ifeq: {{#titleparts:UbuntuWiki:UserDirectoryPHP|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:UbuntuWiki:UserDirectoryPHP|1|-1|}} | zh | | }}

Purpose

When completed, this procedure allows users to securely run PHP files from ~/public_html/ to manipulate their own files.

Procedure

Install Apache 2, PHP 5, and support for executing pseudo-binaries.

sudo apt-get install apache2 php5-cgi binfmt-support

Configure PHP 5 to run .php scripts from the shell.

sudo update-binfmts --install PHP /usr/bin/php5-cgi --extension php

Enable necessary Apache modules.

sudo a2enmod rewrite
sudo a2enmod suexec
sudo a2enmod include
sudo a2enmod userdir

Enable Apache's handling of PHP files. Add the following line to /etc/apache2/apache2.conf

AddHandler cgi-script .php

Configure the userdir module. Uncomment the following lines in /etc/apache2/apache2.conf.

UserDir public_html
UserDir disabled root

<Directory /home/*/public_html>
	AllowOverride FileInfo AuthConfig Limit
	Options Indexes SymLinksIfOwnerMatch IncludesNoExec
</Directory>

Add the ExecCGI option. The block should now appear as below.

UserDir public_html
UserDir disabled root

<Directory /home/*/public_html>
	AllowOverride FileInfo AuthConfig Limit
	Options Indexes SymLinksIfOwnerMatch IncludesNoExec ExecCGI
</Directory>

Reload the Apache configuration.

sudo /etc/init.d/apache2 force-reload