I'm running EasyPHP on Windows. The default install just opens port 80 on the loopback interface, 127.0.0.1. I want my sites to be accessible over the local network too. There are no simple EasyPHP settings for enabling my other interface, like the one that's connected to the internet (let's say 192.168.1.3). What do I add/modify in Apache httpd.conf?
Use this code in your httpd.conf
ServerName localdomain
# env
SetEnv TMP "/tmp"
ServerAdmin admin#devserver
DocumentRoot "/var/www"
#NameVirtualHost *:80
#Listen 80
##################################################################
# default
<VirtualHost *:80>
DocumentRoot "/var/www"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www"
ServerName www.localdomain.com
</VirtualHost>
** I just realize EasyPHP is for windows. You might use c:/path/to/www instead of /var/www
I just need to add this line
Listen <your machine IP>:<your port>
e.g.
Listen 192.168.1.3:8080
and restart Apache
Related
I am having a website first.com which is deployed on a windows server with ip like (11.111.111.11) using 80 port (DNS is pointed on first.com of host server), Now I have installed Xampp and run on 8081 port and deployed code which can be accessed using ip 11.111.111.11:8081/second, what I have to do is another domain second.com to point this second folder of xampp so second.com is equals to 11.111.111.11:8081/second, I have changed DNS of second.com to host DNS of first.com as it is done for this domain.
And changed my vhost of xampp like
<VirtualHost *:8081>
DocumentRoot "D:/xampp/htdocs"
ServerName www.second.com
<Directory "D:/xampp/htdocs/second">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Now when I am hitting this second.com it points the same website of first.com but when I hit second.com:8081/second it points to the new website which logically is working fine, now I want that second.com should open the new website without showing any port/folder.
I believe it is Possible, Please suggest.
Thanks in advance
I think you maybe enabled the virtual host on the xampp,
then you can do the domains pointed to same port by editing the file /httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /opt/lampp/htdocs/website_a
ServerName www.website_a.com
ErrorLog "/opt/lampp/htdocs/website_a/error_log"
</VirtualHost>
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /opt/lampp/htdocs/website_b
ServerName www.website_b.com
ErrorLog "/opt/lampp/htdocs/website_b/error_log"
</VirtualHost>
If you want to know more some reference, here is one for you:
https://github.com/oliguo/Server-Deployment/blob/master/XAMPP.md
I am following a laravel tutorial, where tutor sets up a virtual host to run their app. The app is located in /opt/lampp/htdocs/first-app. My port for running apache is 8000. So if I visit localhost:8000/first-app/public, I can view my laravel app.
My httpd-vhosts.conf file looks like this:
<VirtualHost *:8000>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "/opt/lampp/htdocs"
ServerName localhost
ServerAlias www.localhost
</VirtualHost>
<VirtualHost *:8000>
DocumentRoot "/opt/lampp/htdocs/first-app/public"
ServerName app.test
ServerAlias www.app.test
<Directory "/opt/lampp/htdocs/first-app">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
My /etc/hosts file looks like this:
127.0.0.1 localhost app.test
::1 localhost app.test
127.0.1.1 pop-os.localdomain pop-os
127.0.0.1 app.test
I have uncommented httpd.conf like so
# Virtual hosts
Include etc/extra/httpd-vhosts.conf
But I am getting this when I visit app.test
Browser output when app.test is visited
What am I doing wrong?
Edit: I have discovered, if I visit www.app.test:8000, it works fine
Just found out that the browser automatically adds port 80. So since I am running apache on port 8000, I need to specify it.
Thus, the settings above actually worked. All I had to do was go to http://localhost:8000 or http://127.0.0.1:8000
I am trying to create a virtual host for my project using Xampp.
I added 127.0.0.1 project.com in the hosts file in C:\Windows\System32\drivers\etc
I changed the port 80 to 8003 in the httpd.conf file in C:\xampp\apache\conf (I changed everything from 80 to 8003 in this file)
I added this:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/project/public"
ServerName project.com
</VirtualHost>
in the httpd-vhosts.conf in C:\xampp\apache\conf\extra
When I leave it with the 80 port in the files, it works good. But when I try to use the 8003 port does not work. I get the same message as when I stop Apache.
Edit1: I changed this:
<VirtualHost *:8003>
DocumentRoot "C:/xampp/htdocs/project/public"
ServerName project.com
</VirtualHost>
Now I can access to the ulr but just if I try with the url like this: project.com::8003
With the number port at the end of the url.
There is a way to use project.com without add the number port?
You need to check 4 things.
Are you sure you are listening to port 8003 in httpd.conf file.
Set ServerName domainName.com:8003 in httpd-vhosts.conf.
You also need to change: VirtualHost *:8003 in httpd-vhosts.conf.
<VirtualHost *:8003>
DocumentRoot "C:/xampp/htdocs/project/public"
ServerName project.com
</VirtualHost>
Now, you should be able to access with your URL: http://domainName.com:8003
last but not the least don't forget to restart xampp.
Hope this helps! :)
I moved from linux to a mac. I have Apache and php setup.
Now apache seems to only load the first virtual host listed. It also only loads it in the browser via local host and not the sitename. Its been 3 days hunting the net or solutions nothing seems to work.
now if i make the document root for the virtual host eg. /Library/WebServer/Documents/ then it works. If i add an extra directory it fails eg. /Library/WebServer/Documents/livingahimsa.co.uk
here is the config: ( I have tried the doc root with quotes and without)
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
127.0.0.1 ahimsainvestments.com
127.0.0.1 livingahimsa.co.uk
127.0.0.1 ahimsavillage.com
255.255.255.255 broadcasthost
::1 localhost
and vhost:
<VirtualHost *:80>
DocumentRoot /Library/WebServer/Documents/ahimsainvestments.com
ServerName ahimsainvestments.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /Library/WebServer/Documents/livingahimsa.co.uk
ServerName livingahimsa.co.uk
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /Library/WebServer/Documents/ahimsavillage.com
ServerName ahimsavillage.com
pache2/httpd.conf
Can you tell me please what am I doing wrong in Virtual host settings?
I am editing two files:
Apache/conf/extra/httpd-vhosts.conf and Windows/System32/drivers/etc/hosts
httpd-vhosts.conf looks like
<VirtualHost 127.0.0.1>
ServerName scouttautomotive.com
ServerAlias www.scouttautomotive.com
DocumentRoot "C:/Apache24/htdocs/scouttautomotive/web"
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName bosp.sk
ServerAlias bosp.sk.localhost
DocumentRoot "C:/Apache24/htdocs/bosp/web"
</VirtualHost>
hosts file looks like
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 scouttautomotive.com
127.0.0.1 bosp.sk
What is wrong with it? I am realy confused cause bosp.sk virtual host works well.
After setting the domain ip to 127.0.0.1 to host file, You must restart your computer or flush dns cache to get that applied. Did you do?
So look at these config files and note that difference is only in the last letter of ServerName.
httpd-vhosts.conf
<VirtualHost 127.0.0.1>
ServerName scouttautomotive.com
ServerAlias scout.com.localhost
DocumentRoot "C:/Apache24/htdocs/scouttautomotive/web"
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName scouttautomotiv.com
ServerAlias drom.com.localhost
DocumentRoot "C:/Apache24/htdocs/scouttautomotive/web"
</VirtualHost>
hosts
127.0.0.1 scouttautomotive.com
127.0.0.1 scouttautomotiv.com
First version redirects me to one hosting which offers this domain to sell. Second version works well as virtual host. Both are created in the same time. So it looks command ipconfig /flushdns may not be enough.
Another possible solutions can be find here https://serverfault.com/questions/452268/hosts-file-ignored-how-to-troubleshoot Good luck!