I can't see my php file under "yourprojects" in localhost
Posted by: jjninja9 (47.213.210.---)
Date: May 04, 2024 04:02AM

Hi all,

I am new to wampserver, I am looking for a way to test my PHP files so that I can practice more!

I just downloaded wampserver today, and I am trying to learn and follow the tutorials. I can see the green wampserver icon saying "all services running" in my taskbar, but when I click on localhost, I don't see my PHP file (which is located under C:\wamp64\www.myphpfile.php).

From what I understood from the tutorials I read/watched, the PHP file I wrote (I used notepad++) would appear under Your Projects, and I would somehow be able to test the code from there? Please correct me if this is inaccurate, I am still learning!

Could anyone please help me figure this out?

Thank you!

Options: ReplyQuote
Re: I can't see my php file under "yourprojects" in localhost
Posted by: webmasterinnj (---.cmdnnj.fios.verizon.net)
Date: May 04, 2024 05:32AM

hello smiling smiley
i think for php scripts to run properly you need to declare a virtualhost first,did you add a virtual host?
also the wamp64 folder is for wamp itself.
if you have a virtual host it would look something like "C:\wamp64\www\yourvirtualhost"
some php scripts are finnicky if a virtualhost isn't decalred,wordpress is one example.
you can add a virtualhost on the localhost page smiling smiley

[djsnetwork.freemyip.com]

Options: ReplyQuote
Re: I can't see my php file under "yourprojects" in localhost
Posted by: Otomatic (Moderator)
Date: May 04, 2024 08:45AM

Hi,

See The need for Virtual Host
and Wampserver 3 - Create or add a VirtualHost

Or, if you have Wampserver 3.3.5 see Right-Click -> Help

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: I can't see my php file under "yourprojects" in localhost
Posted by: jjninja9 (47.213.210.---)
Date: May 06, 2024 01:26AM

@webmasterinnj @Otomatic Thank you both so much for responding!

I am currently working through the tutorials that you linked, and under the "the need for virtual host" page, I have a question:

I made it to the step "Now there is one more thing.
Wampmanager Tray Icon Your VirtualHost menu item
The 'Your Virtual Hosts' menu item searches the file that is used to define Virtual Hosts that we have just changed and creates menu links for each ServerName parameter it finds and creates a menu item for each one."

When I hovered over "Your Virtual Hosts", I see 3 errors: one is "Document_Root_error", one is "Directory_Path_error", one is "Directory_Path_no_slash".

I fixed that last error by adding the ending slash, but now the other two remain. When I click on it, it says, "Warning

In the httpd-vhosts.conf file:

The DocumentRoot path

c:/wamp/www/

does not exits

Press ENTER to continue"

I don't understand what I did wrong, and now also clicking on the localhost in the tray icon gives this error:
"Forbidden
You don't have permission to access this resource.

Apache/2.4.59 (Win64) PHP/8.2.18 mod_fcgid/2.3.10-dev Server at localhost Port 80".

Could you guys please help me?

Options: ReplyQuote
Re: I can't see my php file under "yourprojects" in localhost
Posted by: jjninja9 (47.213.210.---)
Date: May 06, 2024 04:13AM

Thank you both for responding! I was working my way through the tutorials, and I ended up with some errors: at first I had 3 errors: one was an error about no slash in the directory, which I fixed by adding the ending slash in the "httpd-vhosts.conf" file. I still have the "DocumentRoot_error" and the "Directory_Path_error".

Specifically, it says, when I click on the document root error: "Warning

In the httpd-vhosts.conf file:

The DocumentRoot path

c:/wamp/www/

does not exits

Press ENTER to continue"

And then when I click on the directory path error: "Warning

In the httpd-vhosts.conf file:

The Directory path

c:/wamp/www/

does not exits

Press ENTER to continue"

I am not sure what I did wrong. I copied the code directly from the tutorial "The need for virtual hosts".


Also, now when I click on localhost in the tray manager, I no longer see the homepage, but instead I get this error: "Forbidden
You don't have permission to access this resource.

Apache/2.4.59 (Win64) PHP/8.2.18 mod_fcgid/2.3.10-dev Server at localhost Port 80". The tray manager is green and all services are running.


Could you guys please help me figure out where I went wrong? If there is any other information I can provide to help please let me know, and thank you!

Options: ReplyQuote
Re: I can't see my php file under "yourprojects" in localhost
Posted by: Otomatic (Moderator)
Date: May 06, 2024 08:49AM

Hi,

> I copied the code directly from the tutorial "The need for virtual hosts".
NO! There is no code to copy. Reread!

Basically, without any other VirtualHost, the httpd-vhosts.conf file must contain only :
# Virtual Hosts
#
<VirtualHost _default_:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>
So, you restore the httpd-vhosts.conf file to its original state, and your VirtualHosts must be created via the Add a VirtualHost page accessible from the Wampserver home page 'http://localhost/'.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: I can't see my php file under "yourprojects" in localhost
Posted by: jjninja9 (---.lightspeed.cicril.sbcglobal.net)
Date: May 09, 2024 05:20PM

Otomatic, thank you for helping me, I did what you said, and now the localhost page works again, and I have also added the virtual host as you said.

Now on the localhost page, under Your Projects, I can see my script, but I cannot click on it.

I tried to navigate to it manually using this URL: "[localhost];, but it does not display quite correctly.

Could you help me, please?

Options: ReplyQuote
Re: I can't see my php file under "yourprojects" in localhost
Posted by: Otomatic (Moderator)
Date: May 09, 2024 06:39PM

If the ServerName of your VirtualHost is "mysite" you can access it via 'http://mysite/', which is visible in the Your VirtualHost left-click menu or in the Your VirtualHost column on the Wampserver home page 'http://localhost/'.

To have your 'topsongs.php' file executed, you need to specify it in the 'http://mysite/topsongs.php' url.

To have this same file executed automatically when you launch 'http://mysite/', rename it index.php.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: I can't see my php file under "yourprojects" in localhost
Posted by: jjninja9 (---.lightspeed.cicril.sbcglobal.net)
Date: May 09, 2024 07:57PM

I'm sorry, I still don't get it. This is all very new to me, and so I am not sure if I am just misunderstanding what you are explaining.

How do you attach an image? I can attach a screenshot of what my virtual host page looks like, if that would help me understand where I am going wrong?

I named the server "topsongs", and the directory is "c:/topsongs".

If I go to the URL, "[localhost];, then I see a screen that has all of the files I have in "C:\wamp64\www\topsongs.php"

But when I try to click on the PHP file located on that URL, it displays the input screen of my file correctly, but the problem is that there is also part of my actual PHP code being displayed, and when I hit the submit button on my input screen, the output does not display correctly.

I have a file variable in my PHP code that references a txt file also located in the same folder "c:/topsongs" (that txt file is also visible in the URL, "[localhost];. Is my PHP file not able to reference the txt file correctly, is that why the output does not display correctly?

Thank you again for helping me.

Options: ReplyQuote


Sorry, only registered users may post in this forum.