Linux server subdomains for multiple sites - php

I have 2 websites i want to host on a Linux machine using Apache server. Since at this point i am unable to acquire a domain name, i access the server through IP, since I'm not required to have one yet.
The first site is comprised of a few HTML pages and is located in /var/hostroot/lifeonearth/{all files here} and the other is comprised of several PHP pages located in /var/hostroot/webDarts/{all files here}.
By default when i go to my IP address, it takes me to the default "Your Apache server is working" page. So from here on, how do i make it so that i can access each site through some sort of subdomain like lifeonearth.(my IP) or webDarts.(my IP) or, am I supposed to access them throug different ports. If it's the latter, how do I go about it?

We have 2 website names.
1. example1.test.local (/var/www/example1)
2. example2.test.local (/var/www/example2)
Now Lets create two files called example1 and example2 in /etc/apache2/sites-available.
example1 file looks like as follows
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/example1
ServerName example1.test.local
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/example1>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
as the same way create another file called example2 and modify the following lines
DocumentRoot /var/www/example2
ServerName example2.test.local
and
<Directory /var/www/example2>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
rest of the file will same as example1.
Then enable those two sites
a2ensite example1
a2ensite example2
Then do apache service restart.
Now we have to do DNS pointing
If your Linux machine is LOCAL then go to your Windows machine where you want to access these websites and open the following file C:\Windows\System32\drivers\etc\hosts
and mention your ip and website name
192.168.249.101 example1.test.local
192.168.249.101 example2.test.local
Thats it! If you found any difficulties please let me know.
I have replicated this scenario at my end and it works for me. Hope it will work for you!

Related

Cannot access specific pages in laravel on XAMPP

Laravel installation on XAMPP only shows pages in /public. When i try to go a page like /business/register which is in /resources. I get a 404 page. I've set the vhosts file on XAMPP properly. The code is below.
I've tried almost everything and even checked .htaccess. Couldn't find the problem.
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/pos"
ServerName pos.dev
<Directory "C:/xampp/htdocs/pos">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
With this config, it should work
check to make sure that there is .htaccess in you public folder
DocumentRoot "C:/xampp/htdocs/pos/public"
<Directory "C:/xampp/htdocs/pos/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Direcroty>
i recommended using homestead https://laravel.com/docs/5.7/homestead

Virtual Host: LAN access, WAMP, Windows 7, Apache 2.4.4, Php 5.4.16; returns dont-have-permission-to-access-on-this-server

