Apache httpserver virtualhost not working - apache

I have configured virtualhost in apache, conf contents below. (/etc/apache2/sites-available/myapp.xyz.conf). this is running on ubuntu 20.04.1
i have run "a2ensite myapp.xyz" successfully.
However, i cannot access myapp.xyz.net from browser. (We can’t connect to the server at myapp.xyz.net)
ping myapp.xyz.net in the machine works fine. but from external machine, it doesnt recognize myapp.xyz.net.
i have tried multiple suggestions but no luck.
I have updated /etc/hosts to include "127.0.0.1 myapp.xyz.net myapp.xyz.net" - no luck.
Tried changing <VirtualHost *:80> to <VirtualHost 127.0.0.1:80> and - no luck
Appreciate suggestions.
<VirtualHost *:80>
ServerName myapp.xyz.net
ServerAlias myapp.xyz.net
LogLevel warn
ErrorLog /var/log/apache2/myappconsoleError.log
CustomLog /var/log/apache2/myappAccess.log combined
ProxyPass / http://myapp.xyz.net:8069/
ProxyPassReverse / http://myapp.xyz.net:8069/
</VirtualHost>
Update:
I can access the page if i use http://1.2.3.4 . (1.2.3.4 is machine ip address).
What should my virtualhost config look like to access it by servername (i.e myapp.xyz.net)

Related

Issues with Apache and Virtual Hosts

I'm, trying to run both MediaWiki and Wordpress on an Apache server. I've got the MediaWiki site set up with a couple of sub-domain Virtual Hosts, so everything is fine there. This is installed at /var/www/html/mediawiki.
I'm trying to install Wordpress on it's own directory, /var/www/wordpress.
In my config file for Wordpress' virtual host, I've got:
<VirtualHost *:80>
ServerName domain.com
ServerAdmin admin#domain.com
DocumentRoot /var/www/wordpress
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<Directory /var/www/wordpress/> AllowOverride All</Directory>
Obviously domain.com is not the domain.
Whenever I visit domain.com, however, it seems to be loading the MediaWiki install from /var/www/html/mediawiki, which is obviously not what I want.
Anyone got any ideas what I'm doing wrong here?
Run apachectl to see all the servers/vhosts running on your server both port 80 and 443
apachectl -S
Also I believe that:
<Directory /var/www/wordpress/> AllowOverride All</Directory>
should be inside of your virtual host block

Virtual Host not pointing properly

I have installed Laravel at C:/Apache24/htdocs/lsapp.
It's working fine with localhost/lsapp/public URL.
What I want to do is instead of above URL I want to access it by mak.org on my local machine.
For that I did following changes
Edited C:/Apache24/conf/extra/httpd-vhosts.conf with below lines:
<VirtualHost *:80>
DocumentRoot "C:/Apache24/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/Apache24/htdocs/lsapp/public"
ServerName mak.org
</VirtualHost>
Edited C:/Windows/System32/drivers/etc/hosts with below lines:
127.0.0.1 localhost
127.0.0.1 mak.org
I restarted my apache server.
But when I hit mak.org in browser, instead of accessing "C:/Apache24/htdocs/lsapp/public" it is pointing to "C:/Apache24/htdocs".
I restarted my PC, enabled opcache.enable=0 in php.ini still not getting desired outcome.
Can anybody help me on this?
What or where am I missing?
The issue resolved by enabling below in httpd.conf file of Apache:
Include conf/extra/httpd-vhosts.conf

What is wrong with this apache2 configuration?

I want to set up apache2 so that the wordpress website is served via port 80 and some other php website served via port 8080. This is on my local machine running Ubuntu 15.10.
The sites-available/000-default.conf contains:
Listen 80
Listen 8080
NameVirtualHost *:8080
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
<Directory /var/www/html/>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot /var/www/php-website
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
When I enter localhost into the browser, I get the Wordpress website. When I enter localhost:8080, I get (redirected it seems to) localhost.
What could be wrong here? I though there might be something wrong with the second VirtualHost config so it's defaulting to the first, so I changed their order. Same thing happened however.
It could be a problem with wordpress configuration. I think wordpress uses wordpress adress (url) or site adress (url) to redirect if you are in another domain. So you should configure this adresses to localhost and localhost:8080.
It was a browser issue. Chrome and Firefox were automatically changing the URL to localhost. It works with curl and in Incognito/Private modes.

Apache Virtual Host IP Works but not ServerName

I am using Wamp.
My Apache Server is running on port 90.
I Tried adding a virtual host by doing the following steps:
1)Removed the comment from the line Include conf/extra/httpd-vhosts.conf line in my Apache httpd.conf file.
2)I Added the following code to my C:\wamp\bin\apache\Apache2.4.4\conf\extra\httpd-vhosts.conf
<VirtualHost *:90>
ServerAdmin admin#laravel.dev
DocumentRoot "c:/wamp/www/laravel/public"
ServerName laravel.dev
ServerAlias www.laravel.dev
ErrorLog "logs/laravel.dev.log"
CustomLog "logs/dummy-laravel.dev.log" common
</VirtualHost>
<VirtualHost *:90>
DocumentRoot "c:/wamp/www/"
</VirtualHost>
3)I made changes to my windows hosts file.This is the content of my hosts file
127.0.0.1:90 localhost
127.0.0.1:90 laravel.dev
127.0.0.1:90 www.laravel.dev
Now localhost:90 will Redirect to my C:/wamp/www and 127.0.0.1:90 will Redirect to my C:/wamp/www/laravel/public but both laravel.dev and www.laravel.dev are not working
I get the message Oops! Google Chrome could not find laravel.dev in my chrome.
Any help would be appreciated :)

Configuring two server simultaneously at apache local

I wanna configure two server simutaneoulsy at my apache. one is with name localhost n another is with name shadaab.
What I did was edited C:\xampp\apache\conf\httpd.conf and added these lines at last of files
NameVirtualHost localhost
<VirtualHost localhost>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
NameVirtualHost shadaab
<VirtualHost shadaab>
DocumentRoot "F:/projects/all/"
ServerName shadaab
</VirtualHost>
Restarted apache server. When I browse in url localhost its working fine but when I did for 'shadaab' it doesn't work.
Later on how mysql will be connected with shadaab server pelase help. What other changes do I need to do.
Your config is WAY off. I suggest reading some documentation.
Your config should look something like:
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1:80>
DocumentRoot "F:/projects/all/"
ServerName shadaab
</VirtualHost>
Or replace 127.0.0.1 with * to make apache listen on all IP addresses, not just the loopback.
add
127.0.0.1 shadaab
in your host file
You will be able to connect to your mysql server via shadaab.
shadaab will point to 127.0.0.1