FreeBSD

FreeBSD: Пошаговая установка и настройка Web сервера

Иметь свой собственный веб-сервер на самом деле очень удобно и практично. Если нужно протестировать скрипты, вывести информацию о состоянии оборудования или просто разместить небольшой сайт – все это возможно при наличии такого сервера.

Ставить будем на:

# uname -a
FreeBSD web 9.1-RELEASE FreeBSD 9.1-RELEASE #0 r243825: Tue Dec  4 09:23:10 UTC 2012     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64

Перед установкой желательно сразу обновить систему и порты.
Первым делом ставим Apache:

# whereis apache22
apache22: /usr/ports/www/apache22

Задать настройки для текущего порта и всех зависимостей, убираем везде галочку с IPV6 так, как его не используем:

# cd /usr/ports/www/apache22 && make config-recursive

Ставим командой:

# cd /usr/ports/www/apache22 && make install clean

Конфигурация во время установки:

┌───────────────────────────── apache22-2.2.24 ────────────────────────────────┐
│ ┌──────────────────────────────────────────────────────────────────────────┐ │
│ │ [x] AUTH_BASIC            mod_auth_basic                                 │ │
│ │ [x] AUTH_DIGEST           mod_auth_digest                                │ │
│ │ [x] AUTHN_ALIAS           mod_authn_alias                                │ │
│ │ [x] AUTHN_ANON            mod_authn_anon                                 │ │
│ │ [x] AUTHN_DBD             mod_authn_dbd                                  │ │
│ │ [x] AUTHN_DBM             mod_authn_dbm                                  │ │
│ │ [x] AUTHN_DEFAULT         mod_authn_default                              │ │
│ │ [x] AUTHN_FILE            mod_authn_file                                 │ │
│ │ [x] AUTHZ_DBM             mod_authz_dbm                                  │ │
│ │ [x] AUTHZ_DEFAULT         mod_authz_default                              │ │
│ │ [x] AUTHZ_GROUPFILE       mod_authz_groupfile                            │ │
│ │ [x] AUTHZ_HOST            mod_authz_host                                 │ │
│ │ [x] AUTHZ_OWNER           mod_authz_owner                                │ │
│ │ [x] AUTHZ_USER            mod_authz_user                                 │ │
│ │ [ ] AUTHNZ_LDAP           mod_authnz_ldap                                │ │
│ │ [ ] LDAP                  connection pooling, result caching             │ │
│ │ [x] DBD                   Manages SQL database connections               │ │
│ │ [x] CACHE                 mod_cache                                      │ │
│ │ [x] DISK_CACHE            mod_disk_cache                                 │ │
│ │ [x] FILE_CACHE            mod_file_cache                                 │ │
│ │ [x] MEM_CACHE             mod_mem_cache                                  │ │
│ │ [x] DAV                   mod_dav                                        │ │
│ │ [x] DAV_FS                mod_dav_fs                                     │ │
│ │ [ ] DAV_LOCK              mod_dav_lock                                   │ │
│ │ [x] ACTIONS               mod_actions                                    │ │
│ │ [x] ALIAS                 mod_alias                                      │ │
│ │ [x] ASIS                  mod_asis                                       │ │
│ │ [x] AUTOINDEX             mod_autoindex                                  │ │
│ │ [x] CERN_META             mod_cern_meta                                  │ │
│ │ [x] CGI                   mod_cgi                                        │ │
│ │ [x] CGID                  mod_cgid                                       │ │
│ │ [x] CHARSET_LITE          mod_charset_lite                               │ │
│ │ [x] DEFLATE               mod_deflate                                    │ │
│ │ [x] DIR                   mod_dir                                        │ │
│ │ [x] DUMPIO                mod_dumpio                                     │ │
│ │ [x] ENV                   mod_env                                        │ │
│ │ [x] EXPIRES               mod_expires                                    │ │
│ │ [x] HEADERS               mod_headers                                    │ │
│ │ [x] IMAGEMAP              mod_imagemap                                   │ │
│ │ [x] INCLUDE               mod_include                                    │ │
│ │ [x] INFO                  mod_info                                       │ │
│ │ [x] LOG_CONFIG            mod_log_config                                 │ │
│ │ [x] LOGIO                 mod_logio                                      │ │
│ │ [x] MIME                  mod_mime                                       │ │
│ │ [x] MIME_MAGIC            mod_mime_magic                                 │ │
│ │ [x] NEGOTIATION           mod_negotiation                                │ │
│ │ [x] REWRITE               mod_rewrite                                    │ │
│ │ [x] SETENVIF              mod_setenvif                                   │ │
│ │ [x] SPELING               mod_speling                                    │ │
│ │ [x] STATUS                mod_status                                     │ │
│ │ [x] UNIQUE_ID             mod_unique_id                                  │ │
│ │ [x] USERDIR               mod_userdir                                    │ │
│ │ [x] USERTRACK             mod_usertrack                                  │ │
│ │ [x] VHOST_ALIAS           mod_vhost_alias                                │ │
│ │ [x] FILTER                mod_filter                                     │ │
│ │ [ ] SUBSTITUTE            mod_substitute                                 │ │
│ │ [x] VERSION               mod_version                                    │ │
│ │ [x] SSL                   mod_ssl                                        │ │
│ │ [ ] SUEXEC                mod_suexec                                     │ │
│ │ [ ] SUEXEC_RSRCLIMIT      suEXEC rlimits based on login class            │ │
│ │ [ ] SUEXEC_USERDIR        suEXEC UserDir support                         │ │
│ │ [x] REQTIMEOUT            mod_reqtimeout                                 │ │
│ │ [ ] PROXY                 mod_proxy                                      │ │
│ │ [ ] IPV4_MAPPED           Allow IPv6 socket to handle IPv4               │ │
│ │ [ ] BUCKETEER             mod_bucketeer                                  │ │
│ │ [ ] CASE_FILTER           mod_case_filter                                │ │
│ │ [ ] CASE_FILTER_IN        mod_case_filter_in                             │ │
│ │ [ ] EXT_FILTER            mod_ext_filter                                 │ │
│ │ [ ] LOG_FORENSIC          mod_log_forensic                               │ │
│ │ [ ] OPTIONAL_HOOK_EXPORT  mod_optional_hook_export                       │ │
│ │ [ ] OPTIONAL_HOOK_IMPORT  mod_optional_hook_import                       │ │
│ │ [ ] OPTIONAL_FN_IMPORT    mod_optional_fn_import                         │ │
│ │ [ ] OPTIONAL_FN_EXPORT    mod_optional_fn_export                         │ │
│ │──────────────────────────────── mod_proxy ───────────────────────────────│ │
│ │ [ ] PROXY_AJP             mod_proxy_ajp                                  │ │
│ │ [ ] PROXY_BALANCER        mod_proxy_balancer                             │ │
│ │ [ ] PROXY_CONNECT         mod_proxy_connect                              │ │
│ │ [ ] PROXY_FTP             mod_proxy_ftp                                  │ │
│ │ [ ] PROXY_HTTP            mod_proxy_http                                 │ │
│ │ [ ] PROXY_SCGI            mod_proxy_scgi                                 │ │
│ └──────────────────────────────────────────────────────────────────────────┘ │
├──────────────────────────────────────────────────────────────────────────────┤
│                       < OK  >            < Cancel >                          │
└──────────────────────────────────────────────────────────────────────────────┘

