Installing Apache2.4, PHP7.1 on FreeBSD

1.Install and configure Apache 2.4
Let's install Apache 2.4 first. please refer to this link.

2.Install and configure PHP 7.1

$ sudo pkg install mod_php71
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        mod_php71: 7.1.12

Number of packages to be installed: 1

The process will require 4 MiB more space.
1 MiB to be downloaded.

Proceed with this action? [y/N]: y
[1/1] Fetching mod_php71-7.1.12.txz: 100%    1 MiB   1.2MB/s    00:01
Checking integrity... done (0 conflicting)
[1/1] Installing mod_php71-7.1.12...
Extracting mod_php71-7.1.12: 100%
[activating module `php7' in /usr/local/etc/apache24/httpd.conf]
Message from mod_php71-7.1.12:
***************************************************************

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>

*********************************************************************

If you are building PHP-based ports in poudriere(8) with ZTS enabled,
add WITH_MPM=event to /etc/make.conf to prevent build failures.

*********************************************************************

The installation will automatically add this line to /usr/local/etc/apache24/httpd.conf:

LoadModule php7_module        libexec/apache24/libphp7.so

Add index.php to DirectoryIndex: /usr/local/etc/apache24/httpd.conf

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

create a php.conf file at /etc/apache24/Includes/php.conf

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

create a test file: /usr/local/www/apache24/php/index.php

<?php phpinfo(); ?>

add a vhost.

<VirtualHost *:80>
    DocumentRoot "/usr/local/www/apache24/php"
    ServerName php.example.com 
    ErrorLog "/var/log/php.example.com-error_log"
    CustomLog "/var/log/php.example.com-access_log" common

    <Directory "/usr/local/www/apache24/php">
       Order allow,deny
       Allow from all
       Require all granted
    </Directory>
</VirtualHost>

<VirtualHost _default_:443>
    DocumentRoot "/usr/local/www/apache24/php"
    ServerName php.example.com 
    ErrorLog "/var/log/php.example.com-error_log"
    CustomLog "/var/log/php.example.com-access_log" common

    SSLEngine on
    SSLCertificateFile "/usr/local/etc/apache24/fullchain.pem"
    SSLCertificateKeyFile "/usr/local/etc/apache24/privkey.pem"

    <Directory "/usr/local/www/apache24/php">
       Order allow,deny
       Allow from all
       Require all granted
    </Directory>
</VirtualHost>
note:Any use of * in a virtual host declaration will have higher precedence than _default_.

Comments

Post a Comment

Popular posts from this blog

Python3 + Django + uWSGI + Nginx On FreeBSD

arduino最小構成 (atmega328/8MHz/3.3V/内部クロック)FT232RLにてブートローダーの書き込み

FreeBSD: Configuring Apache to permit CGI