How to Run PHP Files on My Computer

How to run php files on my computer

You have to run a web server (e.g. Apache) and browse to your localhost, mostly likely on port 80.

What you really ought to do is install an all-in-one package like XAMPP, it bundles Apache, MySQL PHP, and Perl (if you were so inclined) as well as a few other tools that work with Apache and MySQL - plus it's cross platform (that's what the 'X' in 'XAMPP' stands for).

Once you install XAMPP (and there is an installer, so it shouldn't be hard) open up the control panel for XAMPP and then click the "Start" button next to Apache - note that on applications that require a database, you'll also need to start MySQL (and you'll be able to interface with it through phpMyAdmin). Once you've started Apache, you can browse to http://localhost.

Again, regardless of whether or not you choose XAMPP (which I would recommend), you should just have to start Apache.

Is it possible to run .php files on my local computer?

Sure you just need to setup a local web server. Check out XAMPP: http://www.apachefriends.org/en/xampp.html

That will get you up and running in about 10 minutes.

There is now a way to run php locally without installing a server:
https://stackoverflow.com/a/21872484/672229

How do I show / run a PHP file in a browser? As if it was a webpage

You need to download a server, and install it. If you want to go to the trouble, you can get XAMPP, and once it's installed, move the PHP file to the root of your installation (usually c:\xampp\htdocs\ on windows) and then use the url localhost/script.php in your browser.

How to run a PHP file on my computer that is outside the htdocs directory?

There is some ways to do it, but the simplest way is using 'include' or 'required' php command:

<?
include ('/somewhere/outside/of/your/htdocs/file.php');
?>

Please note you may need to turn off 'open_basedir' php directive.

Run .php file in Windows Command Prompt (cmd)

If running Windows 10:

  1. Open the start menu
  2. Type path
  3. Click Edit the system environment variables (usually, it's the top search result) and continue on step 6 below.

If on older Windows:

  1. Show Desktop.

  2. Right Click My Computer shortcut in the desktop.

  3. Click Properties.

  4. You should see a section of control Panel - Control Panel\System and Security\System.

  5. Click Advanced System Settings on the Left menu.

  6. Click Enviornment Variables towards the bottom of the System Properties window.

  7. Select PATH in the user variables list.

  8. Append your PHP Path (C:\myfolder\php) to your PATH variable, separated from the already existing string by a semi colon.

  9. Click OK

  10. Open your "cmd"

  11. Type PATH, press enter

  12. Make sure that you see your PHP folder among the list.

That should work.

Note: Make sure that your PHP folder has the php.exe. It should have the file type CLI. If you do not have the php.exe, go ahead and check the installation guidelines at - http://www.php.net/manual/en/install.windows.manual.php - and download the installation file from there.

PHP server on local machine?

Install and run XAMPP: http://www.apachefriends.org/en/xampp.html

How to make Notepad++ run the PHP file on the server that I set?

What you probably need is an FTP Synchronize plugin that will allow you to edit a copy of your php file and then synchronize it to the server.

How to Install:

  1. Make sure that your Notepad++ is closed

  2. Download from this link . I choose version 0.9.6.1. Unpack or Unzip to \Notepad++\plugin folder.

  3. It will have its own folder so copy or cut and paste the files to
    \Notepad++\plugin

  4. Read the file named "What file to use" so that you will know which
    to use. In my case I used FTP_synchronize.dll

  5. Run your Notepad++ and it will tell you that it will remove the
    unwanted files and just click Ok for it.

  6. Go to Plugin-->FTP Synchronize-->Show FTP Folders. And presto there
    you have it!

How to Connect:

Go to menu Plugins-->FTP Synchronize-->Show FTP Folders

Go to Menu Plugin

Click Open Settings Dialog

Sample Image

Click the New Button then type-in the Address, Port, Username,
Password and check Active on Connection Mode. And finally Click OK.

Sample Image

Click Connect

Sample Image

Click upload Current File to Folder

Sample Image

Then check your website and in my case the files uploaded are on the login name that I used that turned into a folder. And inside the folder are the files that I uploaded. Or of course you could really go directly to the wwwroot folder (or whatever folder name for your root) if you like so that you don't have to transfer the files.



Related Topics



Leave a reply



Submit