virtual host apache

# File: /etc/apache2/sites-available/domain1.com.conf

<VirtualHost *:80>

  # Server Name (domain name) and any aliases
  
  ServerName  domain1.com
  ServerAlias www.domain1.com
  
  #OPTIONAL Admin name
  ServerAdmin [email protected]


  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html
  DocumentRoot /home/demo/public_html/domain1.com/public


  # Custom log file locations, OPTIONAL:
  LogLevel warn
  ErrorLog /var/log/apache2/error-mydomainname.com.log
  CustomLog /var/log/apache2/access-mydomainname.com.log combined

</VirtualHost>

# Enabling:
# sh ~ $
sudo a2ensite domain1.com # Refer to above ServerName!
# The utility may automatically suggest, but run:
sudo /etc/init.d/apache2 reload
# To restart apache!

0
0
Shams 95 points

                                    STEP 1:
# domain: DOMAIN_URL
# public: /var/www/DOMAIN_URL/public_html/public/

&lt;VirtualHost *:80&gt;
	# Admin email, Server Name (domain name), and any aliases
	ServerAdmin admin@DOMAIN_URL
	ServerName  DOMAIN_URL
	ServerAlias DOMAIN_URL
	
	# Index file and Document Root (where the public files are located)
	DirectoryIndex index.html index.php
	DocumentRoot /var/www/DOMAIN_URL/public_html/public/
	&lt;Directory /var/www/DOMAIN_URL/public_html/public/&gt;
        Options Indexes FollowSymLinks
        DirectoryIndex index.php
        AllowOverride All
        Require all granted
        Order allow,deny
        allow from all
	&lt;/Directory&gt;
	# Log file locations
	LogLevel warn
	ErrorLog  /var/www/DOMAIN_URL/log/error.log
	CustomLog /var/www/DOMAIN_URL/log/access.log combined
&lt;/VirtualHost&gt;


STEP 2: With our virtual host files created, we must enable them. We&rsquo;ll be 
using the a2ensite tool to achieve this goal.

sudo a2ensite example.com.conf

STEP 3: When you are finished, you need to restart Apache to make these changes
take effect and use systemctl status to verify the success of the restart.

sudo systemctl restart apache2

refrence:
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04-quickstart

0
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source