I can access my localhost using a computer, and I can access it too via my mobile phone, but when I installed wordpress on it, I can no longer access it via mobile phone, it's always telling me "localhost refused to connect" with error code ERR_CONNECTION_REFUSED but it works completely fine on my computer. I tried removing the .htaccess but no luck. However, I can access html files for example the readme.html (on phone http://192.168.0.13/readme.html)
My current IPv4 Address on my computer is 192.168.0.13, and I use this address to access it on my phone, but it always redirects me to "localhost". Is it because the home url of my wordpress is set to "http://localhost"? How can I fix this?
This is my httpd-vhosts.conf (if it helps)
# Virtual Hosts
#
<VirtualHost *:8080>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
Require ip 192.168.0.1
Require ip 192.168.0.28
Require ip 192.168.0.33
Require ip 192.168.0.13
</Directory>
</VirtualHost>
I am using WampServer Version 3.1.0 64bit and here are my configurations
Apache 2.4.27
PHP 7.1.9
MySQL 5.7.19
MariaDB 10.2.8
What am I missing? I badly need it to work, it's for my web development purposes.
Is it because the home url of my wordpress is set to "http://localhost"?
Yes, it probably is. If you are being redirected to localhost constantly. You can access a HTML file because it does not containt the logic of the Wordpress PHP installation which will try to redirect you to the base URL. Try changing the base URL of your wordpress installation in the admin panel on your computer (if that is possible) otherwise you should change the base url in the wp-config.php file.
Try changing it to your local IPv4 address: http://192.168.0.13
This can probably help you: https://codex.wordpress.org/Changing_The_Site_URL
Also for your apache configuration try this:
ServerName 192.168.0.13
ServerAlias localhost
I do not have any real experience with Apache but as far as i understood the documentation this should work for you.
Sources:
https://httpd.apache.org/docs/2.4/vhosts/name-based.html
https://httpd.apache.org/docs/2.4/mod/core.html#servername
https://httpd.apache.org/docs/2.4/mod/core.html#serveralias
Jeez, I tried changing both wordpress address and site address to my local ipv4 address 192.168.0.13, and voila, I can finally accessed it. Lol
I'm so dumb, Thank you for the help guys.
Related
I want to be able to use root-relative-paths (ex: /incl/file.php) while developing the website in XAMPP's localhost so that it will work in the same way when I upload it to a webserver. In order to do that, I've set up a Virtual Host within XAMPP. The Virtual Host works fine when I access it with absolute paths (ex: C:/xampp/htdocs/incl/file.php) or pahts without the slash (incl/file.php), but root-relative-paths (/incl/file.php) don't work at all.
I've tried many different configurations of Virtual Host set ups that I found here and on many websites and uninstalling and installing XAMPP. I've also tried to use "\" instead of "/", but the result is the same. I have Windows 10 Pro with the latest XAMPP version installed on it.
This is the Virtual Host set up I am currently employing.
In the hosts file:
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
# ::1 localhost
127.0.0.1 atriero.localhost
In the httpf-vhosts.conf file:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
<Directory "C:/xampp/htdocs">
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/subdomains/site"
ServerName atriero.localhost
<Directory "C:/xampp/subdomains/site">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
As an example of root-relative-paths that are not working, in my index page I have
require "/header.php";
which is located on the "site" folder, the same where index.php is located. If I type "header.php" without the slash, it works fine.
There's also in the header.php page the following line
include_once '/includes/dbh.inc.php';
where the same issue happens, dbh.inc.php is located in the includes folder within the site folder. If I take the slash out the link works fine, but in the way it is writen, with root-relative-path, it doesn't work.
I expect that it is possible to run root-relative-paths with Virtual Host in XAMPP, I assume it would really help in the development of my website and as far as I know it would be the best way to do so.
If for some reason it isn't possible to use root-relative-paths with Virtual Host and if I have to upload my website to the server without the "\" before every path, will it be harmfull in any way to the working of my website?
Thanks in advance.
I am currently using WAMP to host a website on my local PC. I have two questions with regards to configuration:
1) Whenever I want to add something to my website, I am required to edit wp-config.php to point to the directory of localhost instead of my live site
/* Making edits with localhost
define('WP_SITEURL', 'http://localhost/example');
define('WP_HOME', 'http://localhost/example');
/* Public site directory
/*define('WP_HOME', 'http://example.com');*/
/*define('WP_SITEURL', 'http://example.com');*/
Is there an easier way to automate this? I can't imagine every person who uses WAMP with wordpress has to go through this process, am I missing something?
2) Whenever I have a virtual host for localhost, people who view my website are redirected to my localhost instead of the website. My config for http-vhosts.conf virtual hosts is as follows:
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
So, I need to comment out the block every time my site goes live, then it works fine. However, whenever I want to make changes to my website, I have to uncomment the virtual host again. Similar to my first issue, is there an easier way to switch between site maintenance and online mode? Thanks in advance for any comments/suggestions.
WAMP is used locally and you should have a separate public installation for your live public site. WAMP is not meant for external access.
Local installation is not protected against attacks, nor heavy traffic. One should use some hosting service.
Once installations are separated, the above issue is resolved.
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 installed Bitnami WAMP Stack in Windows 7 and I am trying to get my eclipse php code to run. I found a link online that said to add an alias, but that didn't work, how do I get the code to run in
http://localhost/greenmugcafe/
if my eclipse workspace is located here
C:\Users\Robert\Documents\GitHub\greenmugcafe ?
Edit: I could not find anything on doing this for Bitnami WAMP but I found a few for the Bitnami Django stack.
Any Help at all?
Your code would run from http://localhost/greenmugcafe/ if you changed the virtual host directory of localhost to C:/Users/Robert/Documents/GitHub/
Personally, I think it would be better to create a local domain called greenmugcafe.dev rather than having a folder greenmugcafe in the localhost domain.
How to setup virtual hosts in WAMP
Make sure virtual hosts have been enabled:
Edit /installdir/apache2/conf/httpd.conf
Search for line that includes httpd-vhosts.conf and uncomment it by removing the # at the start
Adding a new virtual host:
Edit the hosts file on your windows system (usually located at C:\WINDOWS\system32\drivers\etc\)
Add the following to the end of the hosts file 127.0.0.1 greenmugcafe.dev. This tells your computer that any url with a value of greenmugcafe.dev should be routed to 127.0.0.1 (aka localhost).
Save the hosts file and now edit this file /installdir/apache2/conf/extra/httpd-vhosts.conf
Add the greenmugcafe.dev virtual host entry at the bototm of the /installdir/apache2/conf/extra/httpd-vhosts.conf file, save, and restart the server.
Here's the code:
#greenmugcafe
<VirtualHost *:80>
ServerAdmin webmaster#greenmugcafe.dev
DocumentRoot "C:/Users/Robert/Documents/GitHub/greenmugcafe/"
ServerName greenmugcafe.dev
ErrorLog "logs/greenmugcafe.dev-error.log"
CustomLog "logs/greenmugcafe.dev-access.log" common
<Directory "C:/Users/Robert/Documents/GitHub/greenmugcafe/">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Require all granted
</Directory>
</VirtualHost>
Now http://greenmugcafe.dev will point to C:/Users/Robert/Documents/GitHub/greenmugcafe/
This method will also work for other WAMP stacks like Wamp Server and XAMPP.
For a launched website on a linux server, instead of the windows host file, we would change the a record of the domain name to point to the server IP address. Then we still need to setup the virtual host so the server knows to recognise the domain name and point it to the correct folder on the server.
Hope that helps :-)
Virtual host not working in the NETWORK
I just followed this site tutorial,
Virtual host steps
The tutorial was excellent but when I try this alias URL in another system, its not working. I have checked in my other system, I am able to see my application, after I did these changes I am not able to see my application on the other system.
I have even changed Allow from 127.0.0 to all but that is not working.
My C:\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf
This what I added
<VirtualHost *:80>
ServerAdmin webmaster#developertalk
DocumentRoot "C:/wamp/www/developertalk"
ServerName developertalk
ServerAlias www.developertalk
ErrorLog "logs/developertalk-error.log"
CustomLog "logs/developertalk-access.log" common
<directory "C:/wamp/www/developertalk">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from all
</directory>
</VirtualHost>
When hitting URL in another system, getting following error:
Server not found
In my local host i am having 3 web application.
Due to above changes my local host other sites not working.
How to make it work other sites.
You need to use local DNS to say every PC in Your network, that You have on Your PC host 'myApp', also You can add to every client's hosts file something like myapp 192.168.1.2 where 192.168.1.2 Your static IP in network
For every computer you want to have access to http://developertalk, you need to edit the Hosts file in each one.
Located at (xp/win7): C:\Windows\System32\drivers\etc\
You need to add only 1 line on every computer.
(your static internal ip) www.developertalk
example:
192.168.1.71 www.developertalk
you can check your internal ip address on your windows by opening cmd and typing ipconfig.
Look for the IPv4 address under the Ethernet adapter Local Area Connection column.
If you don't request or assign a static internal IP to your computer, others will not be able to connect to http://developertalk which was forwarded to your old internal IP.
Egor Sazanovich has actually answered your question and provided you with extra information, so accept his instead of this one, if this helped at all.