Eclipse output to WAMP webserver www folder - php

I have an eclipse workspace folder. I want to store all the different projects I am working on over here. Now I am working on a PHP project and have WAMP installed. Is there some way to configure eclipse such that it outputs my project files to the server's www folder.
I don't want to create my workspace in the server's www folder, for the following reasons:
- I will work on multiple projects over time and I want all of them to reside in the same workspace
- I don't want to pollute the web server's www folder (though this is a development machine). I feel that if I have the code in a separate workspace, there is a low chance of me deleting it by mistake. I don't want to end up deciding to clean the www folder and deleting my only copy of the code!
Any alternative solutions to my concern are also welcome :)

You don't need to edit any php.ini files or anything crazy like that; you just need to change a couple of things in Eclipse.
Step #1:
Go into Eclipse and click on Window --> Preferences --> PHP --> PHP Servers
There should be a default server listed; you can edit it or just create a new one(this is what I did) and just set it as default later.
Click add or new or whatever it will come up with 2 boxes.
The first is just what you want to call the server; call it whatever you like.
The second is IMPORTANT -- this is where the www folder for your WAMP server is located. I have a shortcut to it on my desktop with a folder with all my php files in it.
I just typed localhost/name of my folder <--- your folder goes here.
It should be localhost/wamp/www if you don't have a shortcut. Don't hold me to that, though.
Step #2 : Running the program
When you have your php file you want to run, right click it and select Run as --> Run Configurations --> PHP webpage(double click). In the "File" area click Browse. Your project folder with your .php file you want to run should pop right up. If not, you'll have to look for it. Select it, then click "Run". Eclipse will open its default browser, and if all went well, you should be able to see your output.
It probably makes it easier if you just use a separate workspace for your PHP projects and store all the files in the www folder(Eclipse should make sub folders for new projects).
Hope this helps

You can keep the php code in your current eclipse workspace and then create virtual host in the httpd.conf file of apache server with document root pointing to this directory.

Only solution I found was to place your PHP files under the wamp\www folder.
Example:
c:\wamp\www\yourproject\index.php

Related

Why does my Notepadqq editor does not recognize LAMP www folder and sub-folders?

Attempting to get LAMP working on my 32-bit Ubuntu 18.04 machine. I believe the set-up is close to correct. I have all Apache2, mysql, and PHP software installed. I have an index.php file located in folder /var/www/bookcorner directory which shows up as it should if I enter localhost/index.php in the browser address bar. This file may be edited in nano while saving the changes. However, I cannot use my editor Notepadqq (or presumably others) to edit the file.
Going through the file manager, I can select the file and open it in Notepadqq, but I cannot save it. I get the error, "folder does not exist". If I try a 'Save As' with Notepadqq, I do not see any folders past /var in the directory structure, though they obviously exist. The www folder and subfolders do not show up in Notepadqq.
There are three folders under /var/www which are
bookcorner
html
michaelsbookcorner.com
I have ownership of all of these folders
michaelsbookcorner.com is a live site at Infinityfree.net
I somehow got Apache2 to point to bookcorner for now which is fine. Eventually I would like to select between different websites but I only have one for now existing in another directory. I wish to begin utilizing LAMP rather than uploading PHP files to my hosting site all the time.
What settings/permissions/etc could I have missed here in order to get this working properly?

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.

PHP sample project with wamp

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.

Netbeans not copying source files to web folder

I'm using Netbeans to develop an HTML/PHP site and I have the Run Configuration set as follows:
Project URL: http://localhost/JEB
Project Folder: C:\Documents and Settings\John\My Documents\NetBeansProjects\JEB
Source Folder: C:\Documents and Settings\John\My Documents\NetBeansProjects\JEB
Web Root:
The "Copy files from Sources Folder to another location" option is checked and the Copy to Folder location is: C:\xampp\htdocs\JEB.
The problem is, when I edit files in the Project Folder, and then click Run, I'm expecting them to copy to the web location (C:\xampp\htdocs\JEB) and then run in the browser. But that's not happening. The files are not getting copied over so I'm seeing the old versions of the files that were previously in the C:\xampp\htdocs\JEB folder. (I had this working once before, I thought.)
Am I misunderstanding how this works? I thought you were supposed to edit the files in the Source folder, and they would automatically be copied to my web server folder when I ran the project locally. I've checked the NetBeans forums and found one other person with this problem, but no working solution. I was having this problem with Netbeans 6.5.1 so I upgraded to 6.7.1 and still no luck.
Thanks.
I had this problem too and it seemed to be a bug in NetBeans. I was using Ubuntu Linux 9.04 with NetBeans 6.5 and 6.7.1.
When it happened to me, I would delete all of the files in the destination location and then run the project again. When NetBeans sees that there are no files there, it copied the latest version over. From then on it usually worked correctly (i.e. automatically copying files from the source to destination folder every time I ran the project). Sometimes I also had to restart NetBeans for this to work correctly.
Not a solution, but work around.
Create a XAMPP Alias to the directory where your files are located, see: Make XAMPP/Apache serve file outside of htdocs

Categories