2 different directories for 2 different port
at 2017-12-24 13:01:00.
so in this tutorial we will run the 2 folder /var/www/forlder1 and /var/www/forlder2 as 2 different service(sites) on 2 different tcp ports 80 and 8080. first you need to stop apache.
then you need to go to /etc/apache2 folder and open up ports.conf then you will see the fallowing lines:
NameVirtualHost *:80 Listen 80
so will add 2 more to make it look like this
NameVirtualHost *:80 NameVirtualHost *:8080 Listen 80 Listen 8080
Now you can open the folder sites-available and open the file default
you may see something like this or with more or less text:
<VirtualHost *:80> DocumentRoot /var/www/ <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride All Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
first you need to change the folder from /var/www to /var/www/folder1/ and then you need to duplicate the same thing again in the same file but change the port to 8080 and the folder to /var/www/folder2 like so:
<VirtualHost *:80> DocumentRoot /var/www/folder1 <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /var/www/folder1> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride All Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> <VirtualHost *:8080> DocumentRoot /var/www/folder2 <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /var/www/folder2> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride All Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
and then service apache2 start