{"id":64,"date":"2013-05-01T20:45:37","date_gmt":"2013-05-01T18:45:37","guid":{"rendered":"http:\/\/new.cs-ware.de\/?p=64"},"modified":"2013-05-20T22:47:45","modified_gmt":"2013-05-20T20:47:45","slug":"apache-httpd-use-php-cgi-without-mod_php","status":"publish","type":"post","link":"https:\/\/www.cs-ware.de\/blog\/archives\/64","title":{"rendered":"Apache httpd: Use php-cgi without mod_php"},"content":{"rendered":"<p>The PHP site describes how to use PHP as a Apache httpd module, however that&#8217;s not always the desired option (e.g. if you want to use different PHP versions at the same time).<\/p>\n<p>In order to enable PHP in CGI mode we use the action module of Apache httpd. On Debian-based systems you have to enable it using <em>a2enmod actions<\/em>.<\/p>\n<p>One can enable php-cgi for the whole installation via the global httpd.conf, for vhosts or for specific files\/folders using .htaccess-files. The configuration looks as follows:<br \/>\n<code># CUSTOM: Add PHP parsing (via CGI) handler and action for .php files<br \/>\nScriptAlias \/local-bin\/php-cgi \/usr\/bin\/php-cgi<br \/>\nAddHandler application\/x-httpd-php .php<br \/>\nAction application\/x-httpd-php \/local-bin\/php-cgi<\/code><\/p>\n<p>Maybe you also need to allow access to \/usr\/bin by adding:<br \/>\n<code><br \/>\n&lt;Directory \"\/usr\/bin\"&gt;<br \/>\nOrder allow,deny<br \/>\nAllow from all<br \/>\n&lt;\/Directory&gt;<\/code><\/p>\n<p>Some other <a href=\"http:\/\/www.bobulous.org.uk\/coding\/apache-php-cgi.html\">howtos<\/a> suggest to use a directory as ScriptAlias (e.g. <code>ScriptAlias \/local-bin \/usr\/bin<\/code>) which might be a security problem, since all tools in \/usr\/bin can be executed via the web (e.g. http:\/\/example.com\/local-bin\/whoami). Directly using php-cgi prevents this &#8211; also php-cgi contains a security check so that I cannot be executed directly.<\/p>\n<p><strong>Update 2013-05-20:<\/strong> Debian 7 has support for this by default (a2enmod php5_cgi, you might need to install php5-cgi).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The PHP site describes how to use PHP as a Apache httpd module, however that&#8217;s not always the desired option (e.g. if you want to use different PHP versions at the same time). In order to enable PHP in CGI mode we use the action module of Apache httpd. On Debian-based systems you have to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[10,7],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-linux","tag-apache-httpd","tag-debian"],"_links":{"self":[{"href":"https:\/\/www.cs-ware.de\/blog\/wp-json\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cs-ware.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cs-ware.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cs-ware.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cs-ware.de\/blog\/wp-json\/wp\/v2\/comments?post=64"}],"version-history":[{"count":7,"href":"https:\/\/www.cs-ware.de\/blog\/wp-json\/wp\/v2\/posts\/64\/revisions"}],"predecessor-version":[{"id":146,"href":"https:\/\/www.cs-ware.de\/blog\/wp-json\/wp\/v2\/posts\/64\/revisions\/146"}],"wp:attachment":[{"href":"https:\/\/www.cs-ware.de\/blog\/wp-json\/wp\/v2\/media?parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cs-ware.de\/blog\/wp-json\/wp\/v2\/categories?post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cs-ware.de\/blog\/wp-json\/wp\/v2\/tags?post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}