PHP sample project with wamp - php

I installed wamp stack and then installed netbeans ide. The port number for apache is 100.
Created one PHP project at
C:\Users\aaa\Documents\NetBeansProjects\PhpProject2
and project URL http://localhost:100/PhpProject2/
When I click on run, I see the message "http://localhost:100/PhpProject2/index.php URL not found on the server".
What else I need to do to connect http://localhost:100/PhpProject2/index.php to C:\Users\aaa\Documents\NetBeansProjects\PhpProject2?
Please help.

You need to configure Apache's webroot to be C:\Users\aaa\Documents\NetBeansProjects (search for DocumentRoot in the file httpd.conf).
Or you can move/copy your files to the existing webroot, which may be something like c:\wwwroot.
Apache doesn't just magically know where you put your website files, and setting the URL inside NetBeans doesn't actually configure the webserver (I think it's just so that auto-generated links are right).

If you go to http://localhost:100/, what do you see? What is your web root? The folder needs to be in your web root, and I would be surprised if it is C:\Users\aaa\Documents\
I did a Google search for "wamp stack" and found a product by Bitnami... if this is the one you are using, the default web root is C:\Program Files\BitNami WAMP Stack\apache2\htdocs\. If that is indeed the case, then you'd need to move the NetBeansProjects folder to there. (source: http://bitnami.org/files/stacks/wampstack/5.3.6-0/wampstack.pdf page 7)

You need to look into aliasing. That will let you more or less assign directories in the url path to arbitrary directories on your file system.

You have to move your files to your root folder of the Apache installation (htdocs). You should refer to your WAMP installation for where that is located. Personally, I like to use XXAMP for installation.
Netbeans is just an IDE, it doesn't serve the files.

Related

How to run PHP files on XAMMP on A Mac

I have saved a PHP file to my Applications/XAMMP/htdocs directory and I want to run it in a browser.
I have used all sorts of url combinations including:
http://localhost/xammp/htdocs/HelloWord.php
http://localhost/xammp/HelloWord.php
amongst others and I cannot find the right url.
I am using XAMPP on a Mac Majove.
If you installed the XAMPP VM version, then you can probably access it via http://192.168.64.2/HelloWord.php (check the General tab in the XAMPP app for the IP address)
If you installed the native version, then I guess it is
http://localhost/HelloWord.php
The htdocs/ folder is the document root. Its content is served under the server address. Neither the xampp nor the htdocs folder will be part of the URL. The paths are relative to the document root, and you shouldn't be able to access parent directories above htdocs/ (although server-side code such as PHP has access to the file system and may work with files outside of the document root).
First of all, expecting the php file to have information that can be visualized in a web browser, inside xampp if you have the .php file in the htdocs folder you should be able to visualize it like this:
http://localhost/HelloWord.php
Found it by trial and error, quite different from what I took from various instructions on line:
http://localhost/HelloWord.php
XAMPP's default root should be "htdocs" or "www". Put your PHP files into those folder and try again.
if it is not work, find the configuration of Apache and PHP in XAMPP folder.

Eclipse - How to add subfolder to end of XAMPP localhost

a quick question about running PHP applications in Eclipse PDT. I have done a lot of searching but can not find what I am looking for.
I have XAMPP installed and am trying to run my PHP applications out of eclipse. The problem is I have my source files in a SUBFOLDER of the htdocs folder. So when I run, eclipse nagivates to:
http://localhost/index.php
But I need it to navigate to:
http://localhost/MyWebApps/index.php
Is there any way I can set the PHP server to always default to MyWebApps folder in eclipse? As MyWebApps is my eclipse workspace.
Thanks in advance!
Here 3 solutions:
First way, easy for one file. Project Explorer -> Right click on file -> Run As... -> Run Configurations. Configure similar to screenshot:
Then, click (V) arrow after run button in toolbar and choose configuration, "New configuration A" as in example.
Another better way: (root needed)
Add host "127.0.0.1 mywebaps.localhost" to /etc/hosts
Configure VirtualHost mywebaps.localhost in Apache, with document root point to your Workspace (files starting with "." should be blocked for this and nested directories, this is eclipse meta files)
Configure web server in eclipse to use mywebaps.localhost as host
name, then your file will be opened as
http://mywebaps.localhost/projectname/index.php
And finally, easy way: (root may be needed)
Leave your Workspace folder inaccessible by apache.
Create new php project, not in workspace but in apache document root
folder(should be writeable by user)

php url and folder name

I just installed the latest MAMP on Mac, and found this hard to understand:
The document root seems to be "~/MAMP/htdocs", because "localhost" will open the index.php file under this folder.
However, "localhost/MAMP/?language=English" opens "~/MAMP/bin/mamp/index.php". I know that in URL strings between "/"s are not necessaries folders, but if they are not folders, how was it constructed and how does the system know where to find the right files?
I know this is a pretty basic question which I can probably get answers by myself, but I don't know what key word to search. Tried "php url construction" and "php url folder" but no luck. So a proper keyword suggestion is also appreciated.
It is setup by default by MAMP. If you open up MAMP/conf/apache/httpd.conf in a text editor and scroll down to around line 368/369 and specifically line 408 you will see that it is an Apache Alias. it is setup for easy navigation, instead of having to type http://localhost:8888/bin/mamp you can just type http://localhost:8888/MAMP. It is also setup as an Alias to ensure that you can still access the web tools if you change the document root from something other than /Applications/MAMP/htdocs.
Are you sure http://localhost:8888 has the docroot set to ~/MAMP/htdocs as you suggest? Reason I ask is that looking at your first image the text says the docroot is /Applications/MAMP/htdocs. Also the docs say it should be in the /Applications/MAMP/htdocs. I think the issue is that you do not have MAMP in the Applications folder where it needs to be.
https://www.mamp.info/en/documentation/
Where should I store my HTML and PHP pages?
By default, PHP and HTML Pages should be stored inside the MAMP
"htdocs" folder which is located in the MAMP Application directory
/Applications/MAMP. This folder is called "Document Root". You can
change the path for the Document Root in the MAMP application's
Preferences Panel:
Also please note this https://www.mamp.info/en/documentation/#q8
Will MAMP work if the MAMP folder is not located in the Applications
directory?
No. In order to work properly the MAMP folder has to be located in the
Applications folder.

Open file using modify address instead of default address

When XAMPP is installed, we can open file using URL like localhost/home.php. Can we open the very same file like (for example) using an URL like hamzazafeer.com/home.php or www.hamzazafeer.com/home.php? Is there any way or we can't change this address?
You can override the domain target to localhost. That means that your browser "thinks" that the domain is on localhost. The browser will fetch then the local files instead of calling a remote server. To do that you have to edit in C:\Windows\System32\drivers\etc a file named hosts. Depending on your operating system and settings it could be a little hard to edit the file. But you will find further specific information with the help google.
The row you have to add into this file will look like:
127.0.0.1 hamzazafeer.com
Yes and no.
Yes, you can. In default XAMPP installation, it always points to some default folder (htdocs folder in its root folder under Windows, /var/www under Linux etc.) This answer may help you locating this folder in your installation of XAMPP).
You can install (FTP copy) XAMPP on any hosting, where your domain hamzazafeer.com currently points to, and properly configure it (both hosting and domain) to point to your XAMPP's default websites folder and you're ready to go.
(BTW: You're mixing certain things. XAMPP nothing to do with this, it is Apache's configuration variable plus XAMPP / Apache has nothing to do with this in general -- you can point your domain to any folder on any hosting, no matter, what server software is used to serve your website)
No, you shouldn't. XAMPP is from the begining to the very end designed as localhost, test-purpose-only, developer-only solution. You should ever, never use it for serving production version your websites or anywhere on any publicly-accessible hosting. Limit it only to your localhost, as it was meant by XAMPP's creators.

httpd.conf # Windows

I've created PHP project with MS WebMatrix and copied the CakePHP into it. It promped:
URL rewriting is not properly configured on your server.
But, except that, everything is fine:
Your version of PHP is 5.2.8 or higher.
Your tmp directory is writable.
The FileEngine is being used for core caching. To change the config edit APP/Config/core.php
Your database configuration file is present.
Cake is able to connect to the database.
I believe I should just edit httpd.conf file (CakePHP documentation told me so) but I couldn't find such a file at all... is it hidden somewhere or is there any GUI configurator? I'm new to Windows so really, don't know where to search and Google told me nothing but obvious Linux directory...
I could just upload all the files to the server and work from there but that's just not really handy.
You should edit .htaccess file in the app root folder. IIS configuration needs some modification in the htaccess files in your cakephp project.
Hope it will work for you. Please ask if it not worked for you.

Categories