# Installing PHP not from ports



## dragonbite (May 8, 2013)

I am a Linux/Window guy (please don't hold that against me  ) charged with updating our FreeBSD web server. We have a VM for which to put it all together on and script the process so it can be run on the bare-metal install on the actual physical servers.

We are supposed to use Binary Packages when able to and when I try to install PHP it is not fully "attached". 

I did the usual phpinfo() in /usr/local/www/apache22/data/ but it isn't being run as PHP (trying to download the file).

When I run the compiled modules for apache I get 
	
	



```
$ httpd -l
Compiled in modules:
  core.c
  prefork.c
  http_core.c
  mod_so.c
```

The total list of modules in /usr/local/etc/apache22/httpd.conf is 
	
	



```
LoadModule authn_file_module libexec/apache22/mod_authn_file.so
LoadModule authn_dbm_module libexec/apache22/mod_authn_dbm.so
LoadModule authn_anon_module libexec/apache22/mod_authn_anon.so
LoadModule authn_default_module libexec/apache22/mod_authn_default.so
LoadModule authn_alias_module libexec/apache22/mod_authn_alias.so
LoadModule authz_host_module libexec/apache22/mod_authz_host.so
LoadModule authz_groupfile_module libexec/apache22/mod_authz_groupfile.so
LoadModule authz_user_module libexec/apache22/mod_authz_user.so
LoadModule authz_dbm_module libexec/apache22/mod_authz_dbm.so
LoadModule authz_owner_module libexec/apache22/mod_authz_owner.so
LoadModule authz_default_module libexec/apache22/mod_authz_default.so
LoadModule auth_basic_module libexec/apache22/mod_auth_basic.so
LoadModule auth_digest_module libexec/apache22/mod_auth_digest.so
LoadModule file_cache_module libexec/apache22/mod_file_cache.so
LoadModule cache_module libexec/apache22/mod_cache.so
LoadModule disk_cache_module libexec/apache22/mod_disk_cache.so
LoadModule dumpio_module libexec/apache22/mod_dumpio.so
LoadModule reqtimeout_module libexec/apache22/mod_reqtimeout.so
LoadModule include_module libexec/apache22/mod_include.so
LoadModule filter_module libexec/apache22/mod_filter.so
LoadModule charset_lite_module libexec/apache22/mod_charset_lite.so
LoadModule deflate_module libexec/apache22/mod_deflate.so
LoadModule log_config_module libexec/apache22/mod_log_config.so
LoadModule logio_module libexec/apache22/mod_logio.so
LoadModule env_module libexec/apache22/mod_env.so
LoadModule mime_magic_module libexec/apache22/mod_mime_magic.so
LoadModule cern_meta_module libexec/apache22/mod_cern_meta.so
LoadModule expires_module libexec/apache22/mod_expires.so
LoadModule headers_module libexec/apache22/mod_headers.so
LoadModule usertrack_module libexec/apache22/mod_usertrack.so
LoadModule unique_id_module libexec/apache22/mod_unique_id.so
LoadModule setenvif_module libexec/apache22/mod_setenvif.so
LoadModule version_module libexec/apache22/mod_version.so
LoadModule ssl_module libexec/apache22/mod_ssl.so
LoadModule mime_module libexec/apache22/mod_mime.so
LoadModule dav_module libexec/apache22/mod_dav.so
LoadModule status_module libexec/apache22/mod_status.so
LoadModule autoindex_module libexec/apache22/mod_autoindex.so
LoadModule asis_module libexec/apache22/mod_asis.so
LoadModule info_module libexec/apache22/mod_info.so
LoadModule cgi_module libexec/apache22/mod_cgi.so
LoadModule dav_fs_module libexec/apache22/mod_dav_fs.so
LoadModule vhost_alias_module libexec/apache22/mod_vhost_alias.so
LoadModule negotiation_module libexec/apache22/mod_negotiation.so
LoadModule dir_module libexec/apache22/mod_dir.so
LoadModule imagemap_module libexec/apache22/mod_imagemap.so
LoadModule actions_module libexec/apache22/mod_actions.so
LoadModule speling_module libexec/apache22/mod_speling.so
LoadModule userdir_module libexec/apache22/mod_userdir.so
LoadModule alias_module libexec/apache22/mod_alias.so
LoadModule rewrite_module libexec/apache22/mod_rewrite.so
```
I do not have the directory "libexec/apache"

But the list of installed packages includes PHP 
	
	



```
$ pkg_info
apache22-2.2.23     Version 2.2.x of Apache web server with prefork MPM.
apr-1.4.6.1.4.1_1   Apache Portability Library
compat6x-amd64-6.4.604000.200810_3 A convenience package to install the compat6x libraries
db42-4.2.52_5       The Berkeley DB package, revision 4.2
expat-2.0.1_2       XML 1.0 parser written in C
gdbm-1.9.1          The GNU database manager
gettext-0.18.1.1    GNU gettext package
libiconv-1.14       A character set conversion library
libxml2-2.7.8_5     XML parser library for GNOME
pcre-8.31_1         Perl Compatible Regular Expressions library
perl-5.14.2_2       Practical Extraction and Report Language
php53-5.3.18        PHP Scripting Language
pkgconf-0.8.9       Utility to help to configure compiler and linker flags
sudo-1.8.6.p3_1     Allow others to run commands as root
```

One of my resources has been http://www.freebsdmadeeasy.com/tutorials/web-server/install-php-5-for-web-hosting.php.  All of the online resources I have found use Ports for installing PHP and the same directories or files (*.so files, mod_php, etc.) are not found.

Are there additional components I need to install (specify mod_php), or series of commands to run?

Ultimately, whichever way this works I need to be able to script it into an executable script so when it is performed on the actual server the process is automated as much as is possible.


----------



## SirDice (May 8, 2013)

The package for lang/php5 doesn't contain the needed Apache module. You will have to build from ports to get it.

That said, you can build your own package for it and transfer it to the machine to satisfy the binary package requirement.


----------



## dragonbite (May 8, 2013)

Thanks! That not only clears things up, that lets me know I am not going crazy  Where did you find this out? Is it documented anywhere? I am curious "how" you know about this so I know where to look with the other components I am installing.


----------



## kpa (May 8, 2013)

It's an FAQ on the forums, I don't remember offhand if there's a sticky about it.


----------



## ShelLuser (May 8, 2013)

dragonbite said:
			
		

> Where did you find this out? Is it documented anywhere?
> 
> I am curious "how" you know about this so I know where to look with the other components I am installing.


I don't know how (or if) you can check for this up-front, but using tools such as pkg_info (if you're still using the current package manager) or pkgng you can easily check for yourself.

