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

Thread: How to run PHP and mySQL in openSUSE

  1. #1

    Default How to run PHP and mySQL in openSUSE

    Hi to all,

    I'm a PHP developer and have been using xampp/wamp under Windows. I just decided to have a try at web development under Linux and would like to do this on my oS 12.3 VMware installation. I would like to know :

    1- How do I run PHP and mySQL services? (Names of required packages and procedure to start the service will be helpful)
    2- Where do I place my PHP files and which local URL can I use to run the PHP files?
    3- Where are the mySQL database files located?
    4- Any helpful information on running PHP/mySQL commands from the terminal

    (5- Python too, any helpful info on how to run Python files)

    I'm sorry if my questions are too many and thanks in advance for your help.

    Cheers

  2. #2

    Default Re: How to run PHP and mySQL in openSUSE

    Quote Originally Posted by IT_guy View Post
    1- How do I run PHP and mySQL services? (Names of required packages and procedure to start the service will be helpful)
    MySQL (well, MariaDB actually, which is a drop-in replacement by the original MySQL author) should be installed by default, you just have to enable automatic start on boot:
    Code:
    sudo systemctl enable mysql
    For PHP I guess the easiest would be to just install the LAMP pattern: Enter YaST->Software Management, select "View"->"Patterns" and search for "Web and LAMP server" in the list on the left (in the "Server Functions" category). Tick it and click "Accept". This should install both Apache and PHP.

    Then enable automatic start on boot for apache:
    Code:
    sudo systemctl enable apache2
    And you should have a working webserver after reboot. Call "http://localhost/" in a webbrowser to check.

    2- Where do I place my PHP files and which local URL can I use to run the PHP files?
    The default location is /srv/www/htdocs/, you can access them with just "http://localhost/" then.
    There's also a public_html directory in your home dir, which can be accessed with "http://localhost/~username/"...

    3- Where are the mySQL database files located?
    In /var/lib/mysql/ by default.

    4- Any helpful information on running PHP/mySQL commands from the terminal

    (5- Python too, any helpful info on how to run Python files)
    I don't quite understand. What do you mean with running PHP commands from the terminal?
    You can run php scripts with "php filename.php", is that what you mean?. The same with python.
    Or add something like "#!/usr/bin/python" at the top of your script and make it executable.

    For mySQL commands, just run "mysql -u root" and enter them. (or use any other user)

  3. #3

    Default Re: How to run PHP and mySQL in openSUSE

    On 2013-08-21, wolfi323 <wolfi323@no-mx.forums.opensuse.org> wrote:
    >> (5- Python too, any helpful info on how to run Python files)

    > I don't quite understand. What do you mean with running PHP commands
    > from the terminal?
    > You can run php scripts with "php -filename.php-", is that what you
    > mean?. The same with python.
    > Or add something like "#!/usr/bin/python" at the top of your script and
    > make it executable.


    Perhaps I'm missing something obvious here, but the basic way to run a python script is

    either:

    Code:
    sh-4.2$ python file.py
    ....or:

    Code:
    sh-4.2$ python
    Python 2.7.3 (default, Apr 14 2012, 08:58:41) [GCC] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> execfile("file.py")

  4. #4

    Default Re: How to run PHP and mySQL in openSUSE

    Quote Originally Posted by flymail View Post
    On 2013-08-21, wolfi323 <wolfi323@no-mx.forums.opensuse.org> wrote:
    >> (5- Python too, any helpful info on how to run Python files)

    > I don't quite understand. What do you mean with running PHP commands
    > from the terminal?
    > You can run php scripts with "php -filename.php-", is that what you
    > mean?. The same with python.
    > Or add something like "#!/usr/bin/python" at the top of your script and
    > make it executable.


    Perhaps I'm missing something obvious here, but the basic way to run a python script is

    either:

    Code:
    sh-4.2$ python file.py
    Yes, of course. That's what I wanted to imply with "The same with python."
    I guess I should have been more explicit there, sorry.

  5. #5
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,138
    Blog Entries
    2

    Default Re: How to run PHP and mySQL in openSUSE

    Besides what has been posted

    Install the LAMP pattern for a fully functional PHP/MySQL setup, fully configured.

    Ordinarily you place your website files in /srv/www/htdocs , in fact if you install a full PHP based framework you may only need to copy some bootstrap files there and open a web browser to Localhost which will not only complete installing web pages but also create your MySQL database complete with tables, relationships, autentication, etc

    PHP files can be run standalone but that's not likely what you want... You likely want a PHP website running in Apache webserver.

    Most people manage/modify their MySQL from a terminal, typically does not require any knowledge where files are located.

    TSU

  6. #6
    Join Date
    Jun 2008
    Location
    West Yorkshire, UK
    Posts
    3,448

    Default Re: How to run PHP and mySQL in openSUSE

    If you want to use the same data as you have used in Windows, use

    Code:
    mysqldump -u root -p --all-databases > [path to]backup.sql
    to make a back up your existing mysql files.

    Code:
    mysql -u root
    souce [path to]backup.sql;
    flush privileges;
    to install them in openSUSE.

    When mysql/mariadb is initially installed, mysql.user has no passwords; this will carry over all the users, passwords and databases you had in Windows.

  7. #7

    Default Re: How to run PHP and mySQL in openSUSE

    A big huge thank you to all for your help!! All your posts have been very extremely super helpful. I had everything set, up and running in no time at all.

    Thanks again to everyone who replied to this thread.
    Cheers

    PS: Only one last little question: how can I get phpmyadmin? Is there some sort of phpmyadmin package? (I could not find one from Yast)

  8. #8
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    19,800
    Blog Entries
    14

    Default Re: How to run PHP and mySQL in openSUSE

    Quote Originally Posted by IT_guy View Post
    A big huge thank you to all for your help!! All your posts have been very extremely super helpful. I had everything set, up and running in no time at all.

    Thanks again to everyone who replied to this thread.
    Cheers

    PS: Only one last little question: how can I get phpmyadmin? Is there some sort of phpmyadmin package? (I could not find one from Yast)
    software.opensuse.org: Download openSUSE 12.3 is your friend , see software.opensuse.org:
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  9. #9

    Default Re: How to run PHP and mySQL in openSUSE

    Quote Originally Posted by IT_guy View Post
    PS: Only one last little question: how can I get phpmyadmin? Is there some sort of phpmyadmin package? (I could not find one from Yast)
    This _is_ included in standard 12.3, see here: software.opensuse.org:

    So you should be able to install it with just "sudo zypper in phpMyAdmin" or YaST.

    But I never used this package myself, so can't tell you how to set it up, maybe it "just works" after installing the package?

  10. #10

    Default Re: How to run PHP and mySQL in openSUSE

    Quote Originally Posted by wolfi323 View Post
    But I never used this package myself, so can't tell you how to set it up, maybe it "just works" after installing the package?
    Well, I tried it now:
    Just install the package and point your browser to "http://localhost/phpMyAdmin/".

    And you'll find the config file in /etc/phpMyAdmin/ ...

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

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