Dear Wiki user, You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change notification.
The following page has been changed by jmcg: http://wiki.apache.org/httpd/ScratchPad/DebianPHP New page: ## Please edit system and help pages ONLY in the moinmaster wiki! For more ## information, please see MoinMaster:MoinPagesEditorGroup. ##master-page:Unknown-Page ##master-date:Unknown-Date ##acl MoinPagesEditorGroup:read,write,delete,revert All:read #format wiki #language en == Installing Apache 2 and PHP 5 on Debian == Lately a lot of folks on #Apache requested help with the installation of Apache 2[.2] and PHP 5 on a Debian[-based] system. Even though this is a rather straight forward process, we have so far neglected to documented it. This is the purpose of this wiki page: To serve our lazyness. === Preparing your system === Before getting started, you should prepare your system, and before preparing your system, you should prepare yourself. You should know: What do you want to achieve? What technology is best fit to achieve that goal? What constraints are there? Now that you know that you want to create a ''representative appearance on the web'', using ''Apache 2'', ''PHP 5'' and ''MySQL'' as technologies, that your ''limited knowledge'' is your only constraint and that this wiki page will help you eliminate it, you can start preparing your system by typing [either as ''root'', or with ''sudo'' infront of it]: {{{ apt-get update }}} This will download the latest lists of packages, to make sure you also install the latest version of the software. ===Installing the Software=== Installing then the required packages is as straight forward as installing any other package on Debian, the trick is knowing what packages you need: {{{ apt-get install apache2 libapache2-mod-php5 }}} This should actually suffice. Debian's packagemangement system should now automatically chose the missing packages which need to be installed. If you're running the latest version of Debian [as of this writing: Etch], you might want to install also the latest [and best] version of apache, by explicitly specifying ''apache2.2-common'' in the above install command. If you also need MySQL, adding ''php5-mysql'' and ''mysql-server-5.0'', should do the rest of the magic. After the install is done, and was successful, hitting ''http://localhost/'' in your browser should prove that you now have a running web server. === Configuring PHP === As Debian is trying to be an extra friendly distro, it splits a single package up in all possible and impossible modules. In Apache's case those modules are called ''libapache2-mod-something'' and their configuration files are saved in ''/etc/apache2/mods-available''. To enable it, you'd type something like: {{{ a2enmod php5 }}} Which will simply symlink ''/etc/apache2/mods-available/php5.conf'' and ''/etc/apache2/mods-available/php5.load'' to ''/etc/apache2/mods-enabled/''. You're half done now. The last two things that need to be taken care of is to '''correct''' Debian's [and php.net's] default PHP configuration for Apache. You can do this by typing: {{{ sed -r 's/AddType/AddHandler/g' -i /etc/apache2/mods-available/php5.conf }}} And now you'll have to tell Apache to finally reload it's configuration and thus enable PHP: {{{ /etc/init.d/apache2 restart }}} That's it. You should now be able to run PHP scripts on your newly installed web server. === Resources === [[DistrosDefaultLayout#head-afb889cc78d0a4f74ca995f02aad7e8a2a7c21b9]] In order to become familiar with your new Debian-based Apache symstem you should read this Also you will be very surprised that the Debian folks not only make weird changes to make your life harder but also document it very well: In ''/usr/share/doc/apache2/'' You should find most of the documentation you need.
