# mod_php56(71) don't install or delete normaly



## verbkinm (Dec 10, 2017)

Hello all!

```
uname -a:
FreeBSD gateway-bsd 11.1-RELEASE-p4 FreeBSD 11.1-RELEASE-p4 #0: Tue Nov 14 06:12:40 UTC 2017     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
```
I'm trying to install package mod_php56 or 71. I run the command 

```
pkg install -y mod_php56
New packages to be INSTALLED:
        mod_php56: 5.6.32

Number of packages to be installed: 1

The process will require 4 MiB more space.
[1/1] Installing mod_php56-5.6.32...
[1/1] Extracting mod_php56-5.6.32: 100%
```
and the process does't end. in process table I see:
`perl -w /usr/local/sbin/apxs -e -a -n php5 libphp5.so`
when I kill him:

```
Message from mod_php56-5.6.32:
***************************************************************

Make sure index.php is part of your DirectoryIndex.

You should add the following to your Apache configuration file:

<FilesMatch "\.php$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>

***************************************************************
```
When I run `pkg delete mod_php56`, everything is the same.
In modules folder I see

```
-rw-r--r--  1 root  wheel   4,4M  7 дек.  06:12 /usr/local/libexec/apache24/libphp5.so
```
But when I try to open a php page, browser downloads the file. The php module does not work. 
Please Help!!!


----------



## verbkinm (Dec 10, 2017)

```
pkg info | grep php
mod_php56-5.6.32               PHP Scripting Language
php56-5.6.32                   PHP Scripting Language
php56-bz2-5.6.32               The bz2 shared extension for php
php56-ctype-5.6.32             The ctype shared extension for php
php56-dom-5.6.32               The dom shared extension for php
php56-extensions-1.0           "meta-port" to install PHP extensions
php56-filter-5.6.32            The filter shared extension for php
php56-gd-5.6.32                The gd shared extension for php
php56-hash-5.6.32              The hash shared extension for php
php56-iconv-5.6.32             The iconv shared extension for php
php56-json-5.6.32              The json shared extension for php
php56-mbstring-5.6.32          The mbstring shared extension for php
php56-mysqli-5.6.32            The mysqli shared extension for php
php56-opcache-5.6.32           The opcache shared extension for php
php56-openssl-5.6.32           The openssl shared extension for php
php56-pdo-5.6.32               The pdo shared extension for php
php56-pdo_sqlite-5.6.32        The pdo_sqlite shared extension for php
php56-phar-5.6.32              The phar shared extension for php
php56-posix-5.6.32             The posix shared extension for php
php56-session-5.6.32           The session shared extension for php
php56-simplexml-5.6.32         The simplexml shared extension for php
php56-sqlite3-5.6.32           The sqlite3 shared extension for php
php56-tokenizer-5.6.32         The tokenizer shared extension for php
php56-xml-5.6.32               The xml shared extension for php
php56-xmlreader-5.6.32         The xmlreader shared extension for php
php56-xmlwriter-5.6.32         The xmlwriter shared extension for php
php56-zip-5.6.32               The zip shared extension for php
php56-zlib-5.6.32              The zlib shared extension for php
phpMyAdmin-4.7.4_1             Set of PHP-scripts to manage MySQL over the web
```


----------



## verbkinm (Dec 10, 2017)

```
apachectl -v
Server version: Apache/2.4.29 (FreeBSD)
Server built:   unknown
```


----------



## Snurg (Dec 10, 2017)

In the apache httpd.conf one of the first things are the inclusions of the modules to load.
Without this, it won't load the php module.
I'd suggest you to read this to learn how to do the configuration.


----------



## verbkinm (Dec 10, 2017)

I add 
`LoadModule php5_module libexec/apache24/libphp5.so`
in *httpd.conf* but it didn't help


----------



## verbkinm (Dec 10, 2017)

`apachectl configtest
Performing sanity check on apache24 configuration:
Syntax OK`


----------



## ShelLuser (Dec 10, 2017)

I'm not too sure I understand the problem.

Anyway, there are 2 things which need to be done here. First you need to load the module, but then you'll also going to need to tell Apache about the new .php file format and how it should handle that.

I usually make a file called php5.conf in /usr/local/etc/apache24/Includes as follows:


```
<IfModule mod_php5.c>
        DirectoryIndex index.php
        AddType application/x-httpd-php .php
        AddType application/x-httpd-php-source .phps
</IfModule>
```
Then things should work normally.


----------



## verbkinm (Dec 14, 2017)

something wrong in *httpd.conf . *I used default config file and install *mod_php56* without problem!


----------



## SirDice (Dec 14, 2017)

ShelLuser said:


> I usually make a file called php5.conf in /usr/local/etc/apache24/Includes as follows:


Actually, this is what the /usr/local/etc/apache24/modules.d/ directory is for. 

Create /usr/local/etc/apache24/modules.d/001_php5.conf:

```
LoadModule php5_module libexec/apache24/libphp5.so
<IfModule mod_php5.c>
  <FilesMatch "\.php$">
    SetHandler application/x-httpd-php
  </FilesMatch>
  <FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
  </FilesMatch>
</IfModule>
```

I really wished they would stop modifying httpd.conf when installing those packages and started using the modules.d directory.


----------



## ShelLuser (Dec 14, 2017)

SirDice said:


> Actually, this is what the /usr/local/etc/apache24/modules.d/ directory is for.


I'm aware, but my problem with that is that it's already filled with other configuration files. For me the problem with adding something of your own is that it'll become harder to determine if you placed the config file there yourself or if it was installed by a package. So I keep my own stuff separated in Includes.


----------



## SirDice (Dec 14, 2017)

ShelLuser said:


> I'm aware, but my problem with that is that it's already filled with other configuration files.


That's the extra directory, the modules.d directory is empty as nobody seems to use it.



ShelLuser said:


> So I keep my own stuff separated in Includes.


I do too but only the sites themselves, split up per virtual host. Modules and module settings I put in the modules.d directory. That way you can neatly separate function and data. I'm doing it this way as it's also easy to manage with Puppet for example.


----------



## verbkinm (Jan 6, 2018)

thanks for all


----------

