Accessing php file from remote host - php

I've a host running with centos 7 minimal in which I have set up apache server running php inside docker. My apache-config.conf file looks like :-
<VirtualHost xxxx.xxxx.com:80>
ServerAdmin root#xxxx.xxxx.com
DocumentRoot /var/www/dl
<Directory “/var/www/site“>
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error_log
CustomLog ${APACHE_LOG_DIR}/access_log combined
</VirtualHost>
if the host name of the remote centos 7 machine is xxxx.xxxx.com, how can I access the php content in my windows machine running firefox browser?
Thanks.

Replace xxxx.xxxx.com in your apache config to localhost and try to open in browser http://localhost.

Related

is it possible to configure PHP to use virtualhost

Actually, I downloaded PHP7.2.7 safe thread from PHP's website(php.net) and I don't know if it is possible I can configure PHP to setup a virtualhost like we can do using XAMPP
You can try below configuration:
1) Entry in hosts file as below
127.0.0.1 example.com
2) Set virtual host in httpd-vhosts.conf as below
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/example/public_html"
ServerAlias quickstart.com
<Directory "/var/www/example/public_html">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
PHP has a built-in web server, but is has limited capability. It does not provide all the configuration options a complete web server does. It does not do VirtualHost.
If you need VirtualHost, you will have to include it as a module inside Apache (or other web server). The module will be global. If your pages in a VirtualHost do not need PHP, PHP remains dormant and does nothing.
PHP isn't a web server, you need to create a VirtualHost in Apache. If you're using Linux, open up httpd.conf or /etc/apache2/sites-enabled/000-default.conf
and enter the following lines.
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Make sure to restart your web server/apache in order to these changes to work.

Serve Laravel app with Apache (wampserver) to access from other computers in same LAN

I need to access my Laravel app that is served with Apache (wampserver) from other computers in the same LAN.
OS: Windows 8.1
Wampserver version: 3.0.6
Apache version: 2.4.23
I can access my app from other computers by the following URL:
http://192.168.12.13/scms/public/
The following URLs also work:
http://192.168.12.13/scms/public/categories/create
But it does not work when I submit POST request from the above URL. It redirects to the following -
http://192.168.12.13/categories
And shows "Not Found". So, it does not work.
To solve the issue, I have setup virtual host for my app which works perfectly in my own computer. But I cannot access it from other computers.
My setup:
In file:
C:\wamp64\bin\apache\apache2.4.23\conf\httpd.conf
Added this line:
Listen 192.168.12.13:80
In file:
C:\wamp64\bin\apache\apache2.4.23\conf\extra\httpd-vhosts.conf
Full code:
# Virtual Hosts
# wamp
<VirtualHost *:80>
DocumentRoot "C:\wamp64\www"
ServerName localhost
</VirtualHost>
# scms
<VirtualHost *:80>
DocumentRoot "C:\wamp64\www\scms\public"
ServerName local.scms-ananta.com
<Directory "C:\wamp64\www\scms\public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
In file:
C:\Windows\System32\drivers\etc\hosts
Added the following lines:
127.0.0.1 local.scms-ananta.com
192.168.12.13 local.scms-ananta.com
With the above setup, I can perfectly work with my app using the following URL in my own computer:
http://local.scms-ananta.com
But I cannot access it from other computers on my network.
Kindly note, serving with php artisan serve will not serve my purpose. I need to serve it with Apache.
Any help is highly appreciated.
First of all editing host file will not help you while accessing from other computer unless you also edit all of those PC's host file. So it would be best to access with IP.
Now problem with your configuration is that for serving/deploying laravel website in your server you have to put public folder as your document root.
Follwoing is your configuration for localhost
# wamp
<VirtualHost *:80>
DocumentRoot "C:\wamp64\www"
ServerName localhost
</VirtualHost>
Change the documentroot to the following will solve your problem.
DocumentRoot "C:\wamp64\www\scms\public"

Local wifi network cannot connect to XAMPP apache server running on mac

