View a wordpress site installed on localhost from LAN [duplicate] - php

This question already has answers here:
How do I connect to this localhost from another computer on the same network?
(8 answers)
Accessing localhost (xampp) from another computer over LAN network - how to?
(25 answers)
Closed 4 years ago.
I have installed xampp on localhost,and have installed wordpress on it(using port 8080),and have created a website on it.
I need to see that localhost wordpress site from another computer before loading it to a domain.I tried ngrok,but using that i could only get to the XAMPP welcome page.
How can I reach the wordpress site.
P.S. I access the wordpress site on my pc as localhost:8080/wordpress-trunk
Please help

You can access your local site from local network. To do that you need to assign ip to your local server. You can check these links link1 link2
To actually visit you site from internet you'll need to buy services(ip and domain name ) from your isp. Your isp will have to assign the in the dns server they are using. That is you'll have to make your own web server.
If its just for testing purpose best option is to use free hosts

Take a look on your apache configuration, looks like it allows requests only from localhost. Your config should looks like
<Directory /APP>
Allow from all
</Directory>
while now you have something like
<Directory /APP>
Allow from 127.0.0.0/8
</Directory>
* EDITED *
Accordin description, your task is to access your web site from another local computer, rather then from internet. As I can see, you can access this computer (and you can see XAMPP welcome page), so you don't need to follow Tousif Osman's answer, the problem is in your settings.

You can achieve what you want using your public IP adress, even if it's dynamic. First, you need to config a port forwarding in your router. To do this, enter in your router settings, go to port forwarding and there add the LOCAL IP adress from your XAMPP computer. Make sure to select type TCP and RANGE 80-80, because port 80 it's the default port for apache. Make sure you don't use Skype, which also use port 80.
After you did that, reset your router so the changes apply. Now, go to https-vhost.conf file and add something like this
<VirtualHost *:80>
#ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "path to your wordpress directory"
ServerName your public IP
ServerAlias your public IP
</VirtualHost>
After that, go to hosts windows file (System32/Drivers/etc/) and add your IP twice. So, it should look something like this:
localhost localhost
YOUR PUBLIC IP YOUR PUBLIC IP
Don't forget to replace YOUR PUBLIC IP and path to your wordpress directory. Now, restart your apache service. I recommend you to perform a clean wordpress instalation in your wordpress directory and use YOUR PUBLIC IP for the website URL.
Briefly, this is all about it. I'm here if you have questions or problems!

Related

Is this possible to create subdomains on local server?

I am working on a project using ZF3 and my requirenment related to local server. Suppose user 'test' login on the system then url for that user should be http://test.10.1.1.55
I have already googled for this and found a post
Create subdomains on the fly with .htaccess (PHP)
For production environment subdomain is working properly but not for development environment. My server guys said to me this is not possible for local server so my question is this posible to create subdomains on local server like as live server?
e.g.
http://test.10.1.1.55
http://test1.10.1.1.55
Note: Local server means I am talking about a system that can be accessed from others system on browser.
If you are using apache on Linux then you would go to
cd /etc/apache2/sites-avaiable/
cp 000-default.conf subname.localhost
nano subname.localhost.conf
Modify DocumentRoot to the root folder of your subdomain
Underneath add
ServerAlias subname.localhost
ServerName subname.localhost
Then remove the entry for:
<Directory /var/www/html>
</Directory>
Save and exit
Then enable your new sub
sudo a2ensite subname.localhost.conf
sudo service apache2 reload
or
sudo service apache2 restart
Re-reading your question you may be able to just use test.localhost instead of the IP.
localhost is the url for your local server by default.
In this case, test.10.1.155 becomes a name, rather than an actual IP address.
You could edit your /etc/hosts file, to add all these named entries, mapped to the same local IP address.
Some additional help about the Hosts file:
https://www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/

How to access my Wamp Server on another Local Computer

How can i access my local wamp server on another computer
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
i use this code in http.config file but not work
You could simply use the Put Online option of your WAMP Server and you can use this current system IP address and to directly access from the other computer.
Do this on system tray
Then, you could find your IP address using typing ipconfig or whatismyip.com website and then access it on another system.
As you are able to access it from the local computer that run the server by http://localhost you have two options to access it from your local area network LAN:
Using the local IP of the computer for example: http://192.168.1.20
Using the computer name for example: http://computer1/
To know your current IP:
Start -> in search field write cmd and hit enter to open the command line -> in the command line write: ipconfig you will get something like that:
Your computer IP address is the value of IPv4 Address.
To know your computer name just right click on the computer icon in the start menu then choose properties to get this screen shot:
However, for computer name method you have to be sure that every computer in your LAN has a unique name.
Update
There are some routers firmware supports local DNS on the router, so you have not need to edit the hosts files for every machine in the network. For example that I already have, dd-wrt firmware on Linksys WRT54G:
Mine wasn't working before when I tried using my computer's IP in the URL.
I found the reason to be the line in httpd.conf:
ServerName localhost:80
which I updated to be
ServerName {My comp's IP}:80
Step 1 : Press window button + R at the same time which opens the run tool of Windows.
Step 2 : Write CMD, then press 'Enter' button. This operation opens CMD terminal.
Step 3 : Then write 'ipconfig' command
Step 4 : Then note your ipv4 Address : 192.168.x.x (From Wireless Lan Adapter Wi-Fi Header) (This Ip address is needed by other computers in the place of localhost in URL)
Step 5 : Go to phpmyadmin.conf file of hosting system(Where wamp is installed...File path -> C:\wamp\alias\phpmyadmin.conf)
Step 6 : Replace this statement
<ifDefine APACHE24>
Require local
</ifDefine>
<ifDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from localhost ::1 127.0.0.1
</ifDefine>
with
Require local
Require ip 192.168.0
Note : (If your Ip is something like 192.147.x.x) then you write 'Require 192.147.0' instead of 'require 192.168.0')
Step 7 : Restart your Wamp server
Step 8 : Enter the link 192.x.x.x/phpmyadmin in the url bar of your own system from which you want to access the hosting wamp server
Step 9 : End.
If you just need to access the wamp server from another LAN PC, as some of the answers have pointed out, you can use the LAN IP or Computer-Name in the URL, as long as VirtualHost's ServerName or ServerAlias directive contains that LAN IP or Computer-Name (so Apache can return the correct website).
But if you need to use a domain-name, you'll have to edit every PC's Hosts file and update it with the correct domain-name to LAN IP address resolve (and make sure that LAN IP is assigned each time to the correct device by the Router).
Though there are much better solutions that will work for all devices (including Mac, Linux, mobile devices such as iPhones, Android phones, etc) if you have a WiFi Router that can either be flashed with one of the open firmwares or is already capable of DNS Masquerading as outlined here: Accessing Websites on a Local Network (LAN) Web Server. "DNS Masquerading" (in this context) is basically using the WiFi Router's own "Hosts file" to do the domain-name to LAN IP resolve.
Hope this helps
I couldn't connect event after doing all the above-mentioned steps. Then I uninstalled my current wampserver (3.0 version) and installed 2.5 version of wampserver. And it worked perfectly. You just need to click on 'Put Online' and you are done. Others can access your server by putting your ip address in the URL instead of localhost.
stop the wamp server and open C:\wamp64\bin\apache\apache2.4.41\conf\extra\httpd-vhosts.conf
replace
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
add
Require all granted
above the Directory closing tag.
Then turn off the windows firewall for [domain, private,
public] networks in my case only [private network] works
Re-Start wamp server

Cannot create local copy of Magento

I'm trying to create a copy of an existing Magento website on my localhost for developing purposes.
I followed all the steps listed here: Copy ec2 files to local
I also created a fake domain for my localhost so that there’s a “.” in it as I read somewhere this is required by magento. So now my localhost fake URL is something like: www.mysite.local
I have XAMPP installed on OS X 10.9.1 and I placed the magento filesystem as follows:
/Applications/XAMPP/xamppfiles/htdocs/magento/
In the database I added the local URL as follows:
update core_config_data
set value = ‘http://www.mysite.local/’
where config_id = 6;
and on local.xml I entered the following parameters:
<host><![CDATA[localhost]]></host>
<username><![CDATA[myusername]]></username>
<password><![CDATA[mypassword]]></password>
<dbname><![CDATA[mydatabase]]></dbname>
where localhost is just localhost, myusername is the username for the db I restored on my local XAMPP server, mypassword is the password for that same db, mydatabase is the name of the same db.
Still, when I browse to www.mysite.local/magento/ or www.mysite.local I don’t see anything appear.
What am I doing wrong?
Thank you so much!
If you're using a local server, here's some basic trouble shooting to help you debug:
Firstly, is the local server active? Can you visit http://localhost without it displaying server not found? If you can't, your local server is most not running. Try firing up xampp and launching Apache.
Secondly, it seems you're trying to create a virtual host for your local server. That's great! Virtual hosts allow you to create individual URLs for projects on the same server. E.g. http://myproject.dev.
However, you first need to make sure that the server understands what you're doing.
You will need to create a virtual host in your server if you haven't already.
I see you're using xampp. What you need to do is navigate to your xampp install, and edit your apache/conf/extra/httpd-vhosts.conf file, which is the file xampp recommends you use solely for virtual hosts.
Reading: Setting Up Virtual Hosts for XAMPP
For example, in Apache, a hosts config file may look like this:
# Base
<VirtualHost *:80>
DocumentRoot "X:/"
ServerName localhost
</VirtualHost>
# Project - Some Project of Mine
<VirtualHost *:80>
DocumentRoot "X:/projects/myproject/public"
ServerName myproject.dev
ErrorLog X:/projects/myproject/logs/apache.error.log
CustomLog X:/projects/myproject/logs/apache.access.log common
php_value error_log X:/projects/myproject/logs/php.error.log
</VirtualHost>
(navigating to myproject.dev displays the files in my X:/projects/myproject/public directory)
This answer is not to explain virtual hosts to you however. There are plenty of amazing resources online to help you get started with setting up your own.
Don't forget to restart your server when you add a virtual host!
If this is already set up, is your computer's hosts file set up to point to your server?
Your hosts file on your computer is used to tell it to do certain actions when you enter a matching url in your browser.
Reading: The Hosts File and what it can do for you
Reading: How to Edit Your Hosts File
For example, using the apache conf file settings above, my hosts file must also include:
# My project - Localhost
127.0.0.1 myproject.dev
It tells my computer to send the request to my local server (at localhost) when I use the URL myproject.dev. The local server then picks up the request, sees that you're accessing myproject.dev and checks if it has any virtual hosts matching that name. Well, whaddya know, it does! It then looks at the DocumentRoot setting for the location of the server files, and continues the process. Think of your hosts file as a local DNS of sorts.
If you've just added the site to your hosts file, it may take a few minutes to start resolving correctly. Wait a little, clear your browser cache and try again.
Finally, if these steps are done, and you're receiving nothing, it may be a server configuration problem, or a .htaccess issue.
If you're running on windows, you can check your event log for apache server errors. If you have set up logging on the virtual host, you can check those files to see if it's picking up your requests, and what it's doing with them if it is.
Most issues after that point will at least yield a visible error in your browser (or a blank page).
I hope this helps!
Also checking the magento error logs could tell you what the issue is, assuming it's actually hitting magento at all at this point.
As Sean mentioned above, one of the most common problems I've seen when copying a magento site is accidentally omitting the .htaccess file - make sure it's present in your site root.
If you tested your site before making the change to core_config_data, then you can also try deleting everything in var/cache and var/session. Also make sure that the web user has write permissions on var.
Regards
Hans

Run wamp through lan or wan and as root website

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

Virtual not working in other system wamp

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.

Categories