How can I see my php scripts files in MAMP? - php

I'm trying to learn PHP and I've installed MAMP (5.0.4)
I see that my files are in MAMP\htdocs
if I create an index.html file in place it in that direction how to I get it to show.
I fire up MAMP (server and mSQL are on)
I click on the OPEN WebStart Page
it opens http://localhost:81/MAMP/
If I type in index.html after that (http://localhost:81/MAMP/index.html)
I've also tried adding htdocs in the path
I am getting a 404 error.
I know it's got to be something simple

When MAMP loads up it actually gives you options to go to the website or myphpadmin site
if you want to jump directly to your site then just use.
None of this will work if you do not set the project in preference to the directory of the project you are working on
http://localhost:81/

Related

Need help getting PHP project to work on my wampserver [duplicate]

This question already has answers here:
Project Links do not work on Wamp Server
(13 answers)
Closed 3 years ago.
This is my first time trying to use wamp and I'm having trouble viewing my php project. I know the code works just fine (because it is a copy of currently live site). Basically when I try to view the site on my localhost only the index.php file loads and the image folder. No css folders/files are loading. The links work, so I can navigate my site, but no css.
My project folder is inside the www folder in my localhost. See below my project is called movies.
C:\wamp64\www\movies
When I go to view it at - http://localhost/movies/ , it displays only the html. When I view the sources tab in the console it shows the localhost/movies and inside movies an image folder and index, there should be many other folders including CSS and PHP folder called process.
If you saved the Webpage by CTRL+S the sources to your wamp dir then maybe it didn't download all sources.
I suppose you are using Windows and maybe chrome or firefox. Inspect Element the page you are currently trying to view and find sources .CSS|.JS|.JPG in console then navigate to the file and see if it's working like http:/localhost/assets/js/something.css.
Remember all your files should be inside www folder because it is the root dir accessible for server.
If you are using <? (short open tag) then for Wamp, Left click on wamp, Hover on PHP then hover over PHP Settings, find "short open tag" and finally Click it. Restart Wamp Server.
The reason for this might be due to the links. If your website is example.com and you link to an image /directory/file.jpg, the browser will request domain+uri -> example.com/directory/file.jpg and it works fine.
You run in a directory called movies and you access it via localhost/movies/. You expect that the browser used localhost/movies/directory/file.jpg, but it's not. It's domain+uri -> localhost/directory/file.jpg. As you can see, "/movies" is missing from it, thus it's not finding the file.
There are a few possible solutions. The best one is to add alocal test domain in your vhost file. You can do this by clicking the wamp logo -> 'your virtual hosts' -> 'virtual host management'. This solution is a bit more difficult and might require some more research, but is the long term best solution.
The first input is your website, eg movies.test.
The second is the path, which is c:/wamp64/www/movies/ (or where-ever you have wamp).
Then click start and restart wamp.
You can also set a base path in you html header.
<base href="/localhost/movies" >
And you could also link to your files relative
<img src="./images/file.jpg" />
These last two are easier, but require different values local vs on your production server. That works annoyingly if you have to keep updating it.

Unable to load the PHP files other then index.php file from NetBeans

I am trying to run the other PHP files from my project folder that I am currently working on, I get this error while running it straight from NetBeans.
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
Otherwise, when I run the project from localhost it opens up the main page index.php perfectly.
Please advise on what I am missing.
The address that I am trying is:
http://localhost/evs/php342/project/process/process_signup.php
I hope your project structure looks like this
If you want to run process_signup.php as your default page while running the project from Netbeans you should configure the project.
In order to do that Right Click on your project and select Properties
Now select Run Configuration
In Index File text field select the process_signup.php file by using the Browse button right to the text field.
Now you're good to go. Right Click on your project and select Run. After that Netbeans will launch your default page.

After changing filename from index.html to index.php my project is no longer served with MAMP

I'm trying to do some PHP learnin' but I've run into a road-block. I have MAMP installed and I am successfully serving my project files locally. However, after renaming my index.html file to index.php, the page is no longer served.
url is: localhost/projectfile/
I can rename the file back to index.html and the page will serve up again but this means my php code won't run.
I've tried digging around MAMP to see if there is some information/ setting that could help but I'm not finding a solution. It would be great if anyone has info on how this could be solved. Thanks!
You will find all the "start page" stuff in MAMP/bin/mamp (e.g. the English language page is MAMP/bin/mamp/English/index.php).
This is due to the following line in MAMP/conf/apache/httpd.conf:
Alias /MAMP "/Applications/MAMP/bin/mamp"
Refer Where is the index.* file that is served as the MAMP start page URL?
For anyone viewing this post- I must have edited a config file in the wrong way. I uninstalled MAMP and reinstalled and everything seems to be working properly now.

wordpress downloading php file instead of viewing the webpage

I installed wordpress on my local machine (backtrack) for experimenting. After I got everything setup I moved it to an Ubuntu Server so that everybody can access those pages at work. I followed the same instructions, I moved the wordpress folder into /var/www but I created a new database with the same username, password and hostname.
The problem is whenever I access the webpage #ubuntu it tries to download the file, if access the page #backtrack it goes to the dashboard and everything is fine.
I did not have an .htaccess file on either machine sop I created one just to see if it will fix the problem but it did not.
Apache works fine because I can get to some folders I have setup by going to
"http://ubuntuserver/folder name"
and the logs shows no errors because it is delivering the webpage to the client just fine but the client is downloading it instead.
Any Ideas why this is happening??
Sounds like you haven't installed the PHP module for Apache or enabled it to use PHP using AddType in the Apache config file.
It seems that your WebServer ( Apache here, i suppose ) is not configured to use PHP module and/or is missing some PHP configuration options.
See here for some basic configuration tutorial.

Wordpress Live to MAMP

I am having trouble moving a Wordpress installation from my live server to MAMP. So far I have
Copied all the files from the live server to a directory on my local machine (htdocs)
Backed up the database from PHPMyAdmin
Replaced http://www.mysite.com with (http://)localhost:8888/mysite/
Replaced /var/www/vhosts/mysite/httpdocs/ with /Applications/MAMP/htdocs/mysite/
What I see is the homepage working with all the menus and posts there and the admin seems fine however when I click a menu item I get an error message saying:
The requested URL /index.php was not found on this server.
I cannot get past the homepage. Can anyone help? Many thanks in advance.
My best guess is that you've not updated your .htaccess file. You'll need to change your RewriteRules.
This is (probably) because your site was originally on the root of your webserver and now it's in a subdirectory within your MAMP.

Categories