Background: I'm supposed to set up a server at work, on a PC running Windows XP. I've taken a course in PHP, which showed us how to set up XAMPP, use PHP, and use MySQL. I installed and ran XAMPP on this PC and I now have Apache 2.2 and MySQL running as services. I also created a MySQL database with the tables and columns I want. But now I'm completely lost as to basics, which I was never taught, and I can't find online. Here are my basic questions:
When developing PHP programs they can be run only with Apache when in the "C:\xampp\htdocs\" folder. For example, the file...
C:\xampp\htdocs\form.php
...can be run only with the path name...
http://localhost/form.php
...in the browser (Internet Explorer), correct? However, when I created a MySQL database called "readings" it looks like it was automatically placed at the path...
C:\xampp\mysql\data\readings
...so how can anything work at all? Can PHP access this database outside of the HTDOCS folder? How can somebody on a client machine see my PHP web page? What folder do they go to? Certainly not HTDOCS, correct? What URL do I give them? I know that web hosting companies like LunarPages have Apache running with scope such that the users can run PHP programs from any folder, but I don't see how they can do that with the HTDOCS limitation. Or should I somehow use another program for installing Apache, like Apache on its own? Does the installer package make any difference? Am I doing something fundamentally wrong, like needing to use a professional web hosting company for our project? It seems I've learned a lot of detail but nothing about the big picture of how to get anything working at a professional level.
basic questions on Apache scope, servers, etc.
Moderator: General Moderators
Re: basic questions on Apache scope, servers, etc.
Yes. PHP doesn't access the MySQL data folder directly - it access it by using the MySQL client library (e.g. mysql_* functions). This library uses a row TCP connection to your MySQL server. No file access here.Simnia wrote:Can PHP access this database outside of the HTDOCS folder?
In your Windows command prompt run:Simnia wrote:How can somebody on a client machine see my PHP web page? What folder do they go to? Certainly not HTDOCS, correct? What URL do I give them?
Code: Select all
ipconfigCreating a DNS record for this IP is the next step.
There are 10 types of people in this world, those who understand binary and those who don't
Re: basic questions on Apache scope, servers, etc.
There is a bit more to it. As well as identifying the IP of your machine, you will need to open http through your windows firewall to allow access from a different computer. In addition, if you are behind a router and want people from the Internet to get to your site you'll need to identify your 'public' IP address which is provided by your ISP, and you'll need to forward http port from your router to your web server.You will see the IP addresses assigned to your machine. Now replace the "localhost" thing with your (or one of yours) IP address. That's the way other users can browse to your website.
Re: basic questions on Apache scope, servers, etc.
Thanks so much, VladSun. That worked!
The file at...
C:\xampp\htdocs\tests\hello.php
...became accessible with the URL...
http://xxx.xxx.xxx.xxx/tests/hello.php
...where the x's hold my IP address.
That still means that anything that I want to be displayed to the public must be placed in the folder or subfolder of...
C:\xampp\htdocs\
...correct? And any databases we use with such web pages must be placed in the folder or subfolder of...
C:\xampp\mysql\data
...correct?
The file at...
C:\xampp\htdocs\tests\hello.php
...became accessible with the URL...
http://xxx.xxx.xxx.xxx/tests/hello.php
...where the x's hold my IP address.
That still means that anything that I want to be displayed to the public must be placed in the folder or subfolder of...
C:\xampp\htdocs\
...correct? And any databases we use with such web pages must be placed in the folder or subfolder of...
C:\xampp\mysql\data
...correct?
Re: basic questions on Apache scope, servers, etc.
Simnia wrote:That still means that anything that I want to be displayed to the public must be placed in the folder or subfolder of...
C:\xampp\htdocs\
...correct?
Yes.
Pay attention to what Doug G said.
Also, keep in mind that your IP could change when you reconnect to your ISP (i.e. DHCP enabled)
Whether your DB is to be accessed by web pages. or desktop applications, or anything else, it simply doesn't matter. Your DB is accessed through a server (commonly by using TCP/IP) just like you access your Apache (HTTP) server.Simnia wrote:And any databases we use with such web pages must be placed in the folder or subfolder of...
C:\xampp\mysql\data
...correct?
Try to run telnet from the command prompt and connect to the MySQL server:
Code: Select all
telnet localhost 3306There are 10 types of people in this world, those who understand binary and those who don't
Re: basic questions on Apache scope, servers, etc.
Thanks again, VladSun. Yes, I had already taken care of the firewall problem per other advice before I posted my question, but Doug's advice is also useful, and fills in the gaps most people forget to mention.