AgiliaLinux: настройка Apache
Пишет, Nikita, 16.01.2012Недавно решил на своей рабочей машине реализовать такие более устойчивую схему сервера, чем «Сервер за 5 мин на Ubuntu». Походу экспериментов над Agilia, стал ставить на ней.
Устанавливаем всё, что надо:
mpkg install httpd mysql php
Настроить /etc/httpd/httpd.conf:
-
<IfModule dir_module>
-
DirectoryIndex index.html index.htm
-
</IfModule>
Заменить на
-
<IfModule dir_module>
-
DirectoryIndex index.html index.htm index.php
-
</IfModule>
Строку
-
#Include /etc/httpd/mod_php.conf
раскомментрировать
что было
-
Include /etc/httpd/mod_php.conf
Строку:
-
#Include /etc/httpd/extra/httpd-vhosts.conf
так же раскомментировать
Строку:
-
#ServerName www.example.com:80
заменить на
-
ServerName localhost
Добавить ниже строку:
-
NameVirtualHost *:80
Создаём каталоги и файлы, делаем их читаемыми и записываемыми группе, в которой запущен apache, либо всем, если не страшно.
/home/nikita/server/domain/www
/home/nikita/server/domain/log/error.log
/home/nikita/server/domain/log/custom.log
/home/nikita/server/localhost/www
/home/nikita/server/localhost/log/error.log
/home/nikita/server/localhost/log/custom.log
В данном примере: domain — имя нашего домена
Путь и структуру каталогов вы можете выбрать сами. Для меня удобней такая.
В файле:
/etc/httpd/extra/httpd-vhosts.conf
добавляем 2 виртуальных хоста, а все виртуальных хосты, что были раньше, удаляем. То есть получится такое содержание, не учитывая комментарии:
-
<VirtualHost domain:80>
-
ServerAdmin admin@localhost
-
DocumentRoot "/home/nikita/server/domain/www"
-
ServerName domain
-
-
ErrorLog "/home/nikita/server/domain/log/error.log"
-
CustomLog "/home/nikita/server/domain/log/custom.log" common
-
<Directory "/home/nikita/server/domain/www/">
-
AllowOverride All
-
Order allow,deny
-
Allow from all
-
</Directory>
-
</VirtualHost>
-
-
<VirtualHost localhost:80>
-
ServerAdmin admin@localhost
-
DocumentRoot "/home/nikita/server/localhost/www"
-
ServerName localhost
-
-
ErrorLog "/home/nikita/server/localhost/log/error.log"
-
CustomLog "/home/nikita/server/localhost/log/custom.log" common
-
<Directory "/home/nikita/server/localhost/www/">
-
AllowOverride All
-
Order allow,deny
-
Allow from all
-
</Directory>
-
</VirtualHost>
В файле /etc/hosts прописываем дополнительные строки:
domain 127.0.0.1
Запускаем apache и mysql:
sudo /etc/init.d/apache2 start
sudo /etc/init.d/mysql start
Первоначальная настройка mysql:
mysql -u root mysql
UPDATE user SET Password=PASSWORD('new_password') WHERE user='root';
new_password — ваш новый root пароль
FLUSH PRIVILEGES;
exit
Теперь нам надо сделать так, чтоб apache сам запускался при старте системы и сам завершался при её выключении.
В файл /etc/conf.d/local (возможно его не будет существовать, не пугайтесь) добавить такое:
-
local_start() {
-
# This is a good place to load any misc programs
-
# on startup (use &>/dev/null to hide output)
-
-
/etc/init.d/apache2 start
-
/etc/init.d/mysql start
-
-
# We should always return 0
-
return 0
-
}
-
local_stop() {
-
# This is a good place to unload any misc.
-
# programs you started above.
-
-
/etc/init.d/apache2 stop
-
/etc/init.d/mysql stop
-
-
# We should always return 0
-
return 0
-
}
Если он уже существует:
В разделы local_start() и local_stop() добавить:
/etc/init.d/apache2 start
/etc/init.d/mysql start
и
/etc/init.d/apache2 stop
/etc/init.d/mysql stop
соответственно.
Продолжение следует…








Свежие комментарии