-2

My computer is a Windows 10 64 bit.
I tried to run my PHP code, steps:

  1. Downloaded php.net.
  2. Set the environment variables path as instructed. Ran the command line like this: https://imgur.com/a/Q9zs9mL

    Microsoft Windows [Version 10.0.17134.345]
    (c) 2018 Microsoft Corporation. All rights reserved.
    
    C:\Users\Mai Do>php -S localhost:4000
    PHP 7.2.10 Development Server started at Mon Oct 22 21:04:32 2018
    Listening on http://localhost:4000
    Document root is C:\Users\Mai Do
    Press Ctrl+C to quit.
    
  3. Created a PHP file, first with NetBeans

  4. Saved the file in the root directory folder named "php1" (try to be different from my root name)
  5. Typed in browser: localhost:4000/php1/input.php
  6. Object not found 404 page.
  7. Tried multiple times with different php file. same thing.
  8. Switch to Atom. Same thing.
  9. Moved the file to htdocs folder. Same thing
  10. Download Xampp. Turn on the Apache and MySQL. XAMP ver 3.2.2 control panel shows up. Both Button turn to Green. Still not found.

This SO page PHP not working in XAMPP says:

If you're trying to connect via your IP then your router must be stopping it so you have to sort the settings out. I don't know your router make/model you better off asking their support forums.

I am thinking there might be a server config problem. Like this one has a similar issue: Apache2 not working with routes PHP which leads to this: https://docs.bolt.cm/3.0/howto/making-sure-htaccess-works

"Editing the apache2.conf and setting 'AllowOverride All' on , finally works." ???

I am not sure if that is the right problem either. Can someone walk me through it? Bless you.

Petru Zaharia
  • 1,031
  • 13
  • 20
Mai Do
  • 1
  • 1
  • 1
  • The steps are incorrect and it's expected not working in such way. Please read the manual of XAMPP before continue crafting your development environment. – Raptor Oct 23 '18 at 02:14
  • Well, I followed what this page says first: https://www.quora.com/How-do-I-run-a-PHP-source-code. Guess I will read the actual xampp manual and let you know how it works! – Mai Do Oct 23 '18 at 02:44
  • Just follow the steps in my answer. – Raptor Oct 23 '18 at 02:55

1 Answers1

0

To set up a test environment on your personal computer, follow the steps below:

  1. Remove any installed PHP (Windows: uninstall via "Add/Remove Programs")
  2. Install XAMPP (in your case, it's better to re-install the software suite)

XAMPP is a software suite that contains PHP + MariaDB (a fork from MySQL) + Apache Web Server + Perl. In your case, you are going to use PHP & Apache only.

  1. Configure the DocumentRoot in Apache config file; you should put your website files in this DocumentRoot, thus I recommend you to set the path value to your development path. Read the manual if you're unsure how to do so.
  2. Start/Restart Apache. If everything goes smooth, Apache should be up and running at port 80 (by default).
  3. Launch your favorite browser and navigate to http://localhost
  4. You should see your website written in PHP

If you have any further questions, please ask in the comment box below.

Note:

  • NetBeans is an IDE, not related to your testing environment
  • You can actually write your PHP scripts using any text editor
Raptor
  • 53,206
  • 45
  • 230
  • 366