To take screenshot on Android 4 or later press and hold the Volume Down and Power buttons at the same time.
Linux FTP ProFtpd server configuration: enable display hidden files
I have been working with some Linux servers with Plesk control panel. By default ProFtpd FTP server is configured to not display hidden files.
To fix this edit ProFtpd main configuration file /etc/proftpd.conf add line below:
ListOptions “-a”
inside <Global> </Global> section.
Check ProFtpd configuration using command:
# proftpd -t6
Checking syntax of configuration file
Syntax check complete.
Restart service.
1. If your ProFTPD server installed as part of xinetd:
# /sbin/service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
2. If your ProFTPD server installed as standard Linux service:
# /sbin/service proftpd restart
or
# /etc/init.d proftpd restart
Linux: check system, PHP and MySQL date and time
Sometimes it can be useful to verify if system, PHP and MySQL date and time is synced.
I am using this set of commands to check:
# date ; php -r "echo date('r').PHP_EOL;" ; mysql -e "SELECT NOW();"
Also, it can be useful to check the same information on remote server without logging in to it. It can be done using the same above set of commands plus ssh utility:
ssh taras@shkodenko.com 'date ; php -r "echo date(\"r\").PHP_EOL;" ; mysql -e "SELECT NOW();"'
Linux: how to kill hanged process
Sometimes, when I am working on Linux, some programs are hanging system, so further work is impossible.
I am using this set of commands to find out PID and other data of hanged process in good readable format (KeePass as example):
$ ps aux |head -n 1; ps aux |grep -v grep |grep -i pass
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
1000 29015 13.1 0.2 824732 40408 ? Sl 14:56 0:02 /usr/bin/mono /usr/bin/KeePass/KeePass.exe
Using this command below to terminated hanged process:
$ kill -s 9 29015
Do you have something to say more on this subject?
MySQL error: failed to connect to server on ‘xxx.yyy.zzz.aaa’ (113)
Sometimes using MySQL Workbench I am getting this kind of errors:
Failed to Connect to MySQL at xxx.yyy.zzz.aaa:3306 with user db_user
Can’t connect to MySQL server on ‘xxx.yyy.zzz.aaa’ (113)
To fix it add configuration directive:
skip_name_resolve = off
to main MySQL configuration file /etc/my.cnf using your favorite text editor (mine is Vim).
to section [mysqld]
and restart MySQL server using command as root:
# /etc/init.d/mysqld restart
PHP: get random array value
Sometimes it can be useful to get random array value in PHP.
You can use my function below to do it:
function getRandomArrayValue($a) { $k = array_rand($a); $v = $a[$k]; return $v; }
If you have any ideas how to make it better: all your comments are welcomed.
General transfer Magento website procedure in Linux
My general transfer Magento website on Linux procedure
1. Export MySQL database to SQL dump to file using phpMyAdmin or mysql command-line:
mysqldump -h localhost -u db_user -p db_name > ./db_name.sql
…or any other utility.
MySQL database host, name, user and password can be found in file ./app/etc/local.xml
Example section with db settings:
<config>
<global>
<resources>
<db>
<table_prefix><![CDATA[]]></table_prefix>
</db>
<default_setup>
<connection>
<host><![CDATA[localhost]]></host>
<username><![CDATA[db_user]]></username>
<password><![CDATA[db_password]]></password>
<dbname><![CDATA[db_name]]></dbname>
<initStatements><![CDATA[SET NAMES utf8]]></initStatements>
<model><![CDATA[mysql4]]></model>
<type><![CDATA[pdo_mysql]]></type>
<pdoType><![CDATA[]]></pdoType>
<active>1</active>
</connection>
</default_setup>
2. If you transfer Magento from one domain (domain1.com) to another (domain2.com) replace all matches in SQL dump file using vim:
domain1.com
—>
domain2.com
:%s/domain1.com/domain2.com/g
:w
or
http://domain1.com
—>
http://domain2.com
:%s/http:\/\/domain1.com/http:\/\/domain2.com/g
:w
or using Perl, sed or any other utility.
I am prefering to make SHA1 checksum using command:
sha1sum -b ./db_name.sql
and archive it after each replace:
tar cpjf ./db_name.sql-N.tar.bz2 ./db_name.sql
for each saved sql file version.
Do not forget to replace both www. and without www. domain name versions.
3. Make all files backup.
For example:
cd /var/www/vhosts/domain1.com/httpdocs
tar cpjf /var/www/vhosts/domain1.com/private/domain1.com.tar.bz2 ./ –exclude ./var/cache –exclude ./var/reports
4. Copy backup to new server using scp (ssh secure copy):
scp /var/www/vhosts/domain1.com/private/domain1.com.tar.bz2 domain2@domain2.com:/home/domain2/
or lftp (via plain ftp):
lftp -e ‘put -a -O / /var/www/vhosts/domain1.com/private/domain1.com.tar.bz2; bye;’ -u domain2,ftp_password domain2.com
or any other FTP client.
5. Restore files from backup:
cd /home/user2/public_html/
tar xjf /home/user2/domain1.com.tar.bz2 ./
mkidr -pv ./var/cache
mkidr -pv ./var/reports
Make both ./var/cache and ./var/reports writable for web server user e.g. apache or nobody using chmod.
6. Restore MySQL database from file:
mysql -h localhost -u db_user -p db_name < ./db_name.sql
7. Change Magento settings in file ./app/etc/local.xml suitable for new server.
8. Do not forget to check all custom .htaccess rules (custom php_value, rewrite rules, password protection, etc.) to match paths and server configuration at new server.
9. If you go from dev to production do not forget to check ./robots.txt file:
User-agent: *
Disallow: /
--->
User-agent: *
Allow: /
and vise versa.
Do you have any thoughts about this subject?
Linux: how to find files changed in dates range
Working in Linux you need to find files changed in dates range.
To find these files I am using set of commands below:
1. Create file stamp with date range begin:
$ touch –date "2012-11-01" ~/tmp/2012-11-01.txt
2. Create file stamp with date range end:
$ touch –date "2012-11-10" ~/tmp/2012-11-10.txt
3. Find all files in user home directory changed in dates range:
$ find ~ -type f -newer ~/tmp/2012-11-01.txt -not -newer ~/tmp/2012-11-10.txt
How to output configuration file content without comments and empty lines
Sometimes working in Linux you may need to output configuration file content without comments and empty lines.
In this case you can use command sequence below:
cat /etc/my.cnf |grep -v '#' |sed '/^$/d' |more
You can replace /etc/my.cnf with another configuration file name and '#' with any other comment mark e.g. ';' or '//'
Hello, all!
Welcome to my little online world.
This is my first post.
I will edit but not delete this post. Because this one will remind me exact day then I have start blogging here!