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.
Use virtualhosts
https://delanomaloney.com/2013/07/10/how-to-set-up-virtual-hosts-using-xampp/
If you using php, use .php file ext for all files instead blahblah.inc and blahblah.cfg. Right way is: blahblah.cfg.php
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)
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.
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:
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.
Set up port forwarding in your router's configuration. Forward all incoming TCP connections on port 80 to your computer to port 8080.
Change the listening port of your web server to 8080.
Scheme:
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.
Related
In the situation where you have a Shared Hosting plan with a provider like GoDaddy without full access to the server, is there anything i can do to disallow outside HTTP requests for *.php files?
If anyone has experience with shared hosting or with GoDaddy specifically that would be appreciated. Im with GoDaddy and the only thing i can try is to mess with User/Group/World permissions of a php file, but no combinations enables server-only access to a file. And, obviously, i don't have access to the apache server's config file which is the easiest solution.
outside HTTP requests for *.php files
I'll interpret this as requests from outside a set of people you're willing to share the pages with. You want to limit access to your site.
Easiest approach -
Use an .htaccess file in DocumentRoot that limits access by IP address (if you are willing to force all the people who use the files to work from a limited set of IP addresses)
https://httpd.apache.org/docs/current/howto/htaccess.html
For Apache 2.2, in the .htaccess file, put
Order Deny,Allow
Deny from all
Allow from 1.2.3.4
For Apache 2.4, use
Require ip 1.2.3.4
Another quick solution would be to password protect the directory with the .php files. The configuration would look something like this:
AuthType Basic
AuthName "Restricted Files"
# (Following line optional)
AuthBasicProvider file
AuthUserFile "/usr/local/apache/passwd/passwords"
Require user goodguy
https://httpd.apache.org/docs/current/howto/auth.html#lettingmorethanonepersonin
You may want to find hosting with SSH access to give you more control.
I have a client and I need to execute a curl script on it's server but I get a 404 error.
First I tried the other suggestions I've found on other solutions here (adding headers, cookies...)
After that I asked for a SSH access to be able to check more and that's what I've found:
The only URL that doesn't returns a 404 is the home http://aksentropis.com and it doesn't return the homepage's content it just return
<html><body><h1>It works!</h1></body></html>
So I've decided to investigate where this text could be and I've found it on another completely different directories using grep:
./usr/src/httpd-2.4.23/docs/docroot/index.html:1
./usr/local/apps/apache2/www/htdocs/index.html:1
I've entered those directories and they only contain the index.html file
But, the main folder for public_html is on:
/home/admin/public_html
How can I fix that, or what should I do? I only have a ssh root access.
Update: if I call the url from another server it just works...
Update: I've found the DocumentRoot in the apache was misconfigured.
It was pointing to
DocumentRoot "/usr/local/apps/apache2/www/htdocs"
and I've updated it to
DocumentRoot "/home/admin/www"
Now it loads the php but it doesn't execute it. Why is that?
It looks to me like the vhost for this site isn't configured to accept your requests. This could either mean from your location, or using the port you're using.
It could be a matter of your source location. A Require, Allow from or Deny from directive inside your vhost can manage access control.
Apache Docs: Access Control
Perhaps a proxy (such as a load balancer or firewall) usually intercepts port 443 and 80 traffic and redirects it to other ports, and your vhosts are configured to listen to those other ports. Right now all traffic (from your curl location, most likely localhost) appears to be directed to the default apache site, and paths relative to that index file.
Please check the virtual host configuration for this site. It can usually be found in /etc/apache2/sites-enabled/. If the VirtualHost block for that site contains a colon followed by a number, then that's the port number this block is applied to:
<VirtualHost aksentropis.com:1234>
DocumentRoot "/home/admin/public_html"
</VirtualHost>
In the above example the server would be configured to listen to port 1234, which means there's usually something that's between external traffic and the server. Apache Docs: Binding to Addresses and Ports
What changes are to made in httd.config file so that the PHP files can be accessed from different networks in xampp?
You should made the update like this
listen *:80
and restart your Apache server
I'm trying to create a copy of an existing Magento website on my localhost for developing purposes.
I followed all the steps listed here: Copy ec2 files to local
I also created a fake domain for my localhost so that there’s a “.” in it as I read somewhere this is required by magento. So now my localhost fake URL is something like: www.mysite.local
I have XAMPP installed on OS X 10.9.1 and I placed the magento filesystem as follows:
/Applications/XAMPP/xamppfiles/htdocs/magento/
In the database I added the local URL as follows:
update core_config_data
set value = ‘http://www.mysite.local/’
where config_id = 6;
and on local.xml I entered the following parameters:
<host><![CDATA[localhost]]></host>
<username><![CDATA[myusername]]></username>
<password><![CDATA[mypassword]]></password>
<dbname><![CDATA[mydatabase]]></dbname>
where localhost is just localhost, myusername is the username for the db I restored on my local XAMPP server, mypassword is the password for that same db, mydatabase is the name of the same db.
Still, when I browse to www.mysite.local/magento/ or www.mysite.local I don’t see anything appear.
What am I doing wrong?
Thank you so much!
If you're using a local server, here's some basic trouble shooting to help you debug:
Firstly, is the local server active? Can you visit http://localhost without it displaying server not found? If you can't, your local server is most not running. Try firing up xampp and launching Apache.
Secondly, it seems you're trying to create a virtual host for your local server. That's great! Virtual hosts allow you to create individual URLs for projects on the same server. E.g. http://myproject.dev.
However, you first need to make sure that the server understands what you're doing.
You will need to create a virtual host in your server if you haven't already.
I see you're using xampp. What you need to do is navigate to your xampp install, and edit your apache/conf/extra/httpd-vhosts.conf file, which is the file xampp recommends you use solely for virtual hosts.
Reading: Setting Up Virtual Hosts for XAMPP
For example, in Apache, a hosts config file may look like this:
# Base
<VirtualHost *:80>
DocumentRoot "X:/"
ServerName localhost
</VirtualHost>
# Project - Some Project of Mine
<VirtualHost *:80>
DocumentRoot "X:/projects/myproject/public"
ServerName myproject.dev
ErrorLog X:/projects/myproject/logs/apache.error.log
CustomLog X:/projects/myproject/logs/apache.access.log common
php_value error_log X:/projects/myproject/logs/php.error.log
</VirtualHost>
(navigating to myproject.dev displays the files in my X:/projects/myproject/public directory)
This answer is not to explain virtual hosts to you however. There are plenty of amazing resources online to help you get started with setting up your own.
Don't forget to restart your server when you add a virtual host!
If this is already set up, is your computer's hosts file set up to point to your server?
Your hosts file on your computer is used to tell it to do certain actions when you enter a matching url in your browser.
Reading: The Hosts File and what it can do for you
Reading: How to Edit Your Hosts File
For example, using the apache conf file settings above, my hosts file must also include:
# My project - Localhost
127.0.0.1 myproject.dev
It tells my computer to send the request to my local server (at localhost) when I use the URL myproject.dev. The local server then picks up the request, sees that you're accessing myproject.dev and checks if it has any virtual hosts matching that name. Well, whaddya know, it does! It then looks at the DocumentRoot setting for the location of the server files, and continues the process. Think of your hosts file as a local DNS of sorts.
If you've just added the site to your hosts file, it may take a few minutes to start resolving correctly. Wait a little, clear your browser cache and try again.
Finally, if these steps are done, and you're receiving nothing, it may be a server configuration problem, or a .htaccess issue.
If you're running on windows, you can check your event log for apache server errors. If you have set up logging on the virtual host, you can check those files to see if it's picking up your requests, and what it's doing with them if it is.
Most issues after that point will at least yield a visible error in your browser (or a blank page).
I hope this helps!
Also checking the magento error logs could tell you what the issue is, assuming it's actually hitting magento at all at this point.
As Sean mentioned above, one of the most common problems I've seen when copying a magento site is accidentally omitting the .htaccess file - make sure it's present in your site root.
If you tested your site before making the change to core_config_data, then you can also try deleting everything in var/cache and var/session. Also make sure that the web user has write permissions on var.
Regards
Hans
I have a website that works fine when deployed on a remote development server. However, when I move it to my local machine, all the images paths' are now not pointed to the right directory.
Where as <img src="/images/breadicon.png" /> used to work, I now get a 404 file not found.
When I update that to <img src="./images/breadicon.png" />, the image is found, but I don't want to have to revert back all my links when I re-deploy this site - and of course I don't want to have to work from the remote server.
The issue is, without the ., the path is perceived as http://localhost/images/breadicon.png instead of http://localhost/sitename/images/breadicon.php
What can I do to resolve all the links and have my links without ruining the code for redeployment?
Your best option is probably to set up a web host on your local machine.
For example, if your live/remote site was http://www.example.com/, you could set up a local web host as http://example/.
I'm assuming you're on Windows and using Apache. You'd need to edit your hosts file (using notepad, running as administrator, usually found here: C:\Windows\System32\drivers\etc) to contain:
127.0.0.1 example
Then create an Apache host config file, for example:
<VirtualHost *:80>
ServerName example
DocumentRoot C:/Path/To/Site/example
</VirtualHost>
Then restart Apache and go to http://example/. Assuming you follow a standard convention for links etc, this should do the trick.
Configure your webserver such that the site can be accessed under http://localhost/ instead of http://localhost/sitename.
If that name is already used for a different purpose, create a virtual host named e.g. sitename in the webserver and edit your hosts file so that sitename points to 127.0.0.1.