Настройка
Проверяем наличие или добавляем строку в /etc/rc.conf:

apache22_enable="YES"
# echo 'apache22_enable="YES"' >> /etc/rc.conf

Редактируем файл /usr/local/etc/apache22/httpd.conf до такого вида:

ServerRoot "/usr/local"
#Listen 12.34.56.78:80
Listen 80

# Example:
# LoadModule foo_module modules/mod_foo.so
#
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 mem_cache_module libexec/apache22/mod_mem_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
LoadModule gzip_module       libexec/apache22/mod_gzip2.so
LoadModule php5_module        libexec/apache22/libphp5.so
LoadModule perl_module        libexec/apache22/mod_perl.so

<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>

User www
Group www

</IfModule>
</IfModule>

#ServerAdmin you@example.com
ServerName localhost:80
DocumentRoot "/usr/local/www/apache22/data"

<Directory />
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

<Directory "/usr/local/www/apache22/data">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

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

<FilesMatch "^.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
    DeflateCompressionLevel 9
    DeflateFilterNote Input instream
    DeflateFilterNote Output outstream
    DeflateFilterNote Ratio ratio
    LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
</IfModule>

ErrorLog "/var/log/httpd-error.log"
LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
    LogFormat "%h %l %u %t "%r" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i" %I %O" combinedio
    </IfModule>

    #CustomLog "/var/log/httpd-access.log" common
    CustomLog "/var/log/httpd-access.log" combined
</IfModule>

<IfModule alias_module>
    # Example:
    # Redirect permanent /foo http://www.example.com/bar
    # Alias /webpath /full/filesystem/path
    ScriptAlias /cgi-bin/ "/usr/local/www/apache22/cgi-bin/"
</IfModule>

<IfModule cgid_module>
    #Scriptsock /var/run/cgisock
</IfModule>

<Directory "/usr/local/www/apache22/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

DefaultType text/plain

<IfModule mime_module>
    TypesConfig etc/apache22/mime.types
    #AddType application/x-gzip .tgz
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddHandler cgi-script .cgi .pl
    #AddHandler type-map var
    #AddType text/html .shtml
    #AddOutputFilter INCLUDES .shtml
</IfModule>

#MIMEMagicFile etc/apache22/magic

# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html

#MaxRanges unlimited

#EnableMMAP off
#EnableSendfile off

# Supplemental configuration

Include etc/apache22/extra/httpd-mpm.conf
#Include etc/apache22/extra/httpd-multilang-errordoc.conf
#Include etc/apache22/extra/httpd-autoindex.conf
#Include etc/apache22/extra/httpd-languages.conf
#Include etc/apache22/extra/httpd-userdir.conf
Include etc/apache22/extra/httpd-info.conf
#Include etc/apache22/extra/httpd-vhosts.conf
#Include etc/apache22/extra/httpd-manual.conf
#Include etc/apache22/extra/httpd-dav.conf
Include etc/apache22/extra/httpd-default.conf

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

Include etc/apache22/Includes/*.conf

Редактируем файл /usr/local/etc/apache22/extra/httpd-mpm.conf до такого вида:

# Server-Pool Management (MPM specific)

<IfModule !mpm_netware_module>
    PidFile "/var/run/httpd.pid"
</IfModule>

<IfModule !mpm_winnt_module>
<IfModule !mpm_netware_module>
LockFile "/var/log/accept.lock"
</IfModule>
</IfModule>

<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   50
</IfModule>

<IfModule mpm_worker_module>
    StartServers          2
    MaxClients          150
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadsPerChild      25
    MaxRequestsPerChild   0
</IfModule>

<IfModule mpm_beos_module>
    StartThreads            10
    MaxClients              50
    MaxRequestsPerThread 10000
</IfModule>

<IfModule mpm_netware_module>
    ThreadStackSize      65536
    StartThreads           250
    MinSpareThreads         25
    MaxSpareThreads        250
    MaxThreads            1000
    MaxRequestsPerChild      0
    MaxMemFree             100
</IfModule>

<IfModule mpm_mpmt_os2_module>
    StartServers           2
    MinSpareThreads        5
    MaxSpareThreads       10
    MaxRequestsPerChild    0
</IfModule>

<IfModule mpm_winnt_module>
    ThreadsPerChild      150
    MaxRequestsPerChild    0
</IfModule>

Редактируем файл /usr/local/etc/apache22/extra/httpd-info.conf до такого вида:

<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
</Location>
ExtendedStatus On

#<Location /server-info>
#    SetHandler server-info
#    Order deny,allow
#    Deny from all
#    Allow from 127.0.0.1
#</Location>

Редактируем файл /usr/local/etc/apache22/extra/httpd-default.conf до такого вида:

Timeout 10
KeepAlive On
MaxKeepAliveRequests 80
KeepAliveTimeout 10
UseCanonicalName Off
AccessFileName .htaccess
ServerTokens Prod
ServerSignature On
HostnameLookups Off

Ставим PHP5 из портов:

# cd /usr/ports/lang/php5 && make config-recursive && make install clean

В окне выбираем:

┌─────────────────────────────── php5-5.4.14 ──────────────────────────────────┐
│ ┌──────────────────────────────────────────────────────────────────────────┐ │
│ │ [x] CLI        Build CLI version                                         │ │
│ │ [x] CGI        Build CGI version                                         │ │
│ │ [ ] FPM        Build FPM version                                         │ │
│ │ [x] APACHE     Build Apache module                                       │ │
│ │ [ ] AP2FILTER  Use Apache 2.x filter interface (experimental)            │ │
│ │ [ ] EMBED      Build embedded library                                    │ │
│ │ [ ] DEBUG      Enable debug                                              │ │
│ │ [ ] DTRACE     Enable DTrace support                                     │ │
│ │ [ ] IPV6       Enable ipv6 support                                       │ │
│ │ [ ] MAILHEAD   Enable mail header patch                                  │ │
│ │ [x] LINKTHR    Link thread lib (for threaded extensions)                 │ │
│ └──────────────────────────────────────────────────────────────────────────┘ │
├──────────────────────────────────────────────────────────────────────────────┤
│                       < OK  >            < Cancel >                         │
└──────────────────────────────────────────────────────────────────────────────┘

В конце видим:

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

Make sure index.php is part of your DirectoryIndex.

You should add the following to your Apache configuration file:

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

***************************************************************
===>   Compressing manual pages for php5-5.4.14
===>   Registering installation for php5-5.4.14
===> SECURITY REPORT:
      This port has installed the following files which may act as network
      servers and may therefore pose a remote security risk to the system.
/usr/local/libexec/apache22/libphp5.so
/usr/local/bin/php
/usr/local/bin/php-cgi

      If there are vulnerabilities in these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports included in the Ports Collection. Please type 'make deinstall'
      to deinstall the port if this is a concern.

      For more information, and contact details about the security
      status of this software, see the following webpage:
http://www.php.net/
===>  Cleaning for libxml2-2.8.0_2
===>  Cleaning for pkgconf-0.9.2
===>  Cleaning for php5-5.4.14
#

Php уже разрешен в конфиге как модуль, но его еще невозможно использовать. Для его использования нужно связать расширения файлов .php с правильным типом данных чтоб Apache знал для каких файлов запускать интерпретатор php.
Для этого создаём файл /usr/local/etc/apache22/Includes/php-application.conf с таким содержимым:

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phpsXsource

Ставим дополнительные модули для PHP

# cd /usr/ports/lang/php5-extensions && make config-recursive && make install clean

Выбираем всё необходимое:

┌─────────────────────────── php5-extensions-1.7 ──────────────────────────────┐
│ ┌──────────────────────────────────────────────────────────────────────────┐ │
│ │ [x] BCMATH        bc style precision math functions                      │ │
│ │ [x] BZ2           bzip2 library support                                  │ │
│ │ [x] CALENDAR      calendar conversion support                            │ │
│ │ [x] CTYPE         ctype functions                                        │ │
│ │ [x] CURL          CURL support                                           │ │
│ │ [x] DBA           dba support                                            │ │
│ │ [x] DOM           DOM support                                            │ │
│ │ [x] EXIF          EXIF support                                           │ │
│ │ [x] FILEINFO      fileinfo support                                       │ │
│ │ [x] FILTER        input filter support                                   │ │
│ │ [x] FTP           FTP support                                            │ │
│ │ [x] GD            GD library support                                     │ │
│ │ [x] GETTEXT       gettext library support                                │ │
│ │ [x] GMP           GNU MP support                                         │ │
│ │ [x] HASH          HASH Message Digest Framework                          │ │
│ │ [x] ICONV         iconv support                                          │ │
│ │ [x] IMAP          IMAP support                                           │ │
│ │ [ ] INTERBASE     Interbase 6 database support (Firebird)                │ │
│ │ [x] JSON          JavaScript Object Serialization support                │ │
│ │ [ ] LDAP          OpenLDAP support                                       │ │
│ │ [x] MBSTRING      multibyte string support                               │ │
│ │ [x] MCRYPT        Encryption support                                     │ │
│ │ [ ] MSSQL         MS-SQL database support                                │ │
│ │ [x] MYSQL         MySQL database support                                 │ │
│ │ [x] MYSQLI        MySQLi database support                                │ │
│ │ [ ] ODBC          ODBC support                                           │ │
│ │ [x] OPENSSL       OpenSSL support                                        │ │
│ │ [ ] PCNTL         pcntl support (CLI only)                               │ │
│ │ [x] PDF           PDFlib support (implies GD)                            │ │
│ │ [x] PDO           PHP Data Objects Interface (PDO)                       │ │
│ │ [ ] PDO_DBLIB     PDO DBLIB-DB driver                                    │ │
│ │ [ ] PDO_FIREBIRD  PDO Firebird driver                                    │ │
│ │ [x] PDO_MYSQL     PDO MySQL driver                                       │ │
│ │ [ ] PDO_ODBC      PDO ODBC driver                                        │ │
│ │ [ ] PDO_PGSQL     PDO PostgreSQL driver                                  │ │
│ │ [x] PDO_SQLITE    PDO sqlite driver                                      │ │
│ │ [ ] PGSQL         PostgreSQL database support                            │ │
│ │ [x] PHAR          phar support                                           │ │
│ │ [x] POSIX         POSIX-like functions                                   │ │
│ │ [ ] PSPELL        pspell support                                         │ │
│ │ [ ] READLINE      readline support (CLI only)                            │ │
│ │ [ ] RECODE        recode support                                         │ │
│ │ [x] SESSION       session support                                        │ │
│ │ [x] SHMOP         shmop support                                          │ │
│ │ [x] SIMPLEXML     simplexml support                                      │ │
│ │ [x] SNMP          SNMP support                                           │ │
│ │ [x] SOAP          SOAP support                                           │ │
│ │ [ ] SOCKETS       sockets support                                        │ │
│ │ [x] SQLITE3       sqlite3 support                                        │ │
│ │ [ ] SYBASE_CT     Sybase database support                                │ │
│ │ [ ] SYSVMSG       System V message support                               │ │
│ │ [ ] SYSVSEM       System V semaphore support                             │ │
│ │ [ ] SYSVSHM       System V shared memory support                         │ │
│ │ [ ] TIDY          TIDY support                                           │ │
│ │ [x] TOKENIZER     tokenizer support                                      │ │
│ │ [ ] WDDX          WDDX support (implies XML)                             │ │
│ │ [x] XML           XML support                                            │ │
│ │ [x] XMLREADER     XMLReader support                                      │ │
│ │ [ ] XMLRPC        XMLRPC-EPI support                                     │ │
│ │ [x] XMLWRITER     XMLWriter support                                      │ │
│ │ [ ] XSL           XSL support (Implies DOM)                              │ │
│ │ [x] ZIP           ZIP support                                            │ │
│ │ [x] ZLIB          ZLIB support                                           │ │
│ └──────────────────────────────────────────────────────────────────────────┘ │
├──────────────────────────────────────────────────────────────────────────────┤
│                       < OK  >            < Cancel >                         │
└──────────────────────────────────────────────────────────────────────────────┘

Там где была галочка на IPV6 я отключал так, как он не используется.

Настройка php.ini

# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
# chmod u+w /usr/local/etc/php.ini
# rehash

Редактируем php.ini до такого вида:

[PHP]
engine = On
short_open_tag = On
asp_tags = Off
precision = 14
y2k_compliance = On
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = 100
allow_call_time_pass_reference = Off
safe_mode = Off
safe_mode_gid = Off
safe_mode_include_dir =
safe_mode_exec_dir =
safe_mode_allowed_env_vars = PHP_
safe_mode_protected_env_vars = LD_LIBRARY_PATH
disable_functions =
disable_classes =
expose_php = Off
max_execution_time = 300
max_input_time = 300
memory_limit = 128M
error_reporting = E_ALL | E_STRICT
display_errors = On
display_startup_errors = On
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = On
html_errors = On
variables_order = "GPCS"
request_order = "GP"
register_globals = Off
register_long_arrays = Off
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 512M
magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
include_path = ".:/usr/local/share/pear"
doc_root =
user_dir =
enable_dl = Off
file_uploads = On
upload_max_filesize = 512M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60

[Date]
date.timezone = Europe/Kiev

[filter]

[iconv]

[intl]

[sqlite]

[sqlite3]

[Pcre]

[Pdo]

[Pdo_mysql]
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket=

[Phar]

[Syslog]
define_syslog_variables  = Off

[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = On

[SQL]
sql.safe_mode = Off

[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1

[Interbase]
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ibase.dateformat = "%Y-%m-%d"
ibase.timeformat = "%H:%M:%S"

[MySQL]
mysql.allow_local_infile = On
mysql.allow_persistent = On
mysql.cache_size = 2000
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off

[MySQLi]
mysqli.max_persistent = -1
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off

[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = On

[OCI8]

[PostgresSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0

[Sybase-CT]
sybct.allow_persistent = On
sybct.max_persistent = -1
sybct.max_links = -1
sybct.min_server_severity = 10
sybct.min_client_severity = 10

[bcmath]
bcmath.scale = 0

[browscap]

[Session]
session.save_handler = files
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.bug_compat_42 = On
session.bug_compat_warn = On
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"

[MSSQL]
mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatability_mode = Off
mssql.secure_connection = Off

[Assertion]

[COM]

[mbstring]

[gd]

[exif]

[Tidy]
tidy.clean_output = Off

[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5

[sysvshm]

[ldap]
ldap.max_links = -1

[mcrypt]

[dba]

Ставим ещё:

# cd /usr/ports/net/pecl-geoip && make install clean
# cd /usr/ports/devel/pear && make install clean
# cd /usr/ports/databases/pear-DB && make install clean
# cd /usr/ports/www/mod_gzip2 && make install clean
# cd /usr/ports/www/mod_perl2 && make install clean

После установки mod_perl2 нужно раскомментировать строку в /usr/local/etc/apache22/httpd.conf

LoadModule perl_module        libexec/apache22/mod_perl.so

Запускаем

# /usr/local/etc/rc.d/apache22 start

Проверяем что сервер запустился и работает

# ps ax | grep httpd
 7011    ??  I        0:21.67 /usr/local/sbin/httpd
10909    ??  I        0:04.50 /usr/local/sbin/httpd
12521    ??  I        0:04.34 /usr/local/sbin/httpd
12675    ??  I        0:02.18 /usr/local/sbin/httpd
34170    ??  I        0:05.47 /usr/local/sbin/httpd
76421    ??  Ss       0:03.26 /usr/local/sbin/httpd
99267    ??  I        0:10.91 /usr/local/sbin/httpd
14536     2  R+       0:00.00 grep httpd

Если при запуске появится ошибка, смотрим /var/log/httpd-error.log

# tail -f /var/log/httpd-error.log
[Sat Apr 27 06:03:33 2013] [alert] (EAI 8)hostname nor servname provided, or not known: mod_unique_id: unable to find IPv4 address of "web"
Configuration Failed

Лезем в /etc/hosts и добавляем свой ip адрес и имя которое указали в /etc/rc.conf (у меня — hostname=»web»):

127.0.0.1               localhost localhost.my.domain
xxx.xxx.xxx.xxx         web

Проверяем работу сервера:

# /usr/local/etc/rc.d/apache22 start
# tail -f /var/log/httpd-error.log
[Sat Apr 27 06:03:33 2013] [alert] (EAI 8)hostname nor servname provided, or not known: mod_unique_id: unable to find IPv4 address of "web"
Configuration Failed
[Sat Apr 27 06:07:00 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sat Apr 27 06:07:00 2013] [notice] Digest: generating secret for digest authentication ...
[Sat Apr 27 06:07:00 2013] [notice] Digest: done
[Sat Apr 27 06:07:01 2013] [notice] Apache/2.2.24 (FreeBSD) mod_gzip/2.1.0 PHP/5.4.14 mod_ssl/2.2.24 OpenSSL/0.9.8y DAV/2 configured -- resuming normal operations
http://ip.сервера/

Проверить работу php можно так, в корневой папке веб сервера /usr/local/www/apache22/data/ создать файл test.php

touch /usr/local/www/apache22/data/test.php

и вписать такое содержимое:

<?php>
phpinfo();
?>

После заходим по адресу http://ip.сервера/test.php мы должны увидеть такое
phpinfo

Оставить комментарий