Posted in

how to move your php development environment to linux (Debian/Ubuntu)

Nowadays, lots of php developers are thinking to move their development environment to linux. And I am writing this tutorial for them. As I like Debian GNU/Linux (www.debian.org) best and ubuntu (www.ubutnulinux.org) is now doing great, in this tutorial I am using the commands for debian & ubuntu.

Ok, now starting:

First on all let’s make a list of software a PHP developer need mostly:

1.Apache
2.PHP
3.Mysql
4.PHP IDE

Ok, let’s start with Apache. Debian & ubuntu use APT to manage the packages. You can easily install apache using apt, here is the command

Debian user:

su

Ubuntu user:

sudo su

Rest of the command ar same for both debian & ubuntu.

apt-get install apache2

It will install all the apache2 & all the related packages (software)
If you need to enable mod_rewrite, follow this link
Now install the PHP

Apt-get install php5 libapache2-mod-php5

This will install the php5 and configure your apache2 server for PHP. You don’t need to do anything.
Lets test the server, if it working ok.

touch /var/www/info.php

Chown www-data:www-data info.php

Now edit this info.php with your feviourate editor and add write code to show phpinfo():
and now browse http://localhost/info.php from your browser. Now check if all your requested library are installed.
if you need any more library, you can check if it already available on your debian/ubuntu package list.

apt-cache search php5-

then you will get the list of available php5 library. Now simple use this command to install it.

apt-get install php5-gd

(example, if you want to install php5 GD library)

Remember: after installing every extra packages, you must need to restart apache server

/etc/init.d/apache2 restart

Ok, so you have now apache2 and php5 installed system. Let’s install mysql:

apt-get install mysql-server-5.0 php5-mysql

It will install all the necessary packages to run mysql-server.
Now restart your apache to take effect.
Complete!!!! Server is allmost ready.
Now i am going to derive how you will transfer your old code to this new environment. Belive me it’s too simple, so don’t worry.

First of all copy your source code to /var/www, here is the details procedure:

mkdir /windows

Here we make a folder for C drive of windows to mount.
mount /dev/hda1 /windows
then we mount the C drive to windows folder (here i use hda1 as example, if your hdd is sata then it will be sda1)

cp -r windows/Apache2/htdocs/xyz /var/www

here we copied our xyz site to /var/www (in debian and ubuntu, default apache2 root folder is /var/www)

cd /var/www

chown -R www-data:www-data xyz

Now change the ownership to www-data

Now we need to move the mysql database, there is two way:

1.use phpmyadmin
2.simple copy the database from data folder
I am deriving the 2nd way.

cp -r /windows/Mysql/data/xyz /var/lib/mysql

chown -R mysql:mysql /var/lib/mysql/xyz

You are done.

PHP Ide for linux environment:

    1.Zend ( i personaly use this)
    2.PHPEd
    3.PHPEclipse
    4.quanta plus
    5.emacs
    6.vi
    7.PHPedit

***I know this tutorial needs more edit, please make your comments if you got anything wrong, or missed anything. I want it a cool tutorial for php developers.

Read some reviewed, the best and most affordable php hosting solutions on the market.

27 thoughts on “how to move your php development environment to linux (Debian/Ubuntu)

  1. বড়ই খটমটে ব্যাপার। বুঝতে পারলাম না।

  2. @omi: thanks, i forget to tell about xampp 🙂

    btw, i don’t like xampp (lot’s of bad experince with it)
    Belive me, i am runing 2 dedicated servers.

  3. hi lavlu, great work. it is so good to see how people with a burning passion also are good teachers and can give the best guidelines. it seems that the php team now is overflowing with passion and burning interest.

  4. @arild

    hey, php team was always overflowing with passion compared to your other teams, eh!

    see lavlu, x-hasin, morshed, mizan – all are guiding others in their blog!

  5. Very good effort 🙂 and also a useful post for PHP developers. keep up such good tutorials always.

    Installing XAMPP is easy as it hides all complexity. But as a developer everyone should know the manual installation and what’s actually going on the back end.

  6. আমি উবুন্টু যখন ইউজ করেছিলাম তখন উবুন্টুর সারভার সিডি থেকে পিএচপি ,মাইএসকিউএল তার পর পিএচপিমাইএ্যাডমিন ইনস্টলকরে মোটামুটি ল্যাম্প LAMP(Linux Apache Mysql PHP) বানিয়ে ফেলেছিলাম । আমার জুমলা , ওয়ারডপ্রেস পিএইচপিবিবির ইনস্টলের হাতেখড়ি ওখান থেকেই। তবে লিনাক্সে xampp ট্রাই করিনি।

  7. তবে নতুন ব্যবহারকারীদের জন্য xampp ভালো। আর আপনার লিনাক্সে যদি নেট কানেকশন না থাকে তবে লাভলুভাই এর উল্ল্যেখিত প্যাকেজগুলো আপনি Ubuntu Server Edition সিডি থেকে ইনস্টল করতে পারবেন।

    http://www.ubuntu.com/products/WhatIsUbuntu/serveredition

    সিডিটি ডাউনলোড করে Synaptic Package Manager এ গিয়ে রিপোজিটরিতে সারভার সিডিটি এ্যাড করে সিনাপটিকের প্যকেজ লিস্টটি রিফ্রেশ করলে উক্ত এ্যাপলিকেশন গুলো লিস্টে দেখাবে। আমি সুবিধার জন্য অন্য রিপোজিটরি গুলো মুছে দিয়েছিলাম ফলে লিস্টে ইনস্টলড এ্যাপলিকেশন এবং সারভার সিডির এ্যাপলিকেশন গুলোই দেখতে পেয়েছি। ((তবে দরকার নাহলে এটা আপনার করার প্রয়োজন নেই))

    ব্যাস

    হ্যাপি লিনাক্সিং লিনাক্সে আগ্রহীদের জন্য বলছি। সাইকেল চালানো শেখার সময় যেমন পড়ে পড়ে শিখেছিলেন তেমনি সহজ লিনাক্স “উবুন্টু” (সব অটোমেটিক আর সহজ যেমন হার্ডডিস্ক মাউন্টিং,deb file এ ক্লিক করে প্যাকেজ ইনস্টল ইত্যাদি)
    ব্যবহার না করে জটিলটি আগে ব্যাবহার করুন । যেমন আমার প্রথম ব্যবহৃত লিনাক্স হচ্ছে ফিডোরা কোর 4 এটি ব্যবহারের সময় নানান জায়গায় আটকেছি কিভাবে আমার হাডডিস্কড্রাইভ গুলো মাউন্ট করতে হবে জানতাম না

    আরপিএম প্যকেজগুলো কিভাবে টারমিনালে কমান্ড দিয়ে ইনস্টল করতে হয় জানতাম না , সোর্সকোড কম্পাইল করে কিভাবে প্রোগ্রাম ইনস্টল করতে হয় জানতাম না। এগুলো আস্তে আস্তে গবেষনা করতে করতে শিখেছি এক্ষেত্রে সবচেয়েবেশী সহায়তা যেখানথেকে পেয়েছি তাহল বিডিলাগ থেকে

    http://groups.yahoo.com/group/bdlug/

    এভাবে শিখার ফলে এখন আমি উবুন্টু ইউজ করলেও প্রয়োজনীয় অনেক কমান্ড জানি সহজ কাজটা জটিল ভাবে ও করতে জানি (Terminal) এ 🙂

  8. nice tutorial.. i agree abt xampp.. i also have some bad experience.. anyway i don’t like any third party package who make our life easier.. i can’t learn properly from that software.. how to configure or customize.. may be u all understand..

  9. thanks tania, arild, hasin bhai, darkloard, morshid bhai, mizan bhia, deborah apu, zaher, babu, omi , sharif for your valuable comments. Your comments giving the energy to write more :).

  10. Thanks for a great tutorial. Everything worked first time except moving database. After moving mysql db folders in phpmyadmin I can see a list of moved databases with correct number of tables next to them, but when I click on one of them they show as empty (no tables). Any suggestions?

  11. Thanks for a great tutorial. Everything worked first time, except moving mysql databases. I moved db folders and changed permissions. When I go to phpmyadmin it shows transfered databases and correct number of tables next to them, but when I click on one of them, it says database empty (no tables) any ideas?

  12. hi arnold,

    i just found the reson, i missed 1 command in mysql section.

    after
    “chown -R mysql:mysql /var/lib/mysql/xyz”
    you have to run:
    “chmod 700 -R /var/lib/mysql/xyz”

    please reply if you still getting problem.

  13. After posting here I decided to transfer my old data to another windows system, created temporary wamp server there and exported all databases using phpmyadmin.

    Anyway, thanks for your reply. Release of Hardy Heron and your post about moving development environment made me make up my mind and finally switch to Linux. I finally have Zend for Eclipse up and running and working on my projects again.

  14. It’s perfect time to make some plans for the future and it’s time to be happy.
    I have read this post and if I could I desire to suggest you few interesting things or suggestions.
    Perhaps you could write next articles referring to this article.

    I wish to read more things about it!

Leave a Reply to lavludaCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.