Thursday, May 16, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 7318  / 2 Years ago, tue, august 16, 2022, 5:11:59

I successfully run one website on apache2 using a tutorial.
My second website, I can't reach locally, and I don't know why.



Here are the steps I follow :




  1. copy my website to folder /data/mywebsite

  2. create symlink to /var/www/mywebsite

  3. configurate /etc/apache2/sites-available/mywebsite like this :




<VirtualHost *:80>
ServerAdmin [email protected]
ServerName localhost
DocumentRoot /var/www/mywebsite

<Directory /var/www/mywebsite>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>



now I enable this page using apache2 and then restart apache2



sudo a2ensite mywebsite
sudo service apache2 restart


but instead of my page, I only see my www folder.
I guess I linked something wrong. Is it necessary to have this slash / behind mywebsite or something ?



I tried EVERYTHING that I can think of for some hours now.



I also tried to run it on different port and adding a Port to my apache2 ports.conf.
still no success.



Any advice would be most helpful.


More From » 12.04

 Answers
4

If you have multiple sites on one Apache httpd server, you should post the complete configuration (both VirtualHost).



I'm going to post an example config of a two site Apache server, one which serves to www.example.com and one for www.example.org:



file: /etc/apache2/sites-available/example-com



<VirtualHost 172.20.30.50>
DocumentRoot /var/www/example.com/
ServerName www.example.com

# Other directives here ...

</VirtualHost>


file: /etc/apache2/sites-available/example-org



<VirtualHost 172.20.30.50>
DocumentRoot /var/www/example.com/
ServerName www.example.com

# Other directives here ...

</VirtualHost>


If both your sites point to: localhost, only one site will show, one precedes the other, in other words, has a higher priority. That's wha the "ServerName" directive is there for. It will serve those who try to ener that ServerName.



So if you're only testing things on your localhost, just use the same VirtualHost and use subfolders. One site in: /var/www/site1 and the other in /var/www/site2, and point your browser to: http://localhost/site1 or http://localhost/site2.



Another solution if you don't want to have subfolders in your URL is to bypass your DNS lookup and just force some domain lookups throught the /etc/hosts file. Here is an example (You want to add to the 127.0.0.1 line at the end):



file: /etc/hosts



127.0.0.1 localhost example.com example.org


Your /etc/hosts file might look different, just remember to add the two domains to the end because as I explained earlier, Apache will only serve you one VirtualHost to the same ServerName.



For more information: http://httpd.apache.org/docs/2.2/vhosts/examples.html


[#29964] Wednesday, August 17, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
atchcommo

Total Points: 114
Total Questions: 130
Total Answers: 101

Location: Cook Islands
Member since Sat, Oct 16, 2021
3 Years ago
;