php url and folder name - php

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.

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?

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.

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.

Yii "framework" sub-folder not visible from apache? [error 403]

I'm having quite a weird problem here.
I have just pasted the Yii folder into my htdocs folders and, for some reason, apache can't see one specific folder within the Yii folder, which is called "framework". I.e., when I type http://localhost/yii , apache correctly lists all sub-folder within the Yii folder except for the "framework" folder!
When I try to call this folder directly from the browser (i.e. writing http://localhost/yii/framework) I get a 403 Access forbidden error.
I'm at a loss here, why isn't apache listing one single folder? The folder which it cannot see is no different from the ones it can see.. I've even removed the read-only attribute from all folders within htdocs but to no avail.
P.S.: my OS is windows Vista sp2
I'm not sure why you are even trying to view the framework folder directly. It does have an .htaccess file in it which says "deny from all". Just make sure you have the correct path for the "yii.php" file inside the framework folder set in the index.php file in your web root.
PHP can include files that are inside "deny from all" folders but you can't browse them directly via a web browser.
Try working through one of tutorials from the start:
http://www.yiiframework.com/doc/guide/1.1/en/quickstart.first-app
http://www.larryullman.com/series/learning-the-yii-framework/

MKDIR is not working correctly?

i'm using Xampp. When I tried to do this earlier, it worked, but now it is not working.
I'm trying to make a directory in my www folder to hide it from baddies who steal files.
Each user gets their own folder in uploads to put their files on.
Xampp uses apache, and Xampp is a local web server. It allows me to design websites without the need of an online host. The www folder is in my C:\program files\xampp\php\www\ and I need to make a directory there. I know it's possible because i've done this before, I have just forgotten how to make it happen.
When I make a directory I use:
$uploaddir1 = "xampp/php/www/uploads/".$esclcusername."/";
mkdir($uploaddir1,0777);
Do I need to include C:\program files\ before xampp?
And finally, how would this be possible on a real online web host?
I saw your question here and searched some on google. This is what i found:
mkdir("D:/hshome/rubygirl58/gameparody.com/clansites/".$sitename."/lib", 0777)
So yes, I think you have to include the complete path.
Greetings,
Younes
you need to make sure that you give permisions to the parent folder to create dirs in it (0777)
to get the full path you can use dirname(FILE) wich will return the path for the directory of the file in wich it is runned

Categories