Knowledge Base

How do I define a virtual host on the server?

How do I define a virtual host on the server?

Apache: Create a file /etc/apache2/sites-available/example.com.conf with: ```apache ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/example.com AllowOverride All Require all granted ErrorLog ${APACHE_LOG_DIR}/example_error.log CustomLog ${APACHE_LOG_DIR}/example_access.log combined ``` Then enable and reload: ```bash sudo a2ensite example.com.conf sudo systemctl reload apache2 ``` Nginx: Create /etc/nginx/sites-available/example.com with: ```nginx server { listen 80; server_name example.com www.example.com; root /var/www/example.com; index index.php index.html index.htm; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.4-fpm.sock; } access_log /var/log/nginx/example_access.log; error_log /var/log/nginx/example_error.log; } ``` Then enable and restart: ```bash sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/ sudo systemctl restart nginx ```

Can't find the information you are looking for?

Create a Support Ticket
Did you find it useful?

1 times viewed | 0 people fount it helpful

3826704865 +38267054865 +38267054865 Top