Установка Apache + PHP под FreeBSD 13.0 (x64) :: Cетевой уголок Majestio

Установка Apache + PHP под FreeBSD 13.0 (x64)


Устанавливаем:

pkg install www/apache24
pkg install lang/php74
pkg install lang/php74-extensions
###
pkg install databases/php74-pdo_pgsql
pkg install databases/php74-pgsql
pkg install databases/php74-odbc
pkg install mail/php74-imap
pkg install net/php74-ldap
pkg install archivers/php74-bz2
pkg install archivers/php74-zip
pkg install converters/php74-mbstring
pkg install databases/php74-mysqli
pkg install databases/php74-pdo_mysql
pkg install devel/php74-gettext
pkg install devel/php74-intl
pkg install devel/php74-pcntl
pkg install devel/php74-readline
pkg install devel/php74-shmop
pkg install devel/php74-sysvmsg
pkg install devel/php74-sysvsem
pkg install devel/php74-sysvshm
pkg install ftp/php74-curl
pkg install ftp/php74-ftp
pkg install graphics/php74-exif
pkg install graphics/php74-gd
pkg install math/php74-bcmath
pkg install math/php74-gmp
pkg install misc/php74-calendar
pkg install net/php74-soap
pkg install net/php74-sockets
pkg install net/php74-xmlrpc
pkg install security/php74-openssl
pkg install sysutils/php74-fileinfo
pkg install textproc/php74-enchant
pkg install textproc/php74-pspell
pkg install textproc/php74-xsl
pkg install www/mod_php74
pkg install www/php74-tidy

Сообщения после установки:

Message from db5-5.3.28_8:
--
===>   NOTICE:
The db5 port currently does not have a maintainer. As a result, it is
more likely to have unresolved issues, not be up-to-date, or even be removed in
the future. To volunteer to maintain this port, please create an issue at:

https://bugs.freebsd.org/bugzilla

More information about port maintainership is available at:

https://docs.freebsd.org/en/articles/contributing/#ports-contributing
--
===>   NOTICE:
This port is deprecated; you may wish to reconsider installing it:
EOLd, potential security issues, maybe use db18 instead.
It is scheduled to be removed on or after 2022-06-30.
=====
Message from apr-1.7.0.1.6.1_2:
--
The Apache Portable Runtime project removed support for FreeTDS with
version 1.6. Users requiring MS-SQL connectivity must migrate
configurations to use the added ODBC driver and FreeTDS' ODBC features.
=====
Message from apache24-2.4.53_1:
--
To run apache www server from startup, add apache24_enable="yes"
in your /etc/rc.conf. Extra options can be found in startup script.

Your hostname must be resolvable using at least 1 mechanism in
/etc/nsswitch.conf typically DNS or /etc/hosts or apache might
have issues starting depending on the modules you are using.

- apache24 default build changed from static MPM to modular MPM
- more modules are now enabled per default in the port
- icons and error pages moved from WWWDIR to DATADIR

   If build with modular MPM and no MPM is activated in
   httpd.conf, then mpm_prefork will be activated as default
   MPM in etc/apache24/modules.d to keep compatibility with
   existing php/perl/python modules!

