{"id":707,"date":"2012-01-29T13:35:56","date_gmt":"2012-01-29T21:35:56","guid":{"rendered":"http:\/\/blog.portnumber53.com\/?p=707"},"modified":"2012-01-29T13:35:56","modified_gmt":"2012-01-29T21:35:56","slug":"setting-up-a-debian-box-for-development-making-a-lamp-apache2","status":"publish","type":"post","link":"https:\/\/blog.portnumber53.com\/index.php\/2012\/01\/29\/setting-up-a-debian-box-for-development-making-a-lamp-apache2\/","title":{"rendered":"Setting up a Debian box for development: making a LAMP: apache2"},"content":{"rendered":"<p>Add a user for the web stuff<\/p>\n<p>\t# adduser httpd<\/p>\n<p>\tChoose a simple (but secure) password.<\/p>\n<p>\t# apt-get install apache2<br \/>\n\tReading package lists&#8230; Done<br \/>\n\tBuilding dependency tree<br \/>\n\tReading state information&#8230; Done<br \/>\n\tThe following extra packages will be installed:<br \/>\n\t&nbsp; apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1 libaprutil1 libaprutil1-dbd-sqlite3<br \/>\n\t&nbsp; libaprutil1-ldap<br \/>\n\tSuggested packages:<br \/>\n\t&nbsp; apache2-doc apache2-suexec apache2-suexec-custom<br \/>\n\tThe following NEW packages will be installed:<br \/>\n\t&nbsp; apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1 libaprutil1<br \/>\n\t&nbsp; libaprutil1-dbd-sqlite3 libaprutil1-ldap<br \/>\n\t0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.<br \/>\n\tNeed to get 2,155 kB of archives.<br \/>\n\tAfter this operation, 7,266 kB of additional disk space will be used.<br \/>\n\tDo you want to continue [Y\/n]? y<br \/>\n\tGet:1 http:\/\/ftp.us.debian.org\/debian\/ squeeze\/main libapr1 amd64 1.4.2-6+squeeze3 [94.2 kB]<br \/>\n\tGet:2 http:\/\/ftp.us.debian.org\/debian\/ squeeze\/main libaprutil1 amd64 1.3.9+dfsg-5 [92.3 kB]<br \/>\n\tGet:3 http:\/\/ftp.us.debian.org\/debian\/ squeeze\/main libaprutil1-dbd-sqlite3 amd64 1.3.9+dfsg-5 [28.1 kB]<br \/>\n\tGet:4 http:\/\/ftp.us.debian.org\/debian\/ squeeze\/main libaprutil1-ldap amd64 1.3.9+dfsg-5 [25.7 kB]<br \/>\n\tGet:5 http:\/\/ftp.us.debian.org\/debian\/ squeeze\/main apache2.2-bin amd64 2.2.16-6+squeeze4 [1,439 kB]<br \/>\n\tGet:6 http:\/\/ftp.us.debian.org\/debian\/ squeeze\/main apache2-utils amd64 2.2.16-6+squeeze4 [164 kB]<br \/>\n\tGet:7 http:\/\/ftp.us.debian.org\/debian\/ squeeze\/main apache2.2-common amd64 2.2.16-6+squeeze4 [308 kB]<br \/>\n\tGet:8 http:\/\/ftp.us.debian.org\/debian\/ squeeze\/main apache2-mpm-worker amd64 2.2.16-6+squeeze4 [2,240 B]<br \/>\n\tGet:9 http:\/\/ftp.us.debian.org\/debian\/ squeeze\/main apache2 amd64 2.2.16-6+squeeze4 [1,396 B]<br \/>\n\tFetched 2,155 kB in 5s (423 kB\/s)<br \/>\n\tSelecting previously deselected package libapr1.<br \/>\n\t(Reading database &#8230; 32742 files and directories currently installed.)<br \/>\n\tUnpacking libapr1 (from &#8230;\/libapr1_1.4.2-6+squeeze3_amd64.deb) &#8230;<br \/>\n\tSelecting previously deselected package libaprutil1.<br \/>\n\tUnpacking libaprutil1 (from &#8230;\/libaprutil1_1.3.9+dfsg-5_amd64.deb) &#8230;<br \/>\n\tSelecting previously deselected package libaprutil1-dbd-sqlite3.<br \/>\n\tUnpacking libaprutil1-dbd-sqlite3 (from &#8230;\/libaprutil1-dbd-sqlite3_1.3.9+dfsg-5_amd64.deb) &#8230;<br \/>\n\tSelecting previously deselected package libaprutil1-ldap.<br \/>\n\tUnpacking libaprutil1-ldap (from &#8230;\/libaprutil1-ldap_1.3.9+dfsg-5_amd64.deb) &#8230;<br \/>\n\tSelecting previously deselected package apache2.2-bin.<br \/>\n\tUnpacking apache2.2-bin (from &#8230;\/apache2.2-bin_2.2.16-6+squeeze4_amd64.deb) &#8230;<br \/>\n\tSelecting previously deselected package apache2-utils.<br \/>\n\tUnpacking apache2-utils (from &#8230;\/apache2-utils_2.2.16-6+squeeze4_amd64.deb) &#8230;<br \/>\n\tSelecting previously deselected package apache2.2-common.<br \/>\n\tUnpacking apache2.2-common (from &#8230;\/apache2.2-common_2.2.16-6+squeeze4_amd64.deb) &#8230;<br \/>\n\tSelecting previously deselected package apache2-mpm-worker.<br \/>\n\tUnpacking apache2-mpm-worker (from &#8230;\/apache2-mpm-worker_2.2.16-6+squeeze4_amd64.deb) &#8230;<br \/>\n\tSelecting previously deselected package apache2.<br \/>\n\tUnpacking apache2 (from &#8230;\/apache2_2.2.16-6+squeeze4_amd64.deb) &#8230;<br \/>\n\tProcessing triggers for man-db &#8230;<br \/>\n\tSetting up libapr1 (1.4.2-6+squeeze3) &#8230;<br \/>\n\tSetting up libaprutil1 (1.3.9+dfsg-5) &#8230;<br \/>\n\tSetting up libaprutil1-dbd-sqlite3 (1.3.9+dfsg-5) &#8230;<br \/>\n\tSetting up libaprutil1-ldap (1.3.9+dfsg-5) &#8230;<br \/>\n\tSetting up apache2.2-bin (2.2.16-6+squeeze4) &#8230;<br \/>\n\tSetting up apache2-utils (2.2.16-6+squeeze4) &#8230;<br \/>\n\tSetting up apache2.2-common (2.2.16-6+squeeze4) &#8230;<br \/>\n\tEnabling site default.<br \/>\n\tEnabling module alias.<br \/>\n\tEnabling module autoindex.<br \/>\n\tEnabling module dir.<br \/>\n\tEnabling module env.<br \/>\n\tEnabling module mime.<br \/>\n\tEnabling module negotiation.<br \/>\n\tEnabling module setenvif.<br \/>\n\tEnabling module status.<br \/>\n\tEnabling module auth_basic.<br \/>\n\tEnabling module deflate.<br \/>\n\tEnabling module authz_default.<br \/>\n\tEnabling module authz_user.<br \/>\n\tEnabling module authz_groupfile.<br \/>\n\tEnabling module authn_file.<br \/>\n\tEnabling module authz_host.<br \/>\n\tEnabling module reqtimeout.<br \/>\n\tSetting up apache2-mpm-worker (2.2.16-6+squeeze4) &#8230;<br \/>\n\tStarting web server: apache2.<br \/>\n\tSetting up apache2 (2.2.16-6+squeeze4) &#8230;<\/p>\n<p>\t# a2enmod rewrite<br \/>\n\tEnabling module rewrite.<br \/>\n\tRun &#39;\/etc\/init.d\/apache2 restart&#39; to activate new configuration!<\/p>\n<p>\t# nano \/etc\/apache2\/envvars<\/p>\n<p>\texport APACHE_RUN_USER=httpd<br \/>\n\texport APACHE_RUN_GROUP=httpd<\/p>\n<p>\tWe will activate the Mass Hosting module for Apache so we can develop a bunch of projects at the same time<\/p>\n<p>\tWe need a file to correct the value of DOCUMENT_ROOT when using such module:<\/p>\n<p>\t&lt;?php<\/p>\n<p>\t\/\/ Let&#39;s fix the document root because of a bug in Apache&#39;s mod_vhost_alias not<br \/>\n\t\/\/ setting up the correct $_SERVER[&#8216;DOCUMENT_ROOT&#8217;] env variable.<br \/>\n\t$__mod_vhost_alias_fix_doc_root = dirname(__FILE__) . DIRECTORY_SEPARATOR . &#39;domains&#39; . DIRECTORY_SEPARATOR . $_SERVER[&#8216;HTTP_HOST&#8217;] . DIRECTORY_SEPARATOR . &#39;html&#39;;<\/p>\n<p>\tif (is_dir($__mod_vhost_alias_fix_doc_root)) {<br \/>\n\t$_SERVER[&#8216;__MOD_VHOST_FIX_OLD_DOCUMENT_ROOT&#8217;] = $_SERVER[&#8216;DOCUMENT_ROOT&#8217;];<br \/>\n\t&nbsp;&nbsp;&nbsp; $_SERVER[&#8216;DOCUMENT_ROOT&#8217;] = $__mod_vhost_alias_fix_doc_root;<br \/>\n\t}<\/p>\n<p>\t?&gt;<\/p>\n<p>\tWe create a configuration file for virtual hosts:<\/p>\n<p>\tnano \/etc\/apache2\/sites-available\/vhosts<br \/>\n\t# get the server name from the Host: header<br \/>\n\tUseCanonicalName Off<\/p>\n<p>\t# splittable logs<br \/>\n\tLogFormat &quot;%{Host}i %h %l %u %t \\&quot;%r\\&quot; %s %b&quot; vcommon<br \/>\n\tCustomLog ${APACHE_LOG_DIR}\/access_log vcommon<\/p>\n<p>\t&lt;Directory \/home\/httpd\/domains\/portnumber53.local\/html&gt;<br \/>\n\t# ExecCGI is needed here because we can&#39;t force<br \/>\n\t# CGI execution in the way that ScriptAlias does<br \/>\n\tOptions FollowSymLinks ExecCGI<br \/>\n\t&lt;\/Directory&gt;<\/p>\n<p>\t# now for the hard bit<\/p>\n<p>\tRewriteEngine On<\/p>\n<p>\t# a ServerName derived from a Host: header may be any case at all<br \/>\n\tRewriteMap lowercase int:tolower<\/p>\n<p>\t## deal with normal documents first:<br \/>\n\t# allow Alias \/icons\/ to work &#8211; repeat for other aliases<br \/>\n\tRewriteCond %{REQUEST_URI} !^\/icons\/<br \/>\n\t# allow CGIs to work<br \/>\n\tRewriteCond %{REQUEST_URI} !^\/cgi-bin\/<br \/>\n\t# do the magic<br \/>\n\tRewriteRule ^\/(.*)$ \/home\/httpd\/domains\/${lowercase:%{SERVER_NAME}}\/html\/$1<\/p>\n<p>\t## and now deal with CGIs &#8211; we have to force a MIME type<br \/>\n\tRewriteCond %{REQUEST_URI} ^\/cgi-bin\/<br \/>\n\tRewriteRule ^\/(.*)$ \/home\/httpd\/domains\/${lowercase:%{SERVER_NAME}}\/cgi-bin\/$1 [T=application\/x-httpd-cgi]<\/p>\n<p>\t# that&#39;s it!<br \/>\n\ta2ensite vhosts<br \/>\n\ta2dissite default<br \/>\n\t\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/<br \/>\n\tmkdir -p \/home\/httpd\/domains\/portnumber53.local\/html<br \/>\n\techo &quot;PortNumber53.local&lt;?php phpinfo(); ?&gt;&quot; &gt; \/home\/httpd\/domains\/portnumber53.local\/html\/index.php<\/p>\n<p>\tmkdir -p \/home\/httpd\/domains\/example.local\/html<br \/>\n\techo &quot;Example.local&lt;?php phpinfo(); ?&gt;&quot; &gt; \/home\/httpd\/domains\/example.local\/html\/index.php<\/p>\n<p>\tLet&#39;s restart Apache:<br \/>\n\tservice apache2 restart<\/p>\n<p>\tAs long as your windows box solves portnumber53.local and example.local to the IP of your debian web box, try opening these domains in your browser.<\/p>\n<p>\t&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Add a user for the web stuff # adduser httpd Choose a simple (but secure) password. # apt-get install apache2 Reading package lists&#8230; Done Building dependency tree Reading state information&#8230; Done The following extra packages will be installed: &nbsp; apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1 libaprutil1 libaprutil1-dbd-sqlite3 &nbsp; libaprutil1-ldap Suggested packages:&#8230; <a class=\"continue-reading-link\" href=\"https:\/\/blog.portnumber53.com\/index.php\/2012\/01\/29\/setting-up-a-debian-box-for-development-making-a-lamp-apache2\/\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[43,102,107,210],"class_list":["post-707","post","type-post","status-publish","format-standard","hentry","category-linux","tag-apache2","tag-debian","tag-development","tag-lamp"],"_links":{"self":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/posts\/707","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/comments?post=707"}],"version-history":[{"count":0,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/posts\/707\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/media?parent=707"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/categories?post=707"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/tags?post=707"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}