sudo yum -y install httpd
sudo systemctl enable httpd.service
sudo mkdir -p /var/www/example.com/public_html
sudo chown -R $USER:$USER /var/www/example.com/public_html
sudo chmod -R 755 /var/www
sudo mkdir /etc/httpd/sites-available
sudo mkdir /etc/httpd/sites-enabled
Next, we should tell Apache to look for virtual hosts in the sites-enabled directory. To accomplish this, we will edit Apache's main configuration file and add a line declaring an optional directory for additional configuration files:
sudo nano /etc/httpd/conf/httpd.conf
Это в начале добавить:
- NameVirtualHost *:81
- Listen 81
Add this line to the end of the file:
IncludeOptional sites-enabled/*.conf
sudo vim /etc/httpd/sites-available/example.com.conf
<VirtualHost *:81>
ServerName images-downloader
DocumentRoot /var/www/html/images-downloader/public
</VirtualHost>
sudo ln -s /etc/httpd/sites-available/example.com.conf /etc/httpd/sites-enabled/example.com.conf
sudo apachectl restart
Внимание! Чтобы работал доступ извне через другой порт, то нужно: или отключить полностью iptables или firewalld. Или добавить портв firewalld:
- firewall-cmd --permanent --add-port=81/tcp
- firewall-cmd --reload
КОГДА ДОБАВЛЯЛ ВТОРОЙ VirtualHost, то вылетала ошибка:
(13)Permission denied: AH00072: make_sock: could not bind to address [::]:2000
Решение: setenforce 0