Configuring Apache Document Root for Eclipse Workspaces with PHP - php

I've set up PHP and Apache for my Snow Leopard machine using these instructions I can change Document Root in httpd.conf such that I can run php files from different local directories. However, when I set it to the the location of my Eclipse workspace, I get "Forbidden - You don't have permission to access / on this server"
I'd like to be able to use the Eclipse New PHP Project to "Create a new project in workspace" instead of creating a directory somewhere else and using "Create project at existing location..."
What am I missing?

You need to modify corresponding <Directory path> directive. You already have this directive for previous DocumentRoot, so just change path in there to your current document root.

Related

Is it possible to put laravel project on outside of Document root?

Where should I put a larval project on server directory?
I put my larval file ~/[larave_project_name]
DocumentRoot is /var/www/html/.
I moved public/index.php into DocumenRoot.
But I found In DocumentRoot, Those files can’t load files from outside of var/www
My Server environment is Cent OS7 / Apache 2.4 /PHP 7.4
The intent is for the webserver to have a document root of the public directory within your laravel project.
A good starting point would be:
Move the files from ~/[laravel_project_name] to /var/www/[laravel_project_name]
Update the default for the web server configuration to change the document root from /var/www/html to /var/www/[laravel_project_name]/public

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)

Setting up LAMP server, trouble with phpmyadmin "Cannot load or save configuration

I am trying to set up a LAMP server on a Ubuntu 14.04 desktop, but am having trouble with setting up phpmyadmin. It is very similar to this (unanswered) question
phpmyadmin is located here:
/usr/share/phpmyadmin
I created the config folder as outlined in the docs, but when I go to localhost/phpmyadmin I get this error:
Directory config, which is used by the setup script, still exists in your phpMyAdmin directory. You should remove it once phpMyAdmin has been configured.
Going to localhost/phpmyadmin/setup/index.php will then give me this error:
Cannot load or save configuration
Please create web server writable folder config in phpMyAdmin top level directory as described in documentation. Otherwise you will be only able to download or display it.
Any ideas on why I can't load the script?
/etc/phpmyadmin has:
apache.conf config.footer.inc.php htpasswd.setup phpmyadmin.service
conf.d config.header.inc.php lighttpd.conf
config-db.php config.inc.php phpmyadmin.desktop
Have you tried accessing localhost/phpmyadmin?
Also, try creating a soft link under /var/www/html/ to /usr/share/phpmyadmin

PHP Apache Config on linux

I'm using Apache 2 in Linux mint and I don't know where to store my files and projects. if I store it in var/www it is not accessible for me, I have to use command as super user. Are there any way to solve my problem?
- If I want to store in my home folder, what should I type in the address bar if I want to run my file?
- Are there any other good solution than these? (such as change the accessible to folder /var, or change the Root_Url of apache ...)
The easiest way to solve this provlem is by typing the following line in terminal:
sudo chmod -R 777 /var/www
and then enter your password. And now you are done. You can store all the PHP files in /var/www
You have to do a chmod, you can have more information in your terminal with comand man chmod to set the rights to write in that folder or else point the web-server elsewhere (the setting is in the https.conf file)
There is different solutions:
create a symlink from /var/www/link to your projet and set your project
create a virtualhost with the DocumentRoot to point to your project: http://httpd.apache.org/docs/2.2/vhosts/examples.html
in both cases your project must have gives permissions to the apache user (www-data?) to read/execute you project
You need to active the user_dir mod of apache and then run the content from your home folder.
To run a file in your hole directory you should go to localhost/~youruser/script.php of course after enabling user_dir
Everything depends on the use.
If you are looking for a configuration for a development server that is accessible only from limited host (such as localhost):
You can configure Apache (/etc/apache2/apache2.conf) to run with your user/group.
User myuser
Group mygroup
Store all your project in your user_dir (/home/myuser/projects/...)
Create a virtual host for any of your projects
All files generated by your server will be accessible to you and vice versa
One way to accomplish this is to edit the default virtualhost supplied with Apache 2. In Linux Mint 14 its configuration file is located at:
/etc/apache2/sites-enabled/
This directory should hold symlinks for all active sites, for me the default is named 000-default.
Change the lines with "DocumentRoot" and "Directory" to point wherever you like. The server should have read only privileges by default. If you are working on file manipulation then it will need permission to read and write files.
Once this is set, restart the server ("sudo service apache2 restart") and type localhost in your browser to access the directory you've set above.
For more advanced configs have a look at:
http://community.linuxmint.com/tutorial/view/853
http://community.linuxmint.com/tutorial/view/527

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.

Categories