Установка apache из исходников для FreeBSD
Установка необходимого ПО.
Перед началом сборки нужно установить некоторые dependencies (зависимости). Следующее ПО необходимо для конфига описанного немного ниже:
Буду использовать программу portupgrade, у меня она не была установлена на моем сервере FreeBSD, по этому я поставил следующим образом:
# pkg_add –r portupgrade
или
# cd /usr/ports/ports-mgmt/portupgrade # make config && make install clean
GD2 — библиотека которая используется в PHP для работы с изображениями, мне она была нужно по этому я ее установил за раннее:
# portinstall gd
MySQL
Установку MySQl можете перейдя по ссылке (См. Установку MySQl)
PCRE — библиотека, реализующая работу регулярных выражений в стиле Perl.
# portinstall pcre
libXML — Этот модуль представляет собой интерфейс для гномов libxml2 DOM и SAX парсер и DOM дерева.
# portinstall libxml2
APR (Apache Portable Runtime) — является кросс-платформенной оберткой над рядом API в той или иной степени представленных в ОС. В случае, если операционная система не поддерживает нужной функциональности, APR обеспечивает её эмуляцию для поддержки кросс — платформености.
# cd /usr/ports/devel/apr1 # make install clean
Установка apache из исходников для FreeBSD
Пожалуй перед компиляцией я создам папку и туда буду скачивать исходный код программ:
# mkdir /usr/src # mkdir /usr/local/src
Установим права на папку 700 (владелец может читать, записывать и запускать на выполнение; никто другой не имеет права выполнять никакие действия):
# chown 700 root:wheel /usr/src # chown 700 root:wheel /usr/local/src/
Перейдем в директорию src:
# cd /usr/local/src
Для начала нам нужно зайти на сайт apache и скачать нужный архив для дальнейшего использования. Мне нужно было установить именно apache-2.2.5 и по этому я выполнил:
# fetch http://apache.rinet.ru/dist/httpd/httpd-2.2.25.tar.gz
Нужно теперь распаковать архив httpd-2.2.25.tar.gz:
# tar –xjf httpd-2.2.25.tar.gz
Можно скачать и apache-2.4.6, если кому нужно, то можете выполнить:
# fetch http://apache.rinet.ru/dist/httpd/httpd-2.4.6.tar.gz
# tar –xjf httpd-2.4.6.tar.gz
!!!!! Перед началом конфигурации и сборки нужно добавить в систему пользователя, для удобства я назвал — apache!!!
Добавим пользователя apache в его группу.
# pw groupadd apache
Создадим пользователя.
# pw useradd apache -c "Apache Server" -d /dev/null -g apache -s /sbin/nologin
Перейдем в распакованный архив апача и начнем компиляцию:
# cd /usr/local/src/httpd-2.2.25
Нужно прочитать файл README перед началом, в нем рассказывается как установить апач (собрать конфигур), мой выглядит так:
./configure \ --prefix=/usr/local/apache2 \ --enable-so \ --enable-vhost-alias \ --enable-cgi \ --enable-info \ --enable-rewrite \ --enable-speling \ --enable-usertrack \ --enable-deflate \ --enable-ssl \ --enable-ftp \ --enable-mime-magic \ --enable-auth-digest \ --with-mpm=prefork
# make; umask 022; make install
# chown -R root:wheel /usr/local/apache2
Добавим сервис в /etc/rc.conf:
# echo 'apache22_enable="YES"' >> /etc/rc.conf
Стартанем пожалуй:
# /usr/local/apache2/bin/apachectl start
Проверить состояние можно так:
# ps aux | grep httpd
Автозагрузка apache:
Перейдем в rc.d и создадим файлик httpd.sh:
# cd /usr/local/etc/rc.d # ee httpd.sh
# Скрипт для автозапуска apache по теме "Установка apache из исходников для FreeBSD" #!/bin/sh # case "$1" in start) /usr/local/apache2/bin/apachectl startssl ;; stop) /usr/local/apache2/bin/apachectl stop ;; restart) $0 stop && sleep 3 $0 start ;; reload) $0 stop $0 start ;; *) echo "Usage: $0 {start|stop|restart|reload}" exit 1 esac
Установим права на файл.
# chmod 755 /usr/local/etc/rc.d/httpd.sh
# /usr/local/etc/rc.d/httpd.sh start
Посмотрим запустился ли апач:
# ps aux | grephttpd
# pw adduser captain -m -d /home/captain -c "user captain" # passwd captain
Создадим пару папок и установлю я права, в нем будут лежать файлы с сайтом (для примера создал ‘test.com’):
# mkdir /home/captain/www # mkdir /home/captain/www/test.com # chown -R root:wheel /home/captain/www
Вся конфигурация apache лежит в папке conf, и нужно отредактировать пару строк в файле httpd.conf:
# ee /usr/local/apache2/conf/httpd.cof
Конфигурация httpd.conf (У Вас может отличаться от моей, но не на многое):
# Конфинг для "Установка apache из исходников для FreeBSD" # This is the main Apache HTTP server configuration file. It contains the # configuration directives that give the server its instructions. # See <URL:http://httpd.apache.org/docs/2.2> for detailed information. # In particular, see # <URL:http://httpd.apache.org/docs/2.2/mod/directives.html> # for a discussion of each configuration directive. # # Do NOT simply read the instructions in here without understanding # what they do. They're here only as hints or reminders. If you are unsure # consult the online docs. You have been warned. # # Configuration and logfile names: If the filenames you specify for many # of the server's control files begin with "/" (or "drive:/" for Win32), the # server will use that explicit path. If the filenames do *not* begin # with "/", the value of ServerRoot is prepended -- so "logs/foo_log" # with ServerRoot set to "/usr/local/apache2" will be interpreted by the # server as "/usr/local/apache2/logs/foo_log". # # ServerRoot: The top of the directory tree under which the server's # configuration, error, and log files are kept. # # Do not add a slash at the end of the directory path. If you point # ServerRoot at a non-local disk, be sure to point the LockFile directive # at a local disk. If you wish to share the same ServerRoot for multiple # httpd daemons, you will need to change at least LockFile and PidFile. # ServerRoot "/usr/local/apache2" # # Listen: Allows you to bind Apache to specific IP addresses and/or # ports, instead of the default. See also the <VirtualHost> # directive. #Установка apache из исходников для FreeBSD # Change this to Listen on specific IP addresses as shown below to # prevent Apache from glomming onto all bound IP addresses. # #Listen 12.34.56.78:80 #Listen 80 Listen 111.111.111.111:80 # Ваш ИП ставим # # Dynamic Shared Object (DSO) Support # # To be able to use the functionality of a module which was built as a DSO you # have to place corresponding `LoadModule' lines at this location so the # directives contained in it are actually available _before_ they are used. # Statically compiled modules (those listed by `httpd -l') do not need # to be loaded here. # # Example: # LoadModule foo_module modules/mod_foo.so LoadModule php5_module modules/libphp5.so # собственно либа для использования PHP LoadModule rpaf_module modules/mod_rpaf-2.0.so # # # If you wish httpd to run as a different user or group, you must run # httpd as root initially and it will switch. # # User/Group: The name (or #number) of the user/group to run httpd as. # It is usually good practice to create a dedicated user and group for # running httpd, as with most system services. # User apache Group apache # 'Main' server configuration # # The directives in this section set up the values used by the 'main' # server, which responds to any requests that aren't handled by a # <VirtualHost> definition. These values also provide defaults for # any <VirtualHost> containers you may define later in the file. # # All of these directives may appear inside <VirtualHost> containers, # in which case these default settings will be overridden for the # virtual host being defined. # # # ServerAdmin: Your address, where problems with the server should be # e-mailed. This address appears on some server-generated pages, such # as error documents. e.g. admin@your-domain.com # ServerAdmin root@admin.com # admin email # # ServerName gives the name and port that the server uses to identify itself. # This can often be determined automatically, but we recommend you specify # it explicitly to prevent problems during startup. # # If your host doesn't have a registered DNS name, enter its IP address here. # #ServerName www.example.com:80 # # DocumentRoot: The directory out of which you will serve your # documents. By default, all requests are taken from this directory, but # symbolic links and aliases may be used to point to other locations. # DocumentRoot "/usr/local/apache2/htdocs" # # Each directory to which Apache has access can be configured with respect # to which services and features are allowed and/or disabled in that # directory (and its subdirectories). #Установка apache из исходников для FreeBSD # First, we configure the "default" to be a very restrictive set of # features. # <Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Allow from all </Directory> # # ATTENTION! Every account must have same section # <Directory "/usr/home/captain/"> Options FollowSymLinks Includes AllowOverride All Order deny,allow Allow from all </Directory> # # Note that from this point forward you must specifically allow # particular features to be enabled - so if something's not working as # you might expect, make sure that you have specifically enabled it # below. # # # This should be changed to whatever you set DocumentRoot to. # <Directory "/usr/local/apache2/htdocs"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.2/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None # # Controls who can get stuff from this server. # Order allow,deny Allow from all </Directory> # # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # <IfModule dir_module> DirectoryIndex index.html index.shtml index.htm index.php </IfModule> # # The following lines prevent .htaccess and .htpasswd files from being # viewed by Web clients. # <FilesMatch "^\.ht"> Order allow,deny Deny from all Satisfy All </FilesMatch> # # ErrorLog: The location of the error log file. # If you do not specify an ErrorLog directive within a <VirtualHost> # container, error messages relating to that virtual host will be # logged here. If you *do* define an error logfile for a <VirtualHost> # container, that host's errors will be logged there and not here. # ErrorLog "/var/log/httpd/error_log" # # LogLevel: Control the number of messages logged to the error_log. # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. # LogLevel crit <IfModule log_config_module> # # The following directives define some format nicknames for use with # a CustomLog directive (see below). # LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common # # The location and format of the access logfile (Common Logfile Format). # If you do not define any access logfiles within a <VirtualHost> # container, they will be logged here. Contrariwise, if you *do* # define per-<VirtualHost> access logfiles, transactions will be # logged therein and *not* in this file. # #CustomLog "/var/log/httpd/access_log" common # # If you prefer a logfile with access, agent, and referer information # (Combined Logfile Format) you can use the following directive. # #CustomLog "/var/log/httpd/access_log" combined </IfModule> # # DefaultType: the default MIME type the server will use for a document # if it cannot otherwise determine one, such as from filename extensions. # If your server contains mostly text or HTML documents, "text/plain" is # a good value. If most of your content is binary, such as applications # or images, you may want to use "application/octet-stream" instead to # keep browsers from trying to display binary files as though they are # text. # DefaultType text/plain <IfModule mime_module> # # TypesConfig points to the file containing the list of mappings from # filename extension to MIME-type. # TypesConfig conf/mime.types # # AddType allows you to add to or override the MIME configuration # file specified in TypesConfig for specific file types. # #AddType application/x-gzip .tgz # # AddEncoding allows you to have certain browsers uncompress # information on the fly. Note: Not all browsers support this. # #AddEncoding x-compress .Z #AddEncoding x-gzip .gz .tgz # # If the AddEncoding directives above are commented-out, then you # probably should define those extensions to indicate media types: # AddType application/x-compress .Z AddType application/x-gzip .gz .tgz # # AddHandler allows you to map certain file extensions to "handlers": # actions unrelated to filetype. These can be either built into the server # or added with the Action directive (see below) # # To use CGI scripts outside of ScriptAliased directories: # (You will also need to add "ExecCGI" to the "Options" directive.) # AddHandler cgi-script .cgi # For type maps (negotiated resources): #AddHandler type-map var # # Filters allow you to process content before it is sent to the client. # # To parse .shtml files for server-side includes (SSI): # (You will also need to add "Includes" to the "Options" directive.) # AddType text/html .shtml AddOutputFilter INCLUDES .shtml # PHP AddType application/x-httpd-php .php AddType application/x-httpd-php .inc AddType application/x-httpd-php .class </IfModule> # # The mod_mime_magic module allows the server to use various hints from the # contents of the file itself to determine its type. The MIMEMagicFile # directive tells the module where the hint definitions are located. # #MIMEMagicFile conf/magic # # Customizable error responses come in three flavors: # 1) plain text 2) local redirects 3) external redirects # # 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 # # # EnableMMAP and EnableSendfile: On systems that support it, # memory-mapping or the sendfile syscall is used to deliver # files. This usually improves server performance, but must # be turned off when serving from networked-mounted # filesystems or if support for these functions is otherwise # broken on your system. # EnableMMAP off EnableSendfile on AcceptFilter http httpready # Supplemental configuration # Various default settings # Timeout: The number of seconds before receives and sends time out. # Timeout 30 # # KeepAlive: Whether or not to allow persistent connections (more than # one request per connection). Set to "Off" to deactivate. # KeepAlive On # Установка apache из исходников для FreeBSD # MaxKeepAliveRequests: The maximum number of requests to allow # during a persistent connection. Set to 0 to allow an unlimited amount. # We recommend you leave this number high, for maximum performance. # MaxKeepAliveRequests 100 # # KeepAliveTimeout: Number of seconds to wait for the next request from the # same client on the same connection. # KeepAliveTimeout 5 # # UseCanonicalName: Determines how Apache constructs self-referencing # URLs and the SERVER_NAME and SERVER_PORT variables. # When set "Off", Apache will use the Hostname and Port supplied # by the client. When set "On", Apache will use the value of the # ServerName directive. # UseCanonicalName Off # # AccessFileName: The name of the file to look for in each directory # for additional configuration directives. See also the AllowOverride # directive. # AccessFileName .htaccess # # ServerTokens # This directive configures what you return as the Server HTTP response # Header. The default is 'Full' which sends information about the OS-Type # and compiled in modules. # Set to one of: Full | OS | Minor | Minimal | Major | Prod # where Full conveys the most information, and Prod the least. # ServerTokens Prod # # Optionally add a line containing the server version and virtual host # name to server-generated pages (internal error documents, FTP directory # listings, mod_status and mod_info output etc., but not CGI generated # documents or custom error documents). # Set to "EMail" to also include a mailto: link to the ServerAdmin. # Set to one of: On | Off | EMail # ServerSignature Off # # HostnameLookups: Log the names of clients or just their IP addresses # e.g., www.apache.org (on) or 204.62.129.132 (off). # The default is off because it'd be overall better for the net if people # had to knowingly turn this feature on, since enabling it means that # each client request will result in AT LEAST one lookup request to the # nameserver. # HostnameLookups Off # Server-pool management (MPM specific) # PidFile logs/httpd.pid LockFile logs/accept.lock # worker MPM # StartServers: initial number of server processes to start # MaxClients: maximum number of simultaneous client connections # MinSpareThreads: minimum number of worker threads which are kept spare # MaxSpareThreads: maximum number of worker threads which are kept spare # ThreadsPerChild: constant number of worker threads in each server process # MaxRequestsPerChild: maximum number of requests a server process serves <IfModule mpm_worker_module> ServerLimit 256 ThreadLimit 128 StartServers 40 MaxClients 4096 MinSpareThreads 60 MaxSpareThreads 90 ThreadsPerChild 128 MaxRequestsPerChild 9000 </IfModule> # prefork MPM # StartServers: number of server processes to start # MinSpareServers: minimum number of server processes which are kept spare # MaxSpareServers: maximum number of server processes which are kept spare # MaxClients: maximum number of server processes allowed to start # MaxRequestsPerChild: maximum number of requests a server process serves <IfModule mpm_prefork_module> ServerLimit 2048 StartServers 100 MinSpareServers 60 MaxSpareServers 90 MaxClients 2048 MaxRequestsPerChild 10000 </IfModule> # # Real-time info on requests and configuration # <Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from 111.18.97.175 # Разрешено смотреть status сервера </Location> # # phpMyAdmin # <Location /AwieV9ph> php_admin_flag file_uploads On php_admin_value upload_max_filesize 20M php_admin_value post_max_size 20M </Location> ExtendedStatus Off # Virtual hosts
Отредактируем vhost.conf и добавим свои сайты:
RPAFEnable On RPAFproxy_ips 127.0.0.1 RPAFheader X-Real-IP Listen 127.0.0.1:80 NameVirtualHost 127.0.0.1:80 <VirtualHost 127.0.0.1:80 > DocumentRoot /usr/home/captain/test.com/www #Установка apache из исходников для FreeBSD ServerAdmin webmaster@test.com ServerName test.com ServerAlias www.test.com ScriptAlias /cgi-bin/ /usr/home/captain/test.com/cgi-bin/ </VirtualHost> <VirtualHost 127.0.0.1:80 > DocumentRoot /usr/home/captain/test2.com/www ServerAdmin webmaster@test2.com ServerName test2.com ServerAlias www.test2.com ScriptAlias /cgi-bin/ /usr/home/captain/test2.com/cgi-bin/ </VirtualHost> <VirtualHost 127.0.0.1:80 > DocumentRoot /usr/home/captain/test3.com/www ServerAdmin webmaster@test3.com ServerName test3.com ServerAlias www.test3.com ScriptAlias /cgi-bin/ /usr/home/captain/test3.com/cgi-bin/ </VirtualHost>
Смотрите так же:
Установка PHP для FreeBSD из исходников (руководство по установке)
Установка apache из исходников для FreeBSD завершена.
ошибки надо исправлять
I see a lot of interesting articles on your page.
You have to spend a lot of time writing, i know how to save you a lot of work,
there is a tool that creates unique, google friendly posts in couple of seconds, just search in google
— laranita’s free content source