Nombre total de pages vues

mercredi 30 novembre 2011

10 PHP Tutorials For Beginners, Tips & Tricks

10 PHP Tutorials For Beginners, Tips & Tricks:

'via Blog this'

mardi 15 novembre 2011

Move MySQL datadir

We are going to see how to move MySQL datadir without loosing data. This is usefull when you meet a disk space problem or when you want to change your database server.

Operation is very simple, we just have to create a new directory in which we are going to copy the old datadir content. MySQL must be stopped before the copy to be sure that nothing will be modified during the data copy. Then we have to edit the mysql config file to define the new datadir. Finally, restart MySQL server and check that everything is ok. old mysql datadir: /var/lib/mysql new mysql datadir: /opt/mysql/datadir Here is the detail of commands:
# create directory, chown, chmod it
mkdir /opt/mysql/datadir
chown mysql:mysql /opt/mysql/datadir
chmod 0755 /opt/mysql/datadir

# save my.cnf
cp /etc/my.cnf /etc/my.cnf.bak

# stop mysql
/etc/init.d/mysql.server stop

# change datadir in my.cnf
vim /etc/my.cnf

:%s?/var/lib/mysql?/opt/mysql/datadir?g

:wq

# copy old datadir to new datadir
cp -rp /var/lib/mysql/* /opt/mysql/datadir/

# start mysql
/etc/init.d/mysql.server start
Now it's important to check that everything working fine, if all is ok we can remove the old datadir:
rm -rf /var/lib/mysql
Otherwise, we go back like this:
/etc/init.d/mysql.server stop
mv /etc/my.cnf /etc/my.cnf2 && mv /etc/my.cnf.bak /etc/my.cnf
/etc/init.d/mysql.server start

mercredi 2 novembre 2011

PHP Server Monitor

PHP Server Monitor is a script that monitors the status of a server or service in a list on a given port. It comes with a web interface from which you can add a server or service, this interface is coupled to a MySQL database. We can also manage users will be alerted for each service by mail or SMS in case of failure. To check a site, the script will use cURL to interpret the HTTP code.

Features:
* check if services (ie IMAP) are up and running on your servers
* check if websites are available (ie no 404 Not found errors)
* get email notifications if a server or website goes down
* get sms (text message) notifications if a server or website goes down
* add multiple users with email address and phone number
* choose who receives the notifications for each server
* easy to use interface
* saves all errors in a log table
* see response time from servers and websites
* separate cronjob file

Install:
cd /downloads
wget http://downloads.sourceforge.net/.../phpservermon-2.0.1.zip...
unzip phpservermon-2.0.1.zip
mv phpservermon /var/www/html/
chown -R apache:apache /var/www/html/phpservermon
cd /var/www/html/phpservermon
mv config.inc.php.sample config.inc.php
vim config.inc.php

// Database information
// Prefix used for tables
define('SM_DB_PREFIX', 'monitor_');
// Database username
define('SM_DB_USER', 'root');
// Database password
define('SM_DB_PASS', 'yourpassword');
// Database name
define('SM_DB_NAME', 'phpservermon');
// Database host
define('SM_DB_HOST', 'localhost');

:wq

mysql -e "create database phpservermon;" 

http://myserver/phpservermon/install.php

rm /var/www/html/phpservermon/install.php

Use:
http://myserver/phpservermon

To check services, we need to configure a cron job with provided script in project:
crontab -e

*/5 * * * * /usr/bin/php -q /var/www/html/phpservermon/cron/status.cron.php

:wq



Project page:
http://sourceforge.net/projects/phpservermon/