Подготовка httpd
Пример:
Домен: vi-edu.local
Адрес IP: 192.168.0.1
Копируем файл конфигурации демона httpd
1 |
$ doas cp /etc/examples/httpd.conf /etc |
Подготовим каталоги и тестовый файл index.html
1 2 3 4 5 6 |
$ doas mkdir -p /var/www/htdocs/vi-edu.local $ doas mkdir -p /var/www/etc/ssl $ doas install -m 444 -o root -g bin /etc/ssl/cert.pem /etc/ssl/openssl.cnf /var/www/etc/ssl/ $ echo "vi-edu.local - OK" | doas tee /var/www/htdocs/vi-edu.local/index.html $ doas cp /etc/resolv.conf /var/www/etc $ doas chown -RH www /var/www/htdocs/ |
Запись адреса IP и нашего домена в файл hosts
1 |
# echo "192.168.0.1 vi-edu.local" >> /etc/hosts |
Базовая настройка httpd
1 |
$ doas nano /etc/httpd.conf |
1 2 3 4 5 6 7 8 9 10 |
ext_ip="*" server "default" { listen on $ext_ip port 80 root "/htdocs/" } types { include "/usr/share/misc/mime.types" } |
Проверка
1 2 |
$ doas httpd -n configuration OK |
Включаем и запускаем демон httpd
1 2 |
$ doas rcctl enable httpd $ doas rcctl start httpd |
Установка PHP
1 |
$ doas pkg_add php-8.0.14 php-curl-8.0.14 php-mysqli-8.0.14 php-pdo_mysql-8.0.14 php-zip-8.0.14 php-bz2-8.0.14 php-gd-8.0.14 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
php-8.0.14:pcre2-10.36: ok php-8.0.14:femail-1.0p1: ok php-8.0.14:femail-chroot-1.0p3: ok php-8.0.14:argon2-20190702: ok php-8.0.14:libsodium-1.0.18p1: ok php-8.0.14:libxml-2.9.12: ok php-8.0.14: ok php-curl-8.0.14: ok php-mysqli-8.0.14: ok php-pdo_mysql-8.0.14: ok php-zip-8.0.14:libzip-1.7.1p0: ok php-zip-8.0.14: ok php-bz2-8.0.14: ok php-gd-8.0.14:jpeg-2.1.1v0: ok php-gd-8.0.14:giflib-5.1.6: ok php-gd-8.0.14:lz4-1.9.3p0: ok php-gd-8.0.14:zstd-1.5.0: ok php-gd-8.0.14:tiff-4.3.0: ok php-gd-8.0.14:libwebp-1.2.1: ok php-gd-8.0.14:gd-2.3.2: ok php-gd-8.0.14: ok |
Включаем и запускаем демон php_fpm
1 2 |
$ doas rcctl start php80_fpm $ doas rcctl enable php80_fpm |
Настройка виртуального хоста
1 |
$ doas nano /var/www/conf/vi-edu.local.conf |
1 2 3 4 5 6 7 8 9 |
server "vi-edu.local" { listen on $ext_ip port 80 root "/htdocs/vi-edu.local" directory auto index location "*.php" { fastcgi socket "/run/php-fpm.sock" } } |
1 |
# echo 'include "/var/www/conf/vi-edu.local.conf"' >> /etc/httpd.conf |
1 |
$ echo "<?php phpinfo(); ?>" | doas tee /var/www/htdocs/vi-edu.local/info.php |
1 2 3 |
$ doas httpd -n configuration OK $ doas rcctl restart httpd |
http://vi-edu.local/info.php