<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>webstersprodigy.net &#187; php</title>
	<atom:link href="http://webstersprodigy.net/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://webstersprodigy.net</link>
	<description>Me trying to learn how to use a computer</description>
	<lastBuildDate>Sat, 04 Feb 2012 01:17:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>php multiuser system &#8211; the www-data problem</title>
		<link>http://webstersprodigy.net/2009/03/php-multiuser-system-the-www-data-problem/</link>
		<comments>http://webstersprodigy.net/2009/03/php-multiuser-system-the-www-data-problem/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 20:58:19 +0000</pubDate>
		<dc:creator>webstersprodigy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://webstersprodigy.net/?p=459</guid>
		<description><![CDATA[On our multi-user system, one where we have 300+ users all with usermod enabled, we also happen to have other web services running. It's inconvenient and in some ways insecure for everyone to be running their dynamic web stuff as the same user. One problem in particular is php. suexec was built for cgi-bin stuff - but php is a whole other beast. That's what I'm talking about here - getting php to run as the user who owns it. More specifically, this will show how /home/user/public_html/myphp.php will run as "user", but stuff in /var/www will still run as www-data.]]></description>
			<content:encoded><![CDATA[<p>On a lot of multi-user systems, like the one at the school where we have 300+ users all with usermod enabled, we also happen to have other web services running. It&#8217;s inconvenient and in insecure for everyone to be running their dynamic web stuff as the same user.</p>
<p>One problem in particular is php. suexec was built for cgi-bin stuff &#8211; but php is a whole other beast. That&#8217;s what I&#8217;m talking about here &#8211; getting php to run as the user who owns it. More specifically, this will show how /home/user/public_html/myphp.php will run as &#8220;user&#8221;, but stuff in /var/www will still run as www-data.</p>
<p>One good article I found describing this is here: http://alain.knaff.lu/howto/PhpSuexec/</p>
<p>First things first &#8211; mod_php needs to be disabled. This can be done globally, but it&#8217;s better to just disable it for public_html dirs. This can be done by adding the following to /etc/apache2/apache2.conf.</p>
<blockquote>
<pre class="example"><code>&lt;Directory /home&gt;
 php_admin_flag engine off
&lt;/Directory&gt;
</code></pre>
</blockquote>
<p>Now, to enable suphp.</p>
<p>First install php-cgi. and the apache2 prefork which has some things we&#8217;ll need later on.</p>
<blockquote><p>apt-get install php-cgi apache2-prefork-dev</p></blockquote>
<p>Do not install libapache2-mod-suphp &#8211; at least not on 8.04. This older version lacks some of the things most people need&#8230; like having more than one directory.</p>
<p>Download the latest suphp module from http://www.suphp.org/Home.html.  Compile this like:</p>
<blockquote>
<pre class="example"><code>tar xfzv suphp-SNAPSHOT-2008-03-31.tar.gz
cd suphp-SNAPSHOT-2008-03-31
./configure --with-apxs=/usr/bin/apxs2 --with-setid-mode=owner
make
make install
</code></pre>
</blockquote>
<p>Modify apache&#8217;s config</p>
<blockquote>
<pre class="example"><code>LoadModule suphp_module /usr/lib/apache2/modules/mod_suphp.so
&lt;Directory /home&gt;
AddHandler application/x-httpd-php .php .php3 .php4 .php5 .phtml
suPHP_AddHandler application/x-httpd-php
suPHP_Engine on
&lt;/Directory&gt;
</code></pre>
</blockquote>
<p>Now in /usr/local/etc/suphp.conf</p>
<blockquote>
<pre class="example"><code>[global]
webserver_user=www-data
docroot=${HOME}/public_html
check_vhost_docroot=false

[handlers]
;Handler for php-scripts
application/x-httpd-php="php:/usr/bin/php-cgi"
</code></pre>
</blockquote>
<p>Restart apache. To debug, check /var/log/apache2/errors.log.  To test create scripts in public_html directories and in /var/www that exec(&#8216;whoami&#8217;) and make sure they&#8217;re called with the correct permissions.</p>
<p>It&#8217;s a start, but then there&#8217;s always stuff like XSS, etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://webstersprodigy.net/2009/03/php-multiuser-system-the-www-data-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

