Данная статья изначально являлась переработанной инструкцией по установке и настройке програмного обеспечения для организации собственного веб-сервера. Она много раз перерабатывалась в зависимости от нужд, менялись настройки, парметры конфигурации, версии программ. И в результате получился вот такой вот небольшой User Guide =)
Подготовка к развертке:
- Создаем директории
shell код:
cd ~
mkdir src
cd src
- Добавляем пользователей:
shell код:
pw groupadd mysql
pw useradd mysql -g mysql
pw groupadd postgres
pw useradd postgres -g postgres
Забираем дистрибутивы:
Apache 1.3.41
shell код:
fetch http://www.sai.msu.su/apache/httpd/apache_1.3.41.tar.gz
И сразу же к нему модули:
- mod_security 1.9.5
shell код:
fetch http://www.modsecurity.org/download/modsecurity-apache_1.9.5.tar.gz
- mod_perl (Последняя версия на момент статьи - 1.31)
shell код:
fetch http://perl.apache.org/dist/mod_perl-1.0-current.tar.gz
- mod_ssl (если требуется)
shell код:
fetch http://www.modssl.org/source/mod_ssl-2.8.31-1.3.41.tar.gz
PHP 5.2.12 (из соображений безопасности)
shell код:
fetch -o php-5.2.12.tar.gz http://ru2.php.net/get/php-5.2.12.tar.gz/from/this/mirror
Если нужна более ранняя версия:
-
4.4.9 shell код:
fetch http://ru2.php.net/distributions/php-4.4.9.tar.gz
Если же нужна более поздняя:
-
5.3.1 shell код:
fetch -o php-5.3.1.tar.gz http://ru2.php.net/get/php-5.3.1.tar.gz/from/this/mirror
MySQL 5.0.89 (из соображений безопасности)
shell код:
fetch http://ftp.heanet.ie/mirrors/www.mysql.com/Downloads/MySQL-5.0/mysql-5.0.89.tar.gz
Если нужна более ранняя версия:
-
3.23 shell код:
fetch http://mirror.provenscaling.com/mysql/community/source/3.23/mysql-3.23.58.tar.gz
-
4.0 shell код:
fetch http://mirror.provenscaling.com/mysql/community/source/4.0/mysql-4.0.30.tar.gz
-
4.1 shell код:
fetch http://mysql.mix.su/Downloads/MySQL-4.1/mysql-4.1.22.tar.gz
Если же более поздняя:
-
5.1 shell код:
fetch http://ftp.heanet.ie/mirrors/www.mysql.com/Downloads/MySQL-5.1/mysql-5.1.42.tar.gz
-
5.2 shell код:
fetch http://ftp.heanet.ie/mirrors/www.mysql.com/Downloads/MySQL-5.2/mysql-5.2.3-falcon-alpha.tar.gz
-
5.4 shell код:
fetch http://ftp.heanet.ie/mirrors/www.mysql.com/Downloads/MySQL-5.4/mysql-5.4.3-beta.tar.gz
-
5.5 shell код:
fetch http://ftp.heanet.ie/mirrors/www.mysql.com/Downloads/MySQL-5.5/mysql-5.5.0-m2.tar.gz
-
6.0 shell код:
fetch http://ftp.heanet.ie/mirrors/www.mysql.com/Downloads/MySQL-6.0/mysql-6.0.11-alpha.tar.gz
PostgreSQL 8.4.2
shell код:
fetch
http://ftp.dk.postgresql.org/postgresql/source/v8.4.2/postgresql-8.4.2.tar.gz
или предыдущая версия
shell код:
fetch
http://ftp.dk.postgresql.org/postgresql/source/v8.3.9/postgresql-8.3.9.tar.gz
Теперь получаем модули Perl для работы с базами данных:
DBI 1.609
shell код:
fetch http://search.cpan.org/CPAN/authors/id/T/TI/TIMB/DBI-1.609.tar.gz
DBD::mysql 4.013
shell код:
fetch http://search.cpan.org/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.013.tar.gz
DBD::Pg 2.16.0
shell код:
fetch http://search.cpan.org/CPAN/authors/id/T/TU/TURNSTEP/DBD-Pg-2.16.0.tar.gz
Для данного модуля требуется установленный модуль version. Если его нет, получаем:
-
version 0.78
shell код:
fetch http://search.cpan.org/CPAN/authors/id/J/JP/JPEACOCK/version-0.78.tar.gz
Для нормальной работы mod_perl с базами данных также требуется модуль:
Apache::DBI 1.0.7
Установить его можно как из портов:
shell код:
cd /usr/ports/www/p5-Apache-DBI
make
make install
или из исходников:
shell код:
fetch http://search.cpan.org/CPAN/authors/id/P/PG/PGOLLUCCI/Apache-DBI-1.07.tar.gz
Распаковываем все архивы:
shell код:
tar -xvf apache_1.3.41.tar.gz
tar -xvf mod_ssl-2.8.31-1.3.41.tar.gz
tar -xvf modsecurity-apache_1.9.5.tar.gz
tar -xvf mod_perl-1.0-current.tar.gz
tar -xvf php-5.3.1.tar.gz
tar -xvf mysql-4.0.30.tar.gz
tar -xvf postgresql-8.4.2.tar.gz
tar -xvf DBI-1.609.tar.gz
tar -xvf DBD-mysql-4.013.tar.gz
tar -xvf DBD-Pg-2.16.0.tar.gz
tar -xvf version-0.78.tar.gz
[Опционально] Установка модуля mod_ssl:
Забираем библиотеки OpenSSL:
shell код:
fetch http://www.openssl.org/source/openssl-0.9.8l.tar.gz
Собираем
OpenSSL:
shell код:
tar -xvf openssl-0.9.8l.tar.gz
cd openssl-0.9.8l
sh config no-idea threads zlib -fPIC
make depend
make
make test
make install
Внедряем модуль
mod_ssl в исходные коды Apache:
shell код:
cd ../mod_ssl-2.8.31-1.3.41
./configure --with-apache=../apache_1.3.41 --with-ssl=../openssl-0.9.8l --prefix=/usr/local/apache
cd ..
Внедряем модуль
mod_security в исходные коды Apache:
shell код:
cp modsecurity-apache_1.9.5/apache1/mod_security.c apache_1.3.41/src/modules/extra
Конфигурируем
Apache:
shell код:
cd apache_1.3.41
./configure \
--prefix=/usr/local/apache \
--bindir=/usr/bin --sbindir=/usr/sbin \
--sysconfdir=/usr/local/apache/conf \
--logfiledir=/var/log/apache \
--datadir=/usr/local/apache/data
Устанавливаем
MySQL с поддержкой кодировки cp1251:
shell код:
cd ../mysql-5.0.89
./configure \
--prefix=/usr/local/mysql \
--localstatedir=/usr/local/mysql/var \
--with-charset=cp1251 \
--with-collation=cp1251_general_ci \
--with-extra-charset=all \
--without-debug \
--without-benchmark \
--with-mysqld-user=mysql
make
make test
make install
cp support-files/my-medium.cnf /etc/my.cnf
./scripts/mysql_install_db
chown -R mysql:mysql /usr/local/mysql
/usr/local/etc/rc.d/mysql-server start
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
Устанавливаем
PostgreSQL:
shell код:
cd ../postgresql-8.4.2
./configure \
--prefix=/usr/local/pgsql \
--localstatedir=/usr/local/pgsql/var \
--with-template=freebsd \
--with-perl
make
make install
mkdir /usr/local/pgsql/var
chown -R postgres:postgres /usr/local/pgsql
Сразу же установим перловые модули для работы с базами:
- DBI
shell код:
cd ../DBI-1.609
perl Makefile.PL
make
make test
make install
- DBD::mysql
shell код:
cd ../DBD-mysql-4.013
perl Makefile.PL \
--mysql_config=/usr/local/mysql/bin/mysql_config \
--cflags='-I/usr/local/mysql/include/mysql -lmysqlclient -lz -lcrypt -lm' \
--libs=-L/usr/local/mysql/lib/mysql \
--testhost=localhost \
--testuser=root
make
make test
make install
- DBD::Pg
shell код:
cd ..
tar -xvf version-0.78.tar.gz
cd version-0.78
perl Makefile.PL
make
make test
make install
cd ../DBD-Pg-2.16.0
perl Makefile.PL
make
make test
make install
- Apache::DBI
shell код:
cd ../Apache-DBI-1.07
perl Makefile.PL
make
make test
make install
Устанавливаем
PHP:
shell код:
cd ../php-5.2.12
./configure \
--prefix=/usr \
--enable-zip \
--enable-mbstring \
--enable-safe-mode \
--enable-inline-optimization \
--disable-debug \
--with-apache=../apache_1.3.41 \
--with-config-file-path=/usr/local/apache/conf \
--with-zlib \
--with-pgsql \
--with-gnu-ld \
--with-mysqli \
--with-mysql=/usr/local/mysql \
--with-bz2=/usr/local/include \
--with-zlib-dir=/usr/local/include \
--with-mcrypt=/usr/local/include
make
make test
make install
Устанавливаем
mod_perl:
shell код:
cd ../mod_perl-1.31
perl Makefile.PL APACHE_SRC=../apache_1.3.41/src DO_HTTPD=1 USE_APACI=1 PREF_HTTPD=1 EVERYTHING=1
make
make test
make install
Все готово к компиляции
Apache:
Сначала конфигурируем его. Для этого я создал небольшой скрипт myconfig.sh:
shell код:
#!/bin/sh
./configure --bindir=/usr/bin \
--sbindir=/usr/sbin \
--localstatedir=/var \
--runtimedir=/var/run \
--prefix=/usr/local/apache \
--logfiledir=/var/log/apache \
--datadir=/usr/local/apache/data \
--sysconfdir=/usr/local/apache/conf \
--activate-module=src/modules/php5/libphp5.a \
--activate-module=src/modules/perl/libperl.a \
--activate-module=src/modules/extra/mod_security \
--disable-module=all \
--enable-module=cgi \
--enable-module=dir \
--enable-module=ssl \
--enable-module=mime \
--enable-module=perl \
--enable-module=php5 \
--enable-module=alias \
--enable-module=access \
--enable-module=rewrite \
--enable-module=security \
--enable-module=log_config \
--enable-module=negotiation
Запускаем его и приступаем к установке:
shell код:
cd ../apache_1.3.41
./myconfig.sh
make
make certificate TYPE=custom
make install
На этом установку можно считать завершенной.
Материалы по теме:
http://www.opennet.ru/base/sys/apache_tune_bsd.txt.html
Статус статьи: Релиз, обновлена 10.01.2010.