For example, if you need to be sure if libphp5.so got installed then you'd only need to use `$ pkg_info -L php5* | grep apache`. After you have actually installed the php5 package of course.

I can't give any examples related to pkgng because I'm not using that one yet.


----------



## SirDice (May 16, 2013)

dragonbite said:
			
		

> Where did you find this out? Is it documented anywhere?


Packages are always built using the default options. And if you look at the PHP port you will notice the Apache module is turned off. This is done because we have a wide variety of webservers and PHP needs to be specifically buil*t* for a certain webserver.


----------



## dragonbite (Jun 6, 2013)

SirDice said:
			
		

> That said, you can build your own package for it and transfer it to the machine to satisfy the binary package requirement.



Where is there information to do this?  That would make it more automatic and scriptable with minimum interaction.


----------



## ShelLuser (Jun 6, 2013)

dragonbite said:
			
		

> Where is there information to do this?  That would make it mor automatic and scriptable with minimum interaction.


In the ports(7) manual page for starters. The package target will build a binary package in /usr/ports/packages which you can use.

Another good approach (in my opinion obviously) is the ports-mgmt/portmaster script. When installing ports you can tell portmaster that it should only use packages, even point it to the place where it should look for them (a nice feature if you want to use your own global repository).

If you want to know how the FreeBSD Ports Management Team is providing all their binary packages then maybe their package building procedure could be a good read.

Hope this can help.


----------



## SirDice (Jun 6, 2013)

ShelLuser said:
			
		

> Another good approach (in my opinion obviously) is the ports-mgmt/portmaster script. When installing ports you can tell portmaster that it should only use packages, even point it to the place where it should look for them (a nice feature if you want to use your own global repository).


Don't forget about the -g option. This will tell portmaster(8) to create a package for it.


----------

