PHP, Installing
m (Reverted edits by 201.70.110.9 (Talk); changed back to last version by Jimbo) |
|||
(38 intermediate revisions by 27 users not shown) | |||
Line 33: | Line 33: | ||
You may even, if you've got the hard drive space to spare, wish to NOT issue a '''make clean''' at all on this port - it'll save you a lot of time if you ever need to install new extensions, since the work will already be done on any of the extensions that haven't been updated since the last time. | You may even, if you've got the hard drive space to spare, wish to NOT issue a '''make clean''' at all on this port - it'll save you a lot of time if you ever need to install new extensions, since the work will already be done on any of the extensions that haven't been updated since the last time. | ||
+ | |||
+ | ==PHP 5 Installing== | ||
+ | Install from ports | ||
+ | |||
+ | /usr/ports/lang/php5 | ||
+ | |||
+ | Select Apache when configuring | ||
+ | # make config | ||
+ | |||
+ | Then install the port | ||
+ | # make install clean | ||
+ | |||
+ | # cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini | ||
+ | |||
+ | Add the following lines to /usr/local/etc/apache2/httpd.conf | ||
+ | AddType application/x-httpd-php .php | ||
+ | AddType application/x-httpd-php-source .phps | ||
+ | |||
+ | Change the following line in httpd.conf from | ||
+ | DirectoryIndex index.html | ||
+ | To: | ||
+ | DirectoryIndex index.html index.php | ||
+ | |||
+ | Test with <? phpinfo(); ?> | ||
+ | # echo "<? phpinfo(); ?>" >> /usr/local/www/data/test.php | ||
+ | |||
+ | Restart apache. | ||
+ | |||
+ | |||
[[Category:Common Tasks]] | [[Category:Common Tasks]] |
Latest revision as of 09:29, 10 July 2009
Installing PHP with all the proper extensions can be a little tricky. The easiest way to do it (assuming you've already got your preferred version of Apache up and running) is as follows... first, head to /usr/ports/www/mod_php4 and make install clean. There isn't too much to be aware of here, except to make sure you either do or don't check "use Apache2" depending on whether your version of Apache is 1.x or 2.x.
Next, head to /usr/ports/lang/php4-extensions and make install - this time, though, you might want to leave the "clean" off. This one's lots more fun - this is where you get to pick and choose capabilities for everything from MySQL (or other SQL server variants) support, PDF library support, image manipulation... you name it. Pick everything you need, but try not to pick anything you DON'T need - remember, "just what you need and no more" is always better (and more secure) than "everything but the kitchen sink". You can always come back later and add more extensions if you need to - all you have to do to change which extensions you're building is type make config (a trick that works in any of the ports that have ncurses-style text menus to configure them).
Depending on how many extensions you selected, this one can take a LONG time to compile. You may also run into problems where it bombs out due to old versions of some of the dependencies for some of the extensions being installed - for example, when I just now rebuilt the extensions on this webserver, I encountered the following problem:
===> Installing for pdflib-6.0.0p1 ===> Generating temporary packing list ===> Checking if print/pdflib already installed ===> an older version of print/pdflib is already installed You may wish to ``make deinstall and install this port again by ``make reinstall to upgrade it properly. If you really wish to overwrite the old port of print/pdflib without deleting it first, set the variable "FORCE_PKG_REGISTER" in your environment or the "make install" command line. *** Error code 1 Stop in /usr/ports/print/pdflib. *** Error code 1 Stop in /usr/ports/lang/php4-extensions.
This was the fix:
freebsdwiki# cd /usr/ports/print/pdflib freebsdwiki# make deinstall freebsdwiki# cd /usr/ports/lang/php4-extensions freebsdwiki# make install
... and off it happily trundled again, finishing my aborted installation from whence it had left off. Situations like this are why, for complex ports like this one, it's well-advised NOT to issue a make install clean all in one fell swoop, but instead to make install first, and wait to make clean until everything is satisfactorily built and installed to specification. (If you're really feeling paranoid and/or are working on a really critical high-traffic server, it's better yet to start with make, then don't make install until you've already done the compilation and everything looks good, and THEN make clean to reclaim the space taken up by the work directories!)
In this case, if I had issued make install clean all in one step, I would have lost close to an hour's worth of compilation time when the process bombed out due to the older version of pdflib being in place, and would have had to begin recompiling all the extensions all over again when I returned to the php4-extensions port after removing the old pdflib.
You may even, if you've got the hard drive space to spare, wish to NOT issue a make clean at all on this port - it'll save you a lot of time if you ever need to install new extensions, since the work will already be done on any of the extensions that haven't been updated since the last time.
[edit] PHP 5 Installing
Install from ports
/usr/ports/lang/php5
Select Apache when configuring
# make config
Then install the port
# make install clean
# cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini
Add the following lines to /usr/local/etc/apache2/httpd.conf
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
Change the following line in httpd.conf from
DirectoryIndex index.html
To:
DirectoryIndex index.html index.php
Test with <? phpinfo(); ?>
# echo "<? phpinfo(); ?>" >> /usr/local/www/data/test.php
Restart apache.