# Need help compiling php71



## bonbon (Jun 21, 2018)

Hi all.. Thanks in advance for any help.......

I am trying to compile php71.....I found another post that i am trying to follow.
========================================================
This is what i am trying to do...here is the post.....
============================================================
If installing PHP from source, you need to pass several options to `./configure` in order to make the proper links. Essential are the `--with-<library>-dir=/usr/lib/`, otherwise PHP cannot find the libraries.

1. You first need to make sure you have libgd, libjpeg, libpng and zlib installed. If installed from FreeBSD ports:

```
# cd /usr/ports/graphics/gd
# make install clean
```
Make sure you have libgd.so, libjpeg.so and libpng.so in /usr/local/lib. zlib.h should be in /usr/include.

2. By default libraries are installed in /usr/local/lib. Make sure you create symbolic links in /usr/lib:
`# ln -s /usr/local/lib/libjpeg.so /usr/lib/
# ln -s /usr/local/lib/libpng.so /usr/lib/
# ln -s /usr/local/lib/libxml2.so /usr/lib/`

3. Compile PHP. You have to at least specify the following options:

`# ./configure \
 --prefix=<dir to install php> \
 --with-config-file-path=<dir to install php.ini> \
 --with-apxs2=<path to apache/bin/apxs> \
 --with-zlib \
 --with-mysql \
 --with-pdo-mysql \
 --with-gd \
 --with-jpeg-dir=/usr/lib \
 --with-png-dir=/usr/lib \
 --with-libxml-dir=/usr/lib \
 --with-zlib-dir=/usr/include/`

`# make
# make install`

Restart the httpd daemon and it should work. 

===================================================================================
I have installed apache24 and did a make install on gd. I set the 3 symbolic links and all is well but when i do a ./configure i get permission denied.
I am logged in as root . I am using this format.
# /usr/ports/lang/php71 ./configure --prefix=/php --with-config-file-path=/php
I get the same thing when i type it like this..
#cd /usr/ports/lang/php71 ./configure --prefix=/php  --with-config-file-path=/php

I need to compile php with the above options. Not sure what I am doing wrong . I am new to freebsd . can someone help me with this part of the code?   Thanks ......
======================================================[/code]


----------



## ondra_knezour (Jun 21, 2018)

Any reason for not use `# pkg install php71` or `# pkg install mod_php71` and then install extensions you need?


----------



## bonbon (Jun 22, 2018)

Thanks I will look for what i need and try to go that route......have a great day!


----------



## bonbon (Jun 22, 2018)

Thanks I used your suggestion and it was a snap doing it that way!

Just one problem now......

 in httpd public dir...... system/library/session/native.php   php hangs up on line 3 of native.php

class native extends \SessionHandler
==========================================================================

added this to the bottom of my httpd.conf

```
<FilesMatch "\.php$">
    SetHandler application/x-httpd-php
 </FilesMatch>
 <FilesMatch "\.phps$">
    setHandler application/x-httpd-php-source
 </FilesMatch>
```
I also added index.php to my directory index

any idea what is wrong and how to fix it?


----------



## SirDice (Jun 22, 2018)

bonbon said:


> 2. By default libraries are installed in /usr/local/lib. Make sure you create symbolic links in /usr/lib:
> `# ln -s /usr/local/lib/libjpeg.so /usr/lib/
> # ln -s /usr/local/lib/libpng.so /usr/lib/
> # ln -s /usr/local/lib/libxml2.so /usr/lib/`


NEVER do things like this. Ever.



> added this to the bottom of my httpd.conf
> 
> ```
> <FilesMatch "\.php$">
> ...


Create a /usr/local/etc/apache24/modules.d/001_php.conf and put that code there. That's a much better place for it.


----------



## julp (Jun 22, 2018)

If you used packages or ports, you may need to install all php extensions you'll need as they are separate packages.


```
pkg install php71-session
```


----------

