简体   繁体   English

如何设置xampp htdocs文件夹中文件的权限?

[英]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. 我使用xampp本地主机创建了一个网站,数据库信息存储在htdocs / config.cfg中。 If I type in 192.168.0.100/config.cfg the browser display the sql database security information. 如果我输入192.168.0.100/config.cfg,浏览器将显示sql数据库安全信息。 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. 任何人都可以帮助我如何解决此问题以及客户端如何通过不编辑driver / etc / hosts文件来以domain.com而不是192.168.0.100的身份访问我的网站。

  1. Use virtualhosts https://delanomaloney.com/2013/07/10/how-to-set-up-virtual-hosts-using-xampp/ 使用虚拟主机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 . 如果使用php,请对所有文件使用.php文件扩展名blahblah.incblahblah.cfg Right way is: blahblah.cfg.php 正确的方法是: blahblah.cfg.php

  3. If you need .cfg and inc extension, configure vhost or apache httpd.conf: 如果需要.cfg和inc扩展名,请配置vhost或apache httpd.conf:

AddType application/x-httpd-php .inc AddType应用程序/ x-httpd-php .inc

AddType application/x-httpd-php .cfg AddType应用程序/ 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. 使用“ web”目录创建站点,并使用它创建您的document_root。 Eg.: www.blabla.tld load c:\\xampp\\htdocs\\mysite\\web and you store your config files outside from "web" dir. 例如:www.blabla.tld加载c:\\ xampp \\ htdocs \\ mysite \\ web,然后将配置文件存储在“ web”目录之外。

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. 您需要在路由器的配置中为计算机设置端口转发,以使Web服务器可从局域网外部访问。 Here's a little step-by-step tutorial: 以下是一些分步教程:

  1. Assign a statical IP to your computer. 为您的计算机分配一个静态IP。 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. 这可以通过编辑/ etc / network / interfaces文件将DHCP网络配置转换为静态IP配置或通过编辑路由器的配置来完成。
  2. Set up port forwarding in your router's configuration. 在路由器的配置中设置端口转发。 Forward all incoming TCP connections on port 80 to your computer to port 8080. 将端口80上的所有传入TCP连接转发到计算机的端口8080。
  3. Change the listening port of your web server to 8080. 将Web服务器的侦听端口更改为8080。

Scheme: 方案: 端口转发规则

Now, everyone should be able to access your web server using your public IP adress . 现在,每个人都应该可以使用您的公共IP地址访问您的Web服务器。

The access to your config.cfg can simply be restricted by using .htaccess file or by creating a new virtualhosts. 可以仅通过使用.htaccess文件或通过创建新的虚拟主机来限制对config.cfg的访问。 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! 请注意,XAMPP不适用于生产服务器!

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. 出于性能和安全性的考虑 ,我强烈建议将Apache或nginx与最新的PHP 7.0.x和MySQL一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM