Home Software Linux Instalace php 5.4 na debian 6

Adding dotdeb repositories

Open

1
/etc/apt/sources.list

and add these lines to the end of the file to add dotdeb repos:

1
2
3
4
5
6
7
# Main dotdeb repository
deb-src http://packages.dotdeb.org squeeze all
# PHP 5.4
deb http://packages.dotdeb.org squeeze-php54 all
deb-src http://packages.dotdeb.org squeeze-php54 all

Go to shell and type:

1
2
3
4
5
6
# Install the GnuPG key
cat dotdeb.gpg | sudo apt-key add -
# Download latest package info from repositories
apt-get update

Setting up MySQL 5.5

Database back up, removing old MySQL server

Before we start, back up your databases via mysqldump:

1
2
3
# --routines: procedures and functions are NOT dumped by default
# --create-options: include all MySQL-specific table options in CREATE TABLE statements
mysqldump -u root --password=yourpassword --create-options --routines database-name > /path/to/your/outputfile.sql

If you want to compress the sql file (which you probably do), type this instead:

1
mysqldump -u root --password=yourpassword --create-options --routines database-name | /bin/bzip2 -9 -c > /path/to/your/compressed_outputfile.sql.bz2;

If you already have previous version of MySQL server installed, you should first remove it to avoid possible conflicts (conf, files, directories, etc.):

1
apt-get remove --purge mysql*

Installing MySQL 5.5

Let’s get down to business:

1
apt-get install mysql-5.5 mysql-server-5.5

apt-get will probably offer you the installation of dependent packages, when prompted Do you want to continue [Y/n]? – type “Y” and Install these packages without verification [y/N]? – type “y”. The installation will now begin.

During the installation, you will be prompted to enter the root password. You are not required to do that (leave the field empty), but it is strongly advisable to do so. You can also do this later:

1
2
3
4
5
# If you have NO password set
mysqladmin -u root password yourpassword
# To update your existing password
mysqladmin -u root -p'currentpassword' password newpassword

Try to connect to your new MySQL server:

1
mysql -u root -p

Setting up PHP 5.4

Again, let’s begin with backing up at least your php.ini (copy it someplace else, preferably not to /dev/null). Where is your php.ini located?

Remove previous version of PHP, if any:

1
apt-get remove --purge php*

Installation

1
2
# note that we are installing dotdeb packages (-t squeeze-php54)
apt-get install -t squeeze-php54 php5 php5-mysql

In this setup, we only added core php5.4 modules + MySQL module. If you need more modules, attach their names to the previous shell command (separated by spaces), for example:

1
apt-get install -t squeeze-php54 php5 php5-mysql php5-imagick php5-json

or add them anytime later:

1
apt-get install -t squeeze-php54 php5-imagick php5-json php5-gd libapache2-mod-php5

Don’t add modules, which you don’t really need now. Gazillion loaded modules will decrease overall PHP performance and will unnecessarily consume system resources. You can always add a new module if you really need it, as described above.

The setup should automatically restart the webserver, if it doesn’t, run:

1
/etc/init.d/apache2 restart

That’s it, hope this small tutorial helped you. I will write a few words on configuration when time allows.

Galerie