Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: How do i run a .php file

  1. #1
    Join Date
    Dec 2007
    Location
    ~
    Beans
    314
    Distro
    Ubuntu 10.04 Lucid Lynx

    Exclamation How do i run a .php file

    I got a script.php file.... how do i compile and run this script....

  2. #2
    Join Date
    Oct 2006
    Location
    Belgrade, Serbia
    Beans
    1,325
    Distro
    Ubuntu

    Re: How do i run a .php file

    only do this if it's your own script - if it's not, please consult someone to check it out before trying it!

    open up gnome terminal and execute:
    Code:
    sudo apt-get install php5-cli
    then use the "cd" command to head to your php5 script directory, and do:
    Code:
    php your-file.php

  3. #3
    Join Date
    Jan 2008
    Location
    Auckland, New Zealand
    Beans
    3,134
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: How do i run a .php file

    A php script is usually used to build websites and is interpreted by a web server. If you want to run a php script yourself you can install the php5-cli package. If you want to use this php script to test and build a website then you will want to install the apache2 web server and php.

  4. #4
    Join Date
    Dec 2007
    Location
    Romania
    Beans
    80
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Red face Re: How do i run a .php file

    Quote Originally Posted by nebu View Post
    I got a script.php file.... how do i compile and run this script....
    You can't compile a PHP script. You can use a byte-code cacher, but you can't compile it

  5. #5
    Join Date
    Feb 2008
    Location
    United States
    Beans
    41
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: How do i run a .php file

    Open a gnome-terminal and do something like this:

    Code:
    sudo apt-get install php5
    cd mylocation
    php myfile.php
    Also you should probably do a web server if you want to use PHP for the conventional use (designing websites and databases).

    Code:
    sudo apt-get install apache2
    sudo apt-get install mysql-client mysql-server php5-mysql
    PHP's best used with Apache.
    http://www.apache.org/
    My AJAX apps project: https://launchpad.net/gold-os/
    My Personal Website: http://jhuni.freehostia.com

  6. #6
    Join Date
    Jul 2008
    Beans
    203
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: How do i run a .php file

    I have installed both - PHP and Apache.

    Now I need to run file index.php so it looks like in my browser like I visit the site.

    How should I do this?

    TIA

    Michael

  7. #7
    Join Date
    Jul 2008
    Beans
    203
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: How do i run a .php file

    Found how to do this here http://www.howtogeek.com/howto/ubunt...che-on-ubuntu/

    But /var/www is located in root folder, how can I obtain same at my home directory?

  8. #8
    Join Date
    Mar 2011
    Location
    India
    Beans
    73
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: How do i run a .php file

    i got nothing from the link you gave....can any one help me how to run my php file in firefox....i have php and apache installed...this is my first php script

  9. #9
    Join Date
    Jul 2010
    Beans
    1

    Re: How do i run a .php file

    Code:
    php myfile.php > myfile.html && firefox myfile.html
    This code in terminal will take the php file and process it into a proper file, then opens it in firefox.

    This simulates what a web server would do with said php script.

    Dependencies: php5-cli, php5

  10. #10
    Join Date
    May 2011
    Beans
    273

    Re: How do i run a .php file

    Since you're a beginner, I recommend that you install a simple server to run php files called XAMPP (actually it's much more than just that, but lets leave that behind). Tutorials can be found all over the internet
    Your left hand is touching your face.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •