juno
juno

Reputation: 41

How to set permissions for files in xampp htdocs folder?

I created a website using xampp local host and the database information is stored in htdocs/config.cfg. If I type in 192.168.0.100/config.cfg the browser display the sql database security information. Can any one help me how to overcome this issue and how clients can access my site as domain.com instead of 192.168.0.100 not by editing drivers/etc/hosts file.

Upvotes: 2

Views: 16052

Answers (2)

Lonkey
Lonkey

Reputation: 193

You need to set up port forwarding for your computer in your router's configuration to make your web server accessible from outside of your local area network. Here's a little step-by-step tutorial:

  1. Assign a statical IP to your computer. This can be done by editing the /etc/network/interfaces file to convert your DHCP network configuration to a static IP configuration or by editing your router's configuration.
  2. Set up port forwarding in your router's configuration. Forward all incoming TCP connections on port 80 to your computer to port 8080.
  3. Change the listening port of your web server to 8080.

Scheme: Port forwarding rule

Now, everyone should be able to access your web server using your public IP adress.

The access to your config.cfg can simply be restricted by using .htaccess file or by creating a new virtualhosts. I would recommend the second option because you need to create a new virtualhosts for your domain anyway.

Please note that XAMPP is not designed to be used for a production server!

For performance and security reasons, I do strongly recommend to use Apache or nginx with the current stables of PHP 7.0.x and MySQL.

Upvotes: 1

Denton
Denton

Reputation: 96

  1. Use virtualhosts https://delanomaloney.com/2013/07/10/how-to-set-up-virtual-hosts-using-xampp/

  2. If you using php, use .php file ext for all files instead blahblah.inc and blahblah.cfg. Right way is: blahblah.cfg.php

  3. If you need .cfg and inc extension, configure vhost or apache httpd.conf:

AddType application/x-httpd-php .inc

AddType application/x-httpd-php .cfg

(you need check your server/hosting and configuring it too if you upload your code)

  1. Create sites with "web" directory, and your document_root using it. Eg.: www.blabla.tld load c:\xampp\htdocs\mysite\web and you store your config files outside from "web" dir.

Upvotes: 1

Related Questions