Run wamp through lan or wan and as root website - php

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

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 change apache domain name(locally) for a laravel site on ubuntu?

Good day guys in my application I want to change the normal http://127.0.0.1:8000/ that laravel uses to serve sites when one runs php artisan serve to example.com and this should have sub domains like app1.example.com and app2.example.com.
In the main time I have tried to create a virtual host for my site by creating a .conf file inside of etc/apache2/sites-available/example.com.conf and here is how it looks:
<VirtualHost *:80>
ServerAdmin webmaster#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /home/tangaye/sites/example/public/index.php
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
After doing that I enable the virtual host I created by running sudo a2ensite example.com.conf and sudo service apache2 reload to reload apache2 configuartions and sudo service apachIe2 restart from the on I added the address my site points to in /etc/hosts:
127.0.0.1 localhost example.com
127.0.1.1 tangaye
After doing all this when I run php artisan serve from my laravel site directory I still see my site being launch like this:
Laravel development server started: http://127.0.0.1:8000
After all I have done I expected to rather see this:
Laravel development server started: example.com
The worst thing is when I try to access example.com in my browser it tends to search for it on the internet.
At this point I don't really understand what really I'm doing. All I want is to be able to customize my site domain name LOCALLY and add other sub domains.
Will appreciate any help. Thanks!
You can't specify port numbers in /etc/hosts. There's no way to get around that part.
You should be able to just throw example.com after the localhost definition:
127.0.0.1 localhost example.com
and then it will also resolve to 127.0.0.1 ... then it's just a matter of name-based hosting configurations in Apache. Your file looks pretty good, but DocumentRoot is specifying a folder, not a file. Remember to do an a2ensite to enable your site (it's really just creating a symlink in sites-enabled pointing at the sites-available file) and restart Apache.
To avoid your browser interpreting a web address as a search term, you can prefix it with http://
Note that PHP's built-in development server and Apache are two completely separate ways to serve a PHP webpage/app.
php artisan serve is a rapid development tool, allowing for easy access to a PHP project without the need to set up a full-fledged web server (e.g. Apache). All you need is PHP and you can run Laravel or other PHP projects. (It's also important to note that this should be used for development only, never in production.)
Apache, on the other hand, is a full-featured web server, with all the bells and whistles, including virtual host management. And it works over port 80, so no need to add the port to your URLs.
If you want to use a named URL in your development environment, you should:
Install Apache
Configure Apache, including virtual hosts and PHP configuration.
Modify your hosts file to point your chosen development domain name to your local machine (or the machine serving your app, which could be a Vagrant box, Docker, etc. if you choose to use such tools).
Don't bother using php artisan serve at all.

Access vhost config website in another PC

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

wamp localhost not working (I know there are few posts but mine is quite weird)

Ok, let me try to shorten things so less to read.
wamp works fine for the past few months, then I started to learn laravel4 and optionally requires vhost and rewrite_module which works pretty well that when I type in larave.intro as URL it works.
Now I'm trying to use wamp again just going to localhost AND page says
The title of the page does say 404 Not Found.
Read a few threads, some said go apache->service->Test port 80 and see if there are other ports running port 80. It says
Your port 80 is actually used by : Server: Apache/2.4.4 (Win32) PHP/5.4.16
which means my apache is the only one running it isn't it...
this already makes me curious and feeling weird, well alright then I go change my port or 8000 in the httpd.conf restart my wamp. and uses localhost:8000 alright now wamp works and I test port 80 again it says
Your port 80 is actually not used.
So nothing is running on my port 80 why can't wamp use it?
And, at first I thought it's my vhost so I deleted the vhost and in my host I deleted 127.0.0.1 laravel.intro too and runs my wamp back to port 80...still doesn't work.
I was thinking then fine I will just use port 8000 BUT then my vhost won't work :(
I was using this as my vhost before
<VirtualHost *:80>
DocumentRoot "J:\wamp\www\laravel4-basic\public"
<Directory "J:\wamp\www\laravel4-basic\public">
Options FollowSymLinks Indexes MultiViews
AllowOverride All
</Directory>
ServerName laravel.intro
</VirtualHost>
and in host it's 127.0.0.1 laravel.intro
now since I'm using port 8000 I suppose I should change the vhost too? so I changed to
<VirtualHost *:8000>
and laravel.intro doesn't work. laravel.intro works if I'm using port 80 with virtualhost: *80 and in URL if I type 127.0.0.1:8000 what popped up is laravel.intro instead of the wamp index and if I use localhost:8000 wamp index comes out.
I'm pretty much so confused now.
Side note:php Admin works fine if I'm using port 80 and in URL I just go localhost/phpmyadmin
Anyone knows what I'm talking about here? I'm getting confused a bit myself at the end and anyone can get me back to port 80 with everything works?
(if I have to change port then oh wells better than one works and the other one doesn't)
Please give me some suggestions thanks ~!
completely remove the wamp files and just clean the temp files and www folder where you have installed and restart the system and then reinstall WAMP and run
The error message means apache is running, so this is a good thing.
By specifying the local host url you are requesting a file called index.htm, index.html or index.php (any one of them depending on your configuration), and the error is merely telling you that the file is not there.
Check that one of these files are in the directory : J:\wamp\www\laravel4-basic\public
If you do that and the problem persists, look for the *error_log in the WAMP log directory. The 404 error message means a file is missing. The error log will tell you which file it is looking for that is missing.
I'm using Laravel 4.1 installed in a Windows OS System with WAMP Server and I get it working using the following routine:
To avoid the conflict between localhost and your virtualhost project you can config as follow:
In the httpd.conf remove the # from the following line:
#Include conf/extra/httpd-vhosts.conf
to
Include conf/extra/httpd-vhosts.conf
Later you need to modify your httpd-vhosts.conf file from c:/wamp/bin/apacheX.X.X/conf/extra folder (i'm using Windows 8 OS). Here you need to add the following VirtualHosts:
#Localhost
<VirtualHost localhost:80>
ServerName localhost
DocumentRoot "c:/wamp/www/"
</VirtualHost>
#My VirtualHost
<VirtualHost appdomain.dev:80>
ServerName appdomain.dev
DocumentRoot "c:/wamp/www/app/public"
</VirtualHost>
In this virtualhost app is the project folder and appdomain.dev is the host that I specify in the hosts windows file located in c:/windows/system32/drivers/etc/hosts:
127.0.0.1 appdomain.dev
As you can see it needs two VirtualHosts because if you use only the second VirtualHost you overwrite the localhost access, then you need to specify the Localhost access as a new top virtualhost.
I hope it serves you.
This problem happen cause of port 8000 has been reserved so try to change it by the following :
In your command line prompt try :
php artisan serve --port=8080
Go to your browser with : localhost:8080
by that it works with me.

Bitnami Eclipse PHP

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 :-)

Categories