hkhoshraftar
7/21/2019 - 1:02 PM

#centos #httpd #vhost

#centos #httpd #vhost

sudo mkdir -p /var/www/example.com/html

sudo mkdir -p /var/www/example.com/log
sudo chown -R $USER:$USER /var/www/example.com/html
sudo chmod -R 755 /var/www
sudo nano /var/www/example.com/html/index.html
sudo mkdir /etc/httpd/sites-available /etc/httpd/sites-enabled
sudo nano /etc/httpd/conf/httpd.conf  
=at the end==> IncludeOptional sites-enabled/*.conf
sudo nano /etc/httpd/sites-available/example.com.conf
===> 
<VirtualHost *:80>
    ServerName www.example.com
    ServerAlias example.com
    DocumentRoot /var/www/example.com/html
    ErrorLog /var/www/example.com/log/error.log
    CustomLog /var/www/example.com/log/requests.log combined
</VirtualHost>

sudo ln -s /etc/httpd/sites-available/example.com.conf /etc/httpd/sites-enabled/example.com.conf
sudo setsebool -P httpd_unified 1
sudo ls -dZ /var/www/example.com/log/
sudo semanage fcontext -a -t httpd_log_t "/var/www/example.com/log(/.*)?"
sudo restorecon -R -v /var/www/example.com/log
sudo ls -dZ /var/www/example.com/log/
sudo systemctl restart httpd