may I ask question about the Apache Virtual Host config?
I use XAMPP, my develop app is Wordpress.
I have configured my host file (C:\Windows\System32\drivers\etc...) like
127.0.0.1 tommydo.dev
127.0.0.1 172.25.129.113/tommydo.dev <== *172.25.129.113 is my local PC's IP address*
and C:\xampp\apache\conf\extra**httpd-vhosts.conf** like:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/tommydo.dev"
ServerName tommydo.dev
</VirtualHost>
It was successful when I access from my PC (LAN). With URL: http://tommydo.dev
But when I access from another computer using http://172.25.129.113/tommydo.dev is was broken. Of course ! Because of my Wordpress config is "tommydo.dev" only.
My question is: Is it possible to configure or access from another PC to my WP in localhost in my own PC?
Get Apache to listen to 172.25.129.113 on port 80. Use the following to listen to Port 80 on all interfaces
Listen 80
On the other computer try going to http://172.25.129.113
You could end up with 404 errors with the path http://tommydo.dev.
This could be solved by
Reconfiguring the site to use http://172.25.129.113
Adding the below to each Computer's hosts file
172.25.129.113 tommydo.dev
Setup a DNS system in your LAN to have tommydo.dev as a Domain Name.
Also
127.0.0.1 172.25.129.113/tommydo.dev
is invalid because the second part is not a hostname
Related
I have a SAAS and am trying to allow other people to use my SAAS in their own domain. So, supposing my site is app.example.com (hosted with Apache and with PHP as the backend language), I want to allow someone to offer my website from, for example, app.anotherwebsite.com.
I already created a CNAME on app.anotherwebsite.com:
app.anotherwebsite.com CNAME app.example.com.
But if I access app.anotherwebsite.com, it loads the default cPanel page on app.anotherwebsite.com/cgi-sys/defaultwebpage.cgi.
I already tried many solutions offered on the web with no luck. Does anyone have any clue how to solve this? Do I have to do something on the example.com server to fix this?
Thanks a lot!
When you create a CNAME and try to make a HTTP request to it, the computer does the follow:
1) Try to discover the IP related to your hostname (in this case, app.anotherwebsite.com), and the CNAME it's an alias to another hostname, that need to point to an IP address;
2) When the computer has the IP address of the hostname, it connect to port 80 (in case of HTTP) or port 443 (in case of HTTPS) and request the page app.anotherwebsite.com;
3) Your HTTP server at the IP address will search it configuration for a virtual host that match app.anotherwebsite.com. If there's no virtual host configured that match the requested hostname, it will serve the default virtual host. At Apache, if there's no explicit declared default virtual host, the first virtual host configured will be elected as default.
In your case, your CPANEL is your default virtual host, and that's why it's displaying it.
So, to make your SASS work at this scenario, you can change your default virtual host to your application or you can add a virtual host with wildcard, like app.*. It'll receive the requested hostname (at PHP, you can access it as $_SERVER["SERVER_NAME"]).
Below is an example code:
<?php
echo "Hello!<br />\n";
echo "<br />\n";
echo "I'm seeing you're requesting the hostname " . $_SERVER["SERVER_NAME"] . "!\n";
?>
Your code can handle this information and serve your client based on that variable.
EDIT:
You can add a virtual server at Apache using this code:
<VirtualHost *:80>
ServerName app.example.com
ServerAlias app.*
DocumentRoot /var/www/SASS
<Directory /var/www/SASS>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/SASS-error.log
CustomLog ${APACHE_LOG_DIR}/SASS-access.log combined
</VirtualHost>
This Apache virtual host add a new server named app.example.com, and will also match app.* requests.
The server will point to /var/www/SASS as root directory, looking for index.html or index.php (if there's PHP enabled at Apache) file.
The permissions to /var/www/SASS granted with tag <Directory> disallow the automatic creation of index files of directories without index file and allow use of .htaccess.
Also, was created a separated error_log and access_log to log requests matching this entry.
To check your Apache configuration and look for all your virtual hosts, use the following command:
apachectl -t -D DUMP_VHOSTS
This will produce an output like:
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server cpanel.example.com (/etc/httpd/conf/httpd.conf:994)
port 80 namevhost cpanel.example.com (/etc/httpd/conf/httpd.conf:994)
port 80 namevhost app.example.com (/etc/httpd/conf/httpd.conf:1044)
wild alias app.*
Syntax OK
i setup my wordpress site on my computer by using wamp server and every thing is ok ,
i can access my site via lan or wan by using the ip address like :
192.168.1.11/site
my host file like this :
127.0.0.1 demo.it
127.0.0.1 www.demo.it
192.168.1.11 demo.it
my vhost file like this
<VirtualHost *:80>
ServerName demo.it
DocumentRoot "c:/wamp/www/point"
<Directory "c:/wamp/www/point">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
i can browse the site on my computer by using the domain (demo.it) , but it's not working from other machine
help please
sorry for my english :)
You will have to enter the IP address of your local machine and the domain name as you have in your hosts file into any machine that wants to access your local wamp server.
192.168.1.11 demo.it
Of course, first the other machines must be able to reach 192.168.1.11, but as you said, they can access your site from http://192.168.1.11/site so that must mean they can reach you.
Just check via ping to be double sure. Open Command prompt and check output of
ping 192.168.1.11
If you can, there might be a way to configure your router or switch such that specific domain requests are routed to your IP address, but I don't know how to do it.
I am running WAMP and using CodeIgniter for my project and have this on my vhost:
<VirtualHost *:80>
ServerAdmin admin#yahoo.com
DocumentRoot "C:/wamp/www/myproject/assets"
ServerName myproject.dev
ErrorLog "logs/myproject.dev-error.log"
CustomLog "logs/myproject.dev-access.log" common
</VirtualHost>
Now to access this, I added this line on windows/system32/drivers/etc/hosts:
127.0.0.1 myproject.dev
Now for the other computers on the network, I have to edit the hosts file of EACH computer so they can access my virtual host. (yes of course I have to use my ip address instead 127.0.0.1 for other computers)
Now my question is, is there a way that they can access my project by only using my ip address on the browser's address bar like this?
http://192.168.1.112/myproject
I mean there are 100 users that will access that project and it's a big hassle if I edit each one's hosts file. Like adding something to .htaccess, or to the routes of CodeIgniter, or to the <virtualHost>
Note:
By the way, when we are still NOT using Codeigniter (plain PHP codes), this is not a problem. But because of Codeigniter's structure, we can't do it anymore.
Can you just add a DNS entry that points to your IP address and set that as the ServerName that apache responds to?
Alternatively you can do virtual hosting based on IP address and port as described here:
http://httpd.apache.org/docs/2.2/vhosts/ip-based.html
In summary you should be able to do:
<VirtualHost 192.168.1.112:8000>
ServerAdmin admin#yahoo.com
DocumentRoot "C:/wamp/www/myproject/assets"
ServerName myproject.dev
ErrorLog "logs/myproject.dev-error.log"
CustomLog "logs/myproject.dev-access.log" common
</VirtualHost>
And have people access it via
http://192.168.1.112:8000/myproject
But, don't forget to add a Listen directive for port 8000 (or whatever you choose) if you use IP-based Virtual hosts
It might work of you create an alias called /myproject in wamp server and point the document root to 'C:/wamp/www/myproject/assets'
Make sure you have set your wamp server status to online by selecting 'Put Online' in wamp server system tray icon.
I've installed Apache/Linux on Amazon EC2. On one instance, I set up PHP and put the files under the directory var/www/html. On the same instance, I also installed NodeJS in a subfolder home/ec2-user/
I created a new director home/ec2-user/site, where I put a javascript file that starts a NodeJS server script (server.js) on port 8080.
Now, if the URL is http://domain.com, it directs to the PHP directory (var/www/html). And a URL http://domain.com:8080 shows the output form server.js
My question is:
Can I redirect http://domain.com:8080 to http://sub.domain.com or http://domain.com/sub ? I want the address bar on the browser will change to too. Is this possible?
I think I've solved this.
First of all, set Amazon S3 and Route 53.
At Amazon S3, add a bucket "sub.domain.com." Then Static Website Hosting > Redirect all requests to another host name, then type "domain.com"
At Route 53, at a hosted zone "domain.com," create a record set "sub.domain.com." Choose type "A", then set an alias to "domain.com."
(TBH, I am not entirely sure that the steps above are necessary.)
Then change proxy setting. Make a file name "httpd-vhosts.conf." Then put it under "etc/httpd/conf.d." For detailed steps, check this answer: Second Virtual Host's DocumentRoot is changed after launching ec2 based on customized Amazon Linux AMI
NameVirtualHost *:80
<VirtualHost *:80>
ServerName domain.com
DocumentRoot "/var/www/html/"
</VirtualHost>
<VirtualHost *:80>
ServerName sub.domain.com
ProxyPass / http://domain.com:8080/
ProxyPassReverse / http://domain.com:8080/
</VirtualHost>
Then I restarted the EC2 instance on Amazon console. Any better solutions are welcome.
I want to run a localhost php website from some other system. I was able to run the website through the subfolder link as http://192.168.1.102/website. But I want it to run as the main site http://website.
Is there any way we can achieve this.
I have tried adding following in hosts file but didn't work.
host:
http://192.168.1.102/website website
I also tried to do following:
host:
192.168.1.102 website
httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot e:/wamp/www/website/
ServerName website
</VirtualHost>
Here the DocumentRoot path is the path on other pc.
In the system in which you are hosting your website ( I mean the one you are accessing via LAN ) you need to have below host entry
127.0.0.1 localhost
127.0.0.1 website
and in the system from where you are accessing this remote system need to have below host entry
192.168.1.102 website
192.168.1.102 is the ip address of the machine you are accessing , please change it accordingly
Also If you have problems in setting Up VHOST in WAMP you can verify your way with the below link it worked for me I often use to follow this link
Setting up WAMP server in windows along with virtual HOST
You need to edit the apache config for wamp to point its default root to your folder (not the vhosts but the main file) also you'll need to put wamp into online mode so it'll listen on the external interface not just localhost but I believe this is just a * in the config anyway to listen to all not just 127.0.0.1
In the /etc/hosts add an entry like this:
127.0.0.1 www.localhost
192.168.1.102 website