Before I start.. Good day to all! :)
I have problem with my WAMP virtual host.. the other computer on our LAN keeps receiving error forbidden-you-dont-have-permission-to-access-on-this-server..
Below is the current settings I have:
/httpd.conf
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
Options FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "c:/wamp/www"
<Directory "c:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
Order Deny,Allow
Allow from all
Allow from 127.0.0.1
Allow from ::1
Allow from localhost
</Directory>
/phpmyadmin.conf
Alias /phpmyadmin "c:/wamp/apps/phpmyadmin4.0.4/"
# to give access to phpmyadmin from outside
# replace the lines
#
# Order Deny,Allow
# Deny from all
# Allow from 127.0.0.1
#
# by
#
# Order Allow,Deny
# Allow from all
#
<Directory "c:/wamp/apps/phpmyadmin4.0.4/">
Options Indexes FollowSymLinks ExecCGI
AllowOverride all
Order Deny,Allow
Allow from all
Allow from 127.0.0.1
Allow from ::1
Allow from localhost
</Directory>
/httpd.vhosts.conf
Listen 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
ServerName www.ecommerce.local
ServerAlias ecommerce.local
DocumentRoot C:/wamp/www/ecommerce
ErrorLog "C:/wamp/www/ecommerce/logs/error.log"
CustomLog "C:/wamp/www/ecommerce/logs/access.log" common
<Directory />
Require all granted
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 127.0.0.1:80>
ServerName localhost
DocumentRoot C:/wamp/www/
</VirtualHost>
Also...
tried to ping from other computer response is success
tried to turn off firewall for both computer
tried to add everyone in www's folder properties
I have tried other solutions I found but still to no avail.. I can access "http://ecommerce.local" but the other computer on our LAN recieves forbidden-you-dont-have-permission-to-access-on-this-server error..
does it have something to do with our network settings? the other computer is also in the same settings... my ip: 192.168.1.198 and the other computer is 192.168.1.192
Access to Apache has nothing to do with windows access rights on a Windows system. Its all to do with what you tell Apache to allow in.
Also you are using a mixture of Apache 2.2 and Apache 2.4 syntax in most of your access declarations.
Apache 2.2
Allow .....
Apache 2.4
Require .....
Require local - means 127.0.0.1 and localhost and ::1
Require ip - specifies a single ip (192.168.0.10) or a range of ip's (192.168.0)
Apache does not seem to complain yet, but its probably best to stick to the Apache 2.4 syntax.
This first change you made is very dangerous and should be changed to this unless you really wanted to give unlimited access to the servers C:\ drive to anyone that hacks your Apache server.
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
Options FollowSymLinks Includes
AllowOverride All
Require all denied
</Directory>
Again here use Apache 2.4 syntax and be specific about who you want to allow in.
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "c:/wamp/www"
<Directory "c:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
Require local
Require ip 192.168.0
</Directory>
Now to your Virtual Host definitions
You dont need this Listen 127.0.0.1:80
Put the localhost definition first so it becomes the default domain, so if a random or misspelt domain name is used this will load. If that comes from an internet ip then they will get an error as only ip's from within you network are allowed access. This isreally for later when you decide to open up your site to a wider audience.
Also dont specify 127.0.0.1 on the line, you want it to be listen any incoming ip not just this machine.
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/wamp/www"
<Directory "c:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
Require local
## May not want to let people access the wamp page so leave this off if not.
Require ip 192.168.0
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.ecommerce.local
ServerAlias ecommerce.local
DocumentRoot "C:/wamp/www/ecommerce"
## not a good idea to have logs visible under the DocumentRoot folder
## should really go in C:\wamp\logs
## But I assume you want developers to have easy access during development
## ErrorLog "C:/wamp/logs/ecommerce_error.log"
## CustomLog "C:/wamp/logs/ecommerce_access.log" common
ErrorLog "C:/wamp/www/ecommerce/logs/error.log"
CustomLog "C:/wamp/www/ecommerce/logs/access.log" common
<Directory />
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require local
Require ip 192.168.0
</Directory>
</VirtualHost>
Now you may want to allow your local developers access to phpMyAdmin. If so you will need to change your C:\wamp\alias\phpmyadmin.conf file as well.
<Directory "c:/wamp/apps/phpmyadmin4.0.4/">
Options Indexes FollowSymLinks ExecCGI
AllowOverride all
Require local
Require ip 192.168.0
</Directory>
Or you could be more specific here and only allow certain ip's to use phpMyAdmin by using something like this
Require ip 192.168.0.10 192.168.0.11 192.168.0.12
Just as a side note. I personally like to move my VistualHosts sites completely out of the C:\wamp\ folder structure. So I would have placed my ecommerce folder somewhere like C:\websites\ecommerce\www\. This keeps any confusion about access rights to a complete minimum and also if I need to upgrade WAMP, my website code is never in any danger when I make a silly typo.
ADDITIONAL INFO:
Now to be able to access your new site as ecommerce.local or www.ecommerce.local you will have to make a chnage to your HOSTS file.
C:\windows\system32\drivers\etc\hosts
On the PC running WAMP add this line:
127.0.0.1 ecommerce.local
On the other PC's do this
192.168.0.10 ecommerce.local
Where 192.168.0.10 is the ip address of the PC running WAMP
Then reboot the PC's or do these 2 commands from a command window started as Administrator
net stop "DNS Client"
net start "DNS Client"
I have already solved my own issue... I have not shared my folder for anyone to view... so what I did is:
Right Click the project folder
On folder options go to sharing tab
Click on advance sharing
advance sharing option will open then tick share this folder
click permissions
permissions option will open then choose whom you would like to share your folder
I chose everyone then below tick full control (*for trial purposes only; recommended tick only Read)
then click ok for all the opened options

