Running PHP Applications on Linux

Overview:

I usually find that lots of poeple find it quite difficult to install any application made in PHP and MySQL on their Linux boxes. They find it a bit confusing how to configure the settings. How to install the LAMP stack. Where to put the PHP applications code. I was quite inspired to write to this after having I saw people facing problems on Ubuntu Forums. This is the one which I dealt with.

Sometimes spoon-feeding becomes important,but only for the first time.

Scenario:

A newbie who knows just the basics of Linux. He/She wants to run a PHP application like wordpress / phpBB / osCommerce on their computer.

The distro is assumed to be Ubuntu, though it doesn’t change much for others too.

Lets Start:

Step 1: Getting the LAMP stack on your system

You first need to install LAMP on your box, Installation is quite simple. Just get the following packages using the command on your terminal ( Applications> Accessories>Terminal)

sudo apt-get install apache2 php5-mysql libapache2-mod-php5 mysql-server

While installing MySQL, it might ask for set up the root password,if it doesn’t ask, then continue.

For more information check this post here .

Step 2: Download the PHP application

You need to download the PHP application which you want to run over the webserver. Examples are WordPress, phpBB, osCommerce, MediaWiki etc

Get them and let it be in the folder where you have downloaded it.

Step 3: Moving these software to the Apache’s root directory

Apache’s root directory is /var/www (/var/www/html). This is owned by the user www-data which is a minimal user created just for running apache and web servers. A normal user cant write to this directory.

Now here is the solution of how to copy the data to this directory. This method can be used for any directory which the normal user does not have write access. The concept behind the method is to start an instance of nautilus ( explorer) with root (superuser) privileges. For this follow the isntructions

* Press Alt + F2

* A Run daialog box appears, over there type gksudo nautilus /var/www

* You will be asked for your password as you are elevating your privileges

* Nautilus opens up,now copy the tarball/zip file from the download location to /var/www

* Untar the archive by Right Click > Extract Archive

You may have the package in the folder say /var/www/wordpress. We are supposing wordpress as an example.

Step 4: Setting up username and accounts in database

Now you need to have a create a new database for the software you intent to work on. For this open MySQL from the terminal. If you had been asked to set up the password at time of MySQL installation then use this command

mysql -u root -p

and then enter the root password which you set up

if you were not asked to set up root password, then use this command at terminal

mysql -u root

After this is done you will be dropped to mysql prompt. Create a new database using this:

create database foo;

type quit to exit.

Step 5: Change the data in the config file.

Hunt for file which may have name such as config,settings etc etc. One you locate it,open to find the area for entering database settings. The settings should be:

Hostname: localhost

Username: root

Password: <the password you set up>

Database name: foo (or whatever you created)

Step 6: Access it via browser

Now point your browser to http://localhost/wordpress

You may get the basic installation thing or whatever stuff you need.

Additional Stuffs:

You can be asked to make some locations writable. There may be instances like the software cant write to a specific folder or file. It can be used for cache or any such temporary stuff. Then you need to change the permissions. Simply give write permissions to the user www-root. However this situation may be unlikely. e..g we have to change the permissions of folder /var/www/wordpress/cache

sudo chmod -cR u+w /var/www/wordpress/cache

Advertisements

23 thoughts on “Running PHP Applications on Linux

  1. Any softwares which are made using PHP is called a php application. I still think this term can be a misnomer.

    Try out wordpress, phpBB, MediaWiki, osCommerce, drupa, joomla and you will come to know what exactly they are.

  2. Hiya,

    Its me again,hehe
    How do i administer osCommerce?I mean I tested out a few transactions by registering users and purchasing items,now how do i process the orders if i had wanted to…ie how do i view the customer profile,items purchased n so on…
    i dont have the faintest idea on mysql,so thouta asking u,if u dont mind……

    cheers

  3. @David
    I think its related to osCommerce, frontends should be provided for these work. You need not goto Database and confirm orders.
    Database is meant for communication and data management by the software itself. You should never manipulate with the DB, it might lead to inconsistency.

    And well I think your question should be solved in osCommerce forum, check here
    http://forums.oscommerce.com/

  4. hi,
    i am a totally newie to php, and found your tutorial to the installation very good, so tkx! i installed has you said in my xubuntu 8.10.
    The localhost shows me an “it works” page. But when i try to reach a .php file, it doesnt show it. Firefox asks me to download it! And if i hide the php script in a .html file, it wont appear.
    any ideas why so?

    tkx again

  5. To execute PHP scripts, you need to keep them as .php extension.

    The problem you might be facing is that the package libapache2-mod-php5 might not be installed properly. This is the package which takes care of PHP running with Apache. That is, its the php module for apache.

    As the package description says:
    This package provides the PHP5 module for the Apache 2 webserver (as found in the apache2 mpm-prefork package). Please note that this package ONLY works with Apache’s prefork MPM.

  6. hi,
    i am a very newbie with this OS, and i have the same problem, and still i am not able to view the php page of an application, i googled and i knew that there is a common problem with php on apache but i am not able to resolve, any idea from where to start troubleshooting?

  7. Hi manish i m a new bee for php and linux, i installed php5 apache2 and mysql with the guidance of ubuntu forum, i want to use my desire folder as repository rather than /var/www please help me.

  8. This is why our prospective buyers adore specific performance having to
    do with AJ Matrix products. Our own baby’s
    Genetics is adequate amounts to locate and display the dna paternity of an father.
    In case you are undoubtedly an athlete, then you have to know information about a highly effective technique labelled visualization.

  9. ?Essay Crafting Company: Swift Choice to Long-Standing Problems
    Oh, if essay composing had been straightforward! There is not any conclusion in sight to these tasks! Urgent essay? – Oh no, not again! Student’s reaction towards essay creating is almost always the same…the same negative. Why so? There are a wide range of reasons, starting off from incomplete knowledge or poor composing skills to life circumstances that are beyond human control. But the biggest problem is the lack of time. If there were being much more time, students life would be easier.
    Urgent-Essay.com knows how overloaded students are. Therefore we offer you urgent essay composing expert services that will help you to definitely go far in your own academic life without spending quite a bit time on swotting tons of theoretical material and endless writings. Order from Urgent-Essay.com and your studies will have a rewarding adventure.
    Original urgent essay is not really the limit
    Essays creating seriously isn’t the entire story with unhappy ending for students. There are assignments which cause no less stress and difficulties than composition overall performance. However for Urgent-Essay.com there isn’t a this kind of task that would be unsustainable for our talented and skillful writers. Their all-round knowledge, awareness of academic standards and neat crafting style make production of any task in any subject doable. Thus, a customer can choose from:
    Huge list of disciplines, that incorporates all fields of knowledge from art and humanities to exact sciences and tips systems
    Type of tasks setting up from short urgent essays to bulky research projects
    Any academic producing style. We are prepared to accomplish your task in APA, MLA, Chicago, Turabian or the style you indicate
    Any academic degree from higher school to university highest degree
    Get a lot of benefits from ordering one personalized urgent essay
    When in catch 22 situation you make an order at essay composing provider in check out to get help with your solitary academic assignment and really do not lay large hopes on brilliant functionality and some further merits, with our urgent essay composing support you might be sure to get some. Urgent-Essay.com is effective to the velvet of its potential customers, ensuring:
    No piracy within your task. Only original assignments that are written from the scratch are delivered to the prospects
    Complimentary revision which is of use during two weeks after order completion
    Non-stop by going online help from professional customer service team. They are wanting to answer your questions 24/7
    Convenient message board to make customer’s using the web communication with personal writer extra effective
    Prompt delivery with the most custom made urgent essay and therefore the most lengthy assignment
    100% safety of client’s private critical information. Our urgent essay crafting program assures that neither customer’s personal facts nor accomplished task is shared or sold to the third parties
    Money again guarantee. Urgent-Essay.com will refund money if the task a customer gets doesn’t meet his/her demands
    So, why choose any crafting services and keep asking yourself a question: what if it will be rather the thing, as soon as you tend to be 100% sure in an unsurpassed outcome with Urgent-Essay.com?
    Crafting company with accessible prices
    How a lot would you give for urgent essay composing? We bet that at Urgent-Essay.com you are able to buy a single in a amount that will not hit you like a ton of bricks. The prices for our offers you are irremovably affordable for all the users. Additional to everything else, in the event you buy urgent essays or any academic assignment for your to begin with time considerable discount is guaranteed. And our standing clients always enjoy regular bonuses.
    So, really don’t delay choice to your academic problems – make an order and see how your troubles fade absent.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s