Настройки Apache, PHP



Сначала обновите индекс пакета, а затем установите пакет apache2, выполнив следующие команды:
sudo apt-get update
sudo apt install apache2
Веб-страница Apache по умолчанию названа index.html и хранится в каталоге /var/www/html
Файлы журнала Apache access.log и error.log находятся в каталоге /var/log/apache
Установите модуль PHP и PHP Apache:
sudo apt install php libapache2-mod-php
В файле apache2.conf исправить везде: AllowOverride All
Перезапустите службу Apache:
sudo systemctl restart apache2
Создайте новый файл с именем info.php внутри каталога /var/www/html
...................Содержимое info.php........первая строка без пробелов:
< ?php
phpinfo();
..................
http://адрес/info.php. Эта страница покажет информацию о вашей конфигурации PHP.
Если возникает ошибка при перезапуске apache2, то выполните в терминале
apache2ctl configtest
Может подсказать, где конкретно ошибка.


Пример файла apache2.conf
DefaultRuntimeDir ${APACHE_RUN_DIR}
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride All
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /etc>
php_admin_value sendmail_path "msmtprc -t -i -a "
</Directory>
Alias /share /share
<Directory /share>
Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
<Directory "/share">
Require all granted
</Directory>