Getting a 403 error after upgrading to php5.5

OK I am new to ASKING questions on stackoverflow, but I need to get this figured out. I have a VPS with Apache installed Running Ubuntu 12.04 LTS. I downloaded a php script which required php 5.4+ but I had 5.3 installed. Then I followed the instructions located at this link.
While doing the upgrade, the installer told me that my php.ini file was manually changed. I believe I did this in order to view the errors on screen with the "display_errors=on" variable a long time ago. I therefore selected the option to KEEP and USE the old version of php.ini. Once the installation was done and the apache server restarted. I went to my chrome browser and pressed "refresh" and to my dismay, "403 Forbidden".
Here is the conf file for the virtual server:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /home/{usr}/Public/
# Indexes + Directory Root.
DirectoryIndex index.html index.shtml index.php
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory /home/{usr}/Public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /home/{usr}/Public/log/{server}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /home/{usr}/Public/log/{server}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
I obscured the username to {usr} and the folder to {server} to keep anonymity. This file was created BY ME, by putting it together with some other example file. I'm not sure if this is correct, all I know is that before this upgrade, everything was working fine!
I also "LL"'d the "Public" folder and here's what I found:
drwxrwxrwx 28 {usr} {usr} 4096 Sep 4 01:09 Public/
It seems that all the folders under it have the same permission. Please help and if there are any questions, feel free to ask. I've been doing this for many years but by no means would I call myself an "expert".
Thanks in advance.
Did you also upgrade Apache 2 ?
Apache 2.4 has a new user rights policy system : http://httpd.apache.org/docs/2.4/upgrading.html#run-time

Mamp Pro alias to directory?

Trying to add this simple code to my httpd.conf but it gets overwritten each time I start the server
Alias /ws /path/to/public
<Directory /path/to/public>
   Order allow,deny
   Allow from all
</Directory>
There are spots in mamp pro to enter stuff but I can't find any documentation on what they do.
http://wes.io/L9t9/content
Help?
The answer might be a little late... but for everyone searching
The first field "Customized virtual host directory Settings will be added to the directory section:
<Directory /path/to/public>
Order allow,deny
Allow from all
#My directory options
</Directory>
The second field "Customized virtual host general settings" will be pasted in the virtual host section:
<VirtualHost *:80>
#My virtual host options
</VirtualHost>
So in your case, just put everything inside the SECOND box and it will look like this with default settings:
<VirtualHost *:80>
ServerName your-servername.dev
DocumentRoot "/your/path/to/public"
<Directory "/your/path/to/public">
Options Includes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Alias /ws /path/to/public
<Directory /path/to/public>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
You can always check what happened in the following path:
/Users/<YOUR-USERNAME>/Library/Application Support/appsolute/MAMP PRO/httpd.conf

WAMP Server ERROR "Forbidden You don't have permission to access /phpmyadmin/ on this server."

Hi Friends previously I am using XAMP Server but when I install joomla Templates it creates alots of error. Now I installed the WAMP, but the issues are:
1. I can access with 127.0.0.1, but I cant access with "localhost".
2 When i access phpmyadmin i get this error.
Forbidden You don't have permission to access /phpmyadmin/ on this server.
Alias /phpmyadmin "c:/wamp/apps/phpmyadmin3.4.5/"
# to give access to phpmyadmin from outside
# replace the lines
#
# Order Deny,Allow
# Deny from all
# Allow from 127.0.0.1
#
# by
#
# Order Allow,Deny
# Allow from all
#
After changing, it will look like this
<Directory "c:/wamp/apps/phpmyadmin3.4.5/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
</Directory>
After this just restart Wamp
Go to C:\wamp\alias. Open the file phpmyadmin.conf and change
<Directory "c:/wamp/apps/phpmyadmin3.5.1/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
to
<Directory "c:/wamp/apps/phpmyadmin3.5.1/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>
problem solved
Change httpd.conf file as follows:
from
<Directory />
AllowOverride none
Require all denied
</Directory>
to
<Directory />
AllowOverride none
Require all granted
</Directory>
So none of the above stuff worked for me. Except this:
edit httpd.conf,
find the line
Listen 80
and change to
listen 0.0.0.0:80
if you are running windows 8, its got something to do with using ipv6 instead of ipv4
Go to C:\wamp\alias.
Open the file phpmyadmin.conf and add
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from MACHINE_IP
Change in following file \bin\apache\apache2.2.22\conf\httpd.conf
Replace Listen 80 with Listen 0.0.0.0:80
Replace
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
with
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
Replace
onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
with
onlineoffline tag - don't remove
Order Deny,Allow
Allow from all
Allow from 127.0.0.1
in \wamp\alias\phpmyadmin.conf
replace
<Directory "c:/wamp/apps/phpmyadmin3.4.10.1/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
with
<Directory "c:/wamp/apps/phpmyadmin3.4.10.1/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
</Directory>
Tested on windows localhost.
Note : Please consider RigsFolly's comment also.
For WampServer 2.2 with Apache 2.4.2 I ended up with:
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require local
To solve this, I opened httpd.conf and changed the following line:
Allow from 127.0.0.1
to:
Allow from 127.0.0.1 ::1
I faced this problem
Forbidden You don't have permission to access /phpmyadmin/ on this server
Some help about this:
First check you installed a fresh wamp or replace the existing one. If it's fresh there is no problem, For done existing installation.
Follow these steps.
Open your wamp\bin\mysql directory
Check if in this folder there is another folder of mysql with different name, if exists delete it.
enter to remain mysql folder and delete files with duplication.
start your wamp server again. Wamp will be working.
just add following line in wamp/alias/phpmyadmin.conf
Allow from ::1
so it will look something like this depending your phpmyadmin version.
<Directory "c:/wamp/apps/phpmyadmin3.5.1/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
</Directory>
If its possible uninstall wamp then run installation as administrator then change you mysql.conf file like that
<Directory "c:/wamp/apps/phpmyadmin3.5.1/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Allow,Deny
Allow from all
Allow from all
</Directory>
Not: Before I reinstall as admin the solution above didn't work for me
Change the file content of c:\wamp\alias\phpmyadmin.conf to the following.
<Directory "c:/wamp/apps/phpmyadmin3.4.5/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
</Directory>
Here my WAMP installation is in the c:\wamp folder. Change it according to your installation.
Previously, it was like this:
<Directory "c:/wamp/apps/phpmyadmin3.4.5/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
Restart your Apache server after making these changes.
In your apache config file (../bin/apachex.y.z/cong/httpd.conf)
Just change
< Directory "c:/wamp/www/" >
...
...
"Require local" ===> "Require all granted"
< /Directory >
This allows other pc's to access (to read) your web folder.
I had done below changes for new phpmyadmin4.0.4 in httpd.conf file
<Directory />
AllowOverride none
Require all granted
</Directory>
and phpmyadmin.conf
<Directory "c:/wamp/apps/phpmyadmin4.0.4/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>
and restart my server.
None of the above answers worked for me, or where unsafe (as some pointed out, using Allow from all can make your files and data accessible to the outside world).
Open the c:\wamp\alias\phpmyadmin.conf file and change
Allow from 127.0.0.1
to
Allow from 127.0.0.1 ::1
Explanation:
On most computer systems, localhost resolves to the IP address 127.0.0.1, which is the most commonly used IPv4 loopback address, and to the IPv6 loopback address ::1 (source: https://en.wikipedia.org/wiki/Localhost)
The resolution of the name localhost into one or more IP addresses is configured by the following lines in the operating system's hosts file:
127.0.0.1 localhost
::1 localhost
to see your hosts file, go to c:\Windows\System32\drivers\etc\HOSTS
notice the above lines are commented out with the note: # localhost name resolution is handled within DNS itself.
On my machine, on Win7, I also noticed the following:
localhost\phpmyadmin did not work on Chrome, but worked on IE11
127.0.0.1\phpmyadmin worked on Chrome
comment Require local from httpd.conf
"#Require local"

Categories