I have installed XAMPP and have an apache server running on my mac. When I go to the address http://192.168.1.132:80/testproject/test.php from the mac's browser it works (simply echos the word 'success'). When I go to the exact same address from another device on the network it says it cannot connect or similar.
I setup a virtual host, and if I replace the servername with my IP I get the same result (works from the mosting mac but not from other devices on network)
# localhost
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
# My custom host
<VirtualHost *:80>
ServerName wgaamwserver.local
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/wgaamwserver.local-error_log"
</VirtualHost>
I have run "ps -eaf | grep httpd" in terminal while XAMPP was not running to check incase of other httpd services. I got the below output:
501 19343 18144 0 4:57pm ttys000 0:00.00 grep httpd
I have been searching everywhere for a solution to this but googling mostly turns up issues relating to either windows firewall on the host blocking the remote connections, or the apache server simply not responding when connecting from the host. Obviously neither are the case here.
localhost can use only in your`s device, rename them
Try add in hosts file (At another device) 192.168.1.132 wgaamwserver.local and go to wgaamwserver.local

WAMP Gives the Forbidden Error with Static IP Address [duplicate]

I know this question has been asked a lot of times
I followed Most of the answers in the internet But I still get the same Message
403 Forbidden
You don't have permission to access / on this server.
It is weird that when I access using the same PC to localhost:1234 it runs normally but if I access using my IP address 192.168.0.188:1234
Also which is really weird is that I tried to install WAMP on other PC and without any configuration I could access to that PC.
So I thought it's because McAfee and Firewall so I open port on Widows and McAfee and nothing changed also I turned off Firewall and still nothing change.
Then for no reason I opened port through the Router “port forwarding” and still nothing changed.
I don't think that it's because my configuration in WAMP since I am still able to get this 403 Forbidden Message and also by using other PC without any configuration I could access it.
Both PCs are setup like this:
Windows 8 Pro
WAMP Wampserver: 2.4
Apache Version: 2.4.4
PHP Version: 5.4.12
MySQL Version: 5.6.12
The accessible PC uses Microsoft Security Essentials.
The inaccessible PC uses McAfee Internet Security.
I tried to turn off WAMP and start IIS For Microsoft Server (I works perfectly From any PC) but WAMP is still not not working
I followed these tutorial:
How to Access WAMP Server in LAN or WAN
Install & Setup Virtual Host Guide for WAMP
Install & Setup LAN & Worldwide Access Guide for WAMP
And the Stack Overflow answers here:
Cannot access wamp server on local network
WAMP 403 Forbidden message on Windows 7
If you are using WAMPServer 3 See bottom of answer
For WAMPServer versions <= 2.5
By default Wampserver comes configured as securely as it can, so Apache is set to only allow access from the machine running wamp. Afterall it is supposed to be a development server and not a live server.
Also there was a little error released with WAMPServer 2.4 where it used the old Apache 2.2 syntax instead of the new Apache 2.4 syntax for access rights.
You need to change the security setting on Apache to allow access from anywhere else, so edit your httpd.conf file.
Change this section from :
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
Allow from localhost
To :
# onlineoffline tag - don't remove
Require local
Require ip 192.168.0
The Require local allows access from these ip's 127.0.0.1 & localhost & ::1.
The statement Require ip 192.168.0 will allow you to access the Apache server from any ip on your internal network. Also it will allow access using the server mechines actual ip address from the server machine, as you are trying to do.
WAMPServer 3 has a different method
In version 3 and > of WAMPServer there is a Virtual Hosts pre defined for localhost so you have to make the access privilage amendements in the Virtual Host definition config file
First dont amend the httpd.conf file at all, leave it as you found it.
Using the menus, edit the httpd-vhosts.conf file.
It should look like this :
<VirtualHost *:80>
ServerName localhost
DocumentRoot D:/wamp/www
<Directory "D:/wamp/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
Amend it to
<VirtualHost *:80>
ServerName localhost
DocumentRoot D:/wamp/www
<Directory "D:/wamp/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Hopefully you will have created a Virtual Host for your project and not be using the wamp\www folder for your site. In that case leave the localhost definition alone and make the change only to your Virtual Host.
Dont forget to restart Apache after making this change
For Apache 2.4.9
in addition, look at the httpd-vhosts.conf file in C:\wamp\bin\apache\apache2.4.9\conf\extra
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot C:/wamp/www
<Directory "C:/wamp/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require local
</Directory>
</VirtualHost>
Change to:
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot C:/wamp/www
<Directory "C:/wamp/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
changing from "Require local" to "Require all granted" solved the error 403 in my local network
I got this answer from here. and its works for me
Require local
Change to
Require all granted
Order Deny,Allow
Allow from all
To expand on RiggsFolly’s answer—or for anyone who is facing the same issue but is using Apache 2.2 or below—this format should work well:
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 ::1
Allow from localhost
Allow from 192.168
Allow from 10
Satisfy Any
For more details on the format changes for Apache 2.4, the official Upgrading to 2.2 from 2.4 page is pretty clear & concise. Key point being:
The old access control idioms should be replaced by the new
authentication mechanisms, although for compatibility with old
configurations, the new module mod_access_compat is provided.
Which means, system admins around the world don’t necessarily have to panic about changing Apache 2.2 configs to be 2.4 compliant just yet.
For those who may be running WAMP 3.1.4 with Apache 2.4.35 on Windows 10 (64-bit)
If you're having issues with external devices connecting to your localhost, and receiving a 403 Forbidden error, it may be an issue with your httpd.conf and the httpd-vhosts.conf files and the "Require local" line they both have within them.
[Before] httpd-vhosts.conf
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local <--- This is the offending line.
</Directory>
</VirtualHost>
[After] httpd-vhosts.conf
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
</Directory>
</VirtualHost>
Additionally, you'll need to update your httpd.conf file as follows:
[Before] httpd.conf
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
# onlineoffline tag - don't remove
Require local #<--- This is the offending line.
</Directory>
[After] httpd.conf
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
# onlineoffline tag - don't remove
# Require local
</Directory>
Make sure to restart your WAMP server via (System tray at bottom-right of screen --> left-click WAMP icon --> "Restart all Services").
Then refresh your machine's browser on localhost to ensure you've still got proper connectivity there, and then refresh your other external devices that you were previously attempting to connect.
Disclaimer: If you're in a corporate setting, this is untested from a security perspective; please ensure you're keenly aware of your local development environment's access protocols before implementing any sweeping changes.

Php website virtual host

I'm new to php, I did installed xampp-win32-1.8.2-2-VC9-installer on my window7 desktop pc. PHP page run from C:\xampp\htdocs but when i create virtual host and tried to access php file in d:\web\ it shows access forbidden.
my host file code
127.0.0.1 localhost1
my httpd-vhost file code
NameVirtualHost *
<VirtualHost *>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost localhost1:80>
DocumentRoot "d:/web/test.php"
ServerName localhost1
<Directory "d:/web/test.php">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I don't know now where i have to change
It's a file permissions derived issue. Try changing NTFS permissions in "C:/xampp/htdocs" to allow read and execute permissions to the user that is running the web server, you should be able to see who that user is in the Apache configuration file, tipically "apache" which is the equivalent to IUSR in IIS.

Categories