Please compare the existing httpd.conf with httpd.conf.sample
and merge missing modules/instructions into httpd.conf!
===== ДАЛЕЕ В СООБЩЕНИЯХ УСЕЧЕНЫ ПОВТОРЫ ======================================
This file has been added to automatically load the installed extension:
/usr/local/etc/php/ext-20-dom.ini
/usr/local/etc/php/ext-20-pdo.ini
/usr/local/etc/php/ext-18-session.ini
/usr/local/etc/php/ext-10-opcache.ini
/usr/local/etc/php/ext-20-xmlwriter.ini
/usr/local/etc/php/ext-30-xmlreader.ini
/usr/local/etc/php/ext-20-xml.ini
/usr/local/etc/php/ext-20-simplexml.ini
/usr/local/etc/php/ext-20-ctype.ini
/usr/local/etc/php/ext-20-posix.ini
/usr/local/etc/php/ext-20-filter.ini
/usr/local/etc/php/ext-20-tokenizer.ini
/usr/local/etc/php/ext-20-json.ini
/usr/local/etc/php/ext-20-sqlite3.ini
/usr/local/etc/php/ext-30-pdo_sqlite.ini
/usr/local/etc/php/ext-20-iconv.ini
/usr/local/etc/php/ext-20-phar.ini
/usr/local/etc/php/ext-30-pdo_pgsql.ini
/usr/local/etc/php/ext-20-pgsql.ini
/usr/local/etc/php/ext-20-bcmath.ini
/usr/local/etc/php/ext-20-bz2.ini
/usr/local/etc/php/ext-20-calendar.ini
/usr/local/etc/php/ext-20-curl.ini
/usr/local/etc/php/ext-20-enchant.ini
/usr/local/etc/php/ext-20-exif.ini
/usr/local/etc/php/ext-20-fileinfo.ini
/usr/local/etc/php/ext-20-ftp.ini
/usr/local/etc/php/ext-20-gd.ini
/usr/local/etc/php/ext-20-gettext.ini
/usr/local/etc/php/ext-20-gmp.ini
/usr/local/etc/php/ext-20-intl.ini
/usr/local/etc/php/ext-20-ldap.ini
/usr/local/etc/php/ext-20-mbstring.ini
/usr/local/etc/php/ext-20-mysqli.ini
/usr/local/etc/php/ext-20-odbc.ini
/usr/local/etc/php/ext-20-openssl.ini
/usr/local/etc/php/ext-20-pcntl.ini
/usr/local/etc/php/ext-20-pspell.ini
/usr/local/etc/php/ext-20-readline.ini
/usr/local/etc/php/ext-20-shmop.ini
/usr/local/etc/php/ext-20-soap.ini
/usr/local/etc/php/ext-20-sockets.ini
/usr/local/etc/php/ext-20-sysvmsg.ini
/usr/local/etc/php/ext-20-sysvsem.ini
/usr/local/etc/php/ext-20-sysvshm.ini
/usr/local/etc/php/ext-20-zip.ini
/usr/local/etc/php/ext-30-imap.ini
/usr/local/etc/php/ext-30-pdo_mysql.ini
/usr/local/etc/php/ext-30-xmlrpc.ini
/usr/local/etc/php/ext-20-tidy.ini
/usr/local/etc/php/ext-30-xsl.ini
Upstream Security Support ends on 2022-11-28.
It is scheduled to be removed on or after 2022-11-29.
******************************************************************************
Message from mod_php74-7.4.29_2:
******************************************************************************

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) or Synth with ZTS enabled,
add WITH_MPM=event to /etc/make.conf to prevent build failures.

Добавляем в /etc/rc.conf

apache24_enable="YES"

Правим /usr/local/etc/apache24/httpd.conf:

Находим и раскомментируем строчку:

Include etc/apache24/extra/httpd-vhosts.conf

В файле /usr/local/etc/apache24/extra/httpd-vhosts.conf заменяем содержимое на:

<VirtualHost *:80>
    ServerAdmin webmaster@template-html5.loc
    DocumentRoot "/mnt/tree/www/template-html5.loc/public_html"
    ServerName template-html5.loc
    ServerAlias www.template-html5.loc
    ErrorLog "/mnt/tree/www/template-html5.loc/logs/template-html5.loc-error_log"
    CustomLog "/mnt/tree/www/template-html5.loc/logs/template-html5.loc-access" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@template-laravel.loc
    DocumentRoot "/mnt/tree/www/template-laravel.loc/public_html"
    ServerName template-laravel.loc
    ErrorLog "/mnt/tree/www/template-laravel.loc/logs/template-laravel.loc-error_log"
    CustomLog "/mnt/tree/www/template-laravel.loc/logs/template-laravel.loc-access" common
</VirtualHost>

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

В основном конфиге /usr/local/etc/apache24/httpd.conf пропишем

ServerName freebsd-13.loc:80
DocumentRoot "/mnt/tree/www/freebsd-13.loc/public_html"

И далее находим и заменяем для корневого сервера соответствующие настройки.

Подготовим нужные каталоги:

mkdir -p /mnt/tree/www/freebsd-13.loc/public_html/cgi-bin
mkdir -p /mnt/tree/www/freebsd-13.loc/logs
mkdir -p /mnt/tree/www/template-html5.loc/public_html
mkdir -p /mnt/tree/www/template-html5.loc/logs
mkdir -p /mnt/tree/www/template-laravel.loc/public_html
mkdir -p /mnt/tree/www/template-laravel.loc/logs
chown www:www /mnt/tree/www/freebsd-13.loc/public_html
chown www:www /mnt/tree/www/freebsd-13.loc/public_html/cgi-bin
chown www:www /mnt/tree/www/freebsd-13.loc/logs
chown www:www /mnt/tree/www/template-html5.loc/public_html
chown www:www /mnt/tree/www/template-html5.loc/logs
chown www:www /mnt/tree/www/template-laravel.loc/public_html
chown www:www /mnt/tree/www/template-laravel.loc/logs

Запускаем и проверяем:

service apache24 start
sockstat -4 -l | grep httpd

Теперь расскоментируем строчку в основном файле конфигурации /usr/local/etc/apache24/httpd.conf:

Include etc/apache24/extra/httpd-vhosts.conf

А в файле виртуальных хостов /usr/local/etc/apache24/extra/httpd-vhosts.conf пропишем следующее содержание

# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#

<VirtualHost *:80>
    ServerAdmin webmaster@freebsd-13.loc
    DocumentRoot "/mnt/tree/www/freebsd-13.loc/public_html"
    ServerName freebsd-13.loc
    ServerAlias www.freebsd-13.loc
    DirectoryIndex index.html index.htm index.php
    ErrorLog "/mnt/tree/www/freebsd-13.loc/logs/freebsd-13.loc-error_log"
    CustomLog "/mnt/tree/www/freebsd-13.loc/logs/freebsd-13.loc-access" common
    <Directory /mnt/tree/www/freebsd-13.loc/public_html>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride None
      Order allow,deny
      Allow from all
      Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@template-html5.loc
    DocumentRoot "/mnt/tree/www/template-html5.loc/public_html"
    ServerName template-html5.loc
    ServerAlias www.template-html5.loc
    DirectoryIndex index.html index.htm index.php
    ErrorLog "/mnt/tree/www/template-html5.loc/logs/template-html5.loc-error_log"
    CustomLog "/mnt/tree/www/template-html5.loc/logs/template-html5.loc-access" common
    <Directory /mnt/tree/www/template-html5.loc/public_html>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride None
      Order allow,deny
      Allow from all
      Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@template-laravel.loc
    DocumentRoot "/mnt/tree/www/template-laravel.loc/public_html"
    ServerName template-laravel.loc
    DirectoryIndex index.html index.htm index.php
    ErrorLog "/mnt/tree/www/template-laravel.loc/logs/template-laravel.loc-error_log"
    CustomLog "/mnt/tree/www/template-laravel.loc/logs/template-laravel.loc-access" common
    <Directory /mnt/tree/www/template-laravel.loc/public_html>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride None
      Order allow,deny
      Allow from all
      Require all granted
    </Directory>
</VirtualHost>

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

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

Теперь можно еще раз перестартовать сервер:

service apache24 start

Подключение SSL

Сперва сгенерируем самоподписанные сертификаты:

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-template-html5.loc.key -out /etc/ssl/certs/apache-template-html5.loc.crt
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-template-laravel.loc.key -out /etc/ssl/certs/apache-template-laravel.loc.crt
Рейтинг: 5/5 - 1 голосов