Thursday, February 17, 2011

Steps to upgrade PHP to 5.3.5 and MySQL to 5.1 in CentOS and RHEL

Hi,

The following steps will make you to upgrade PHP to 5.3.5 using remi repostries in CentOS and RHEL systems.

Preinstallation steps
=====================
Make a note of current PHP and MySQL versions by using the following commands

#php -v

mysql --version

backup running MySQL databases by using the fllowing steps

#cp -arp /var/lib/mysql /var/lib/mysql.bak

then dump the mysql databases using the following command

#mysqldump -you root -p(password) --all-databases > dumpfilename.sql

You can also take version compatible downgrade dump to check for any missing file restoring by using the following command

#mysqldump -you root -p(password) --all-databases --compatible=mysql40 > versioncompatibledumpfilename.sql


Also backup your php.ini(PHP configuration) file
cp -arp /etc/php.ini /etc/php.ini.back

Upgrading PHP
=============

Downloading Remi rpm
-----------------------

The below command will download and install remi rpms from source.

#rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

Remove all old PHP rpms from yum by using the following command.

#yum remove php*

Now you are ready with the remi repostries installed with in the server to upgrade PHP.

Please provide the following command to install php and its modules from yum remi repostries.

#yum --enablerepo=remi install php php-common php-pear php-pdo php-mysql php-pgsql php-pecl-memcache php-gd php-mbstring php-mcrypt php-xml php-imap php-devel php-odbc php-bcmath php-ldap

After installing restart httpd services

/etc/init.d/httpd restart

Now you will
You may get errors if your php cannot combine with lower versions of MySQL. So, you need to upgrade MySQL to 5.1

Please remove the older version of MySQL by removing mysql rpms

#yum remove MySQL

Now please install MySQL through remi rpms by following steps

#yum --enablerepo=remi install mysql mysql-server mysql-connector-odbc

The above command will install MySQL 5.1

To start mysql automatically on server restart please provide the following line which will start mysql on run levels 2, 3 and 5

#chkconfig --levels 235 mysqld on

Thats all now you have upgraded PHP and MySQL in the server to 5.3.5 and 5.1 respectively.

Check them by using the following commands

#php -v
and
#mysql --version

Please let me know if I have made errors, your comments corrects my mistakes.

Reference: http://www.if-not-true-then-false.com/2010/install-apache-php-on-fedora-centos-red-hat-rhel/

Thanks,
Siru

Installing and compiling Json with php

Hi,

This post guides you to compile PHP with json in CentOS.

By assuming that you have already installed PHP in the system I am going to guide you the installation steps

Please run the following command to install json in the server.

#pecl install json


After completing the command please goto php.d folder

#cd /etc/php.d/

Then open a file with .ini extension probably json.ini.

#vi json.ini

Add the following in json.ini file for php to load json extension.

extension=json.so

Then restart you httpd service.

#/etc/init.d/httpd restart

This will compile PHP with json.

Please let me know if I have made errors, your comments corrects my mistakes

Monday, January 24, 2011

MySQL command help

Command to create mysql user
============================

CREATE USER 'username'@'localhost' IDENTIFIED by 'password';

Command to grant all privileges to a user to databases starting with any name
=============================================================================
GRANT ALL PRIVILEGES ON database_.* TO 'username'@'localhost' IDENTIFIED BY 'password';

flush privileges;

The above two line command will make the user "username" to have all the privileges to add delete modify databases that starts with the name database_.

Command to dump mysql database
==============================
mysqldump -u [databaseusername] -p[password] databasename > databasebackup.sql


Command to restore mysql database
=================================
mysqldump -u [databaseusername] -p[password] databasebackup.sql < databasename

Tuesday, January 11, 2011

FreeBSD knowledgebase

Services location in FreeBSD
/usr/local/etc/rc.d

Crontab useful paths
/etc/crontab--root user crons
/var/cron/tabs--system user crons
also please check /var/cron/atjobs for any other crons.

Saturday, December 18, 2010

MySQL version downgrade in linux cPanel servers

SOP for MySQL version downgrade from 5.1 to 4.0 in cPanel servers
================================================
Pre-installation steps
==============

Before you downgrade the MySQL version you need to do the following steps so as to avoid data loss or file corruption

Check the MySQL version by using the following command

#rpm -qa |grep MySQL

O/P
MySQL-server-5.0.91-0.glibc23
MySQL-client-5.0.91-0.glibc23
MySQL-devel-5.0.91-0.glibc23
MySQL-shared-5.0.91-0.glibc23
MySQL-bench-5.0.91-0.glibc23


check the server OS as below

# cat /etc/issue
or
# cat /etc/redhat-release

O/P
CentOS release 5.5 (Final)

Server architecture check

# arch

O/P
x86_64

Before downgrading we need to backup MySQL databases so as to avoid data corruption so we are copying the mysql database folder by using the following command

#cp -arp /var/lib/mysql /var/lib/mysql.bak

then dump the mysql databases using the following command

#mysqldump -you root -p(password) --all-databases > dumpfilename.sql

You can also take version compatible downgrade dump to check for any missing file restoring by using the following command

#mysqldump -you root -p(password) --all-databases --compatible=mysql40 > versioncompatibledumpfilename.sql

Actual MySQL down-gradation
===================

Then now we can start the down-gradation process

First you need to open the cpanel.conf file and make changes to the MySQL-version line from 5.1 to 4.0 by following the using the command

#vi /var/cpanel/cpanel.config

After changing the MySQL version line from 5.1 to 4.0 in the configuration file we need to run the following command to force the MySQL up-gradation/Down-gradation.

#/scripts/mysqlup --force

Now the MySQL version down-gradation will take place, once the process is completed you can check the version of MySQL which will be

# rpm -qa | grep -i mysql-
O/P

MySQL-shared-4.0.27-0
MySQL-devel-4.0.27-0
MySQL-bench-4.0.27-0
MySQL-client-4.0.27-0
MySQL-embedded-4.0.27-0
MySQL-server-4.0.27-0


Restart MySQL services by using the following command
#/etc/init.d/mysql restart

That's all the MySQL version has been downgraded successfully.

Thursday, December 2, 2010

Adding extra/addtional FTP user for a domain in plesk control panel

Hi,

Finally you came here to know how to create additional FTP user account for a domain in plesk control panel, no wonder i will explain you its pretty simple, all you need is to be root of the server.

Let's get started.

Login to the server using root account and add a user which you need to restrict the files/folders that the user can access by using the following command.

#useradd -d /var/www/vhosts/domainname.tld/path/to/folder/

now a user will be created, but the user can access other files under / partition where the server has read permission to other users, this is a big security hole so you need make sure that the user shouldn't access other files in the server except the folder which he should access. So, you have to change change the group id for that particular user, this can be done by following the steps below.

All the user details will be in /etc/passwd file, there you need to change the group id from
username:x:500:500::/var/www/vhosts/domainname.tld/path/to/folder/:/bin/bash
username1:x:501:501::/var/www/vhosts/domainname.tld/path/to/folder/:/bin/bash


to

username:x:500:2425::/var/www/vhosts/domainname.tld/path/to/folder/:/bin/bash

[ Above I have changed the group id(500) to 2425 which is the default psactl group id for Plesk control panel it may differ for your server, you can check it with other FTP user names and use that for the new user]

Now you should also change the shell for the user which is currently set to user as /bin/bash, where the user can access the server using SSH, you need to change it to /bin/false which will make the user to use only FTP service.

That's it, a new FTP user is created in Plesk control panel.

Wednesday, December 1, 2010

Qmail logs

If you are using Plesk control panel the you will have your qmail logs at

/usr/local/psa/var/log/maillog
(function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })()