CentOS7 php redis server – permission denied

Fresh installation of redis, out of the box and it doesn’t work.
Never had this issue on Ubuntu ..

Warning: Redis::connect(): connect() failed: Permission denied in /var/www/vhosts/xxx/httpdocs/_/_.redis.php on line 12

We need to enable httpd to use redis’ default port 6379:

yum install policycoreutils-python
semanage port -m -t http_port_t -p tcp 6379
semanage port -l | egrep '(^http_port_t|6379)'
http_port_t tcp 6379, 80, 81, 443, 488, 8008, 8009, 8443, 9000
redis_port_t tcp 6379

No need to restart redis or httpd after this, it should work right away.

Run nodejs application in background

There are several ways to do this, you can either use nohup, or append & at the end of command – personally, I’ve found forever to do the job perfectly fine.
Assuming you already have npm installed, if not, just do

sudo apt-get install npm

Then install forever

npm install forever --global

Now you can run it like this

forever start app.js

And it will take care of everything.

/usr/bin/env: node: No such file or directory

Can be fixed by creating symlink.

cd /usr/bin
sudo ln -s nodejs node

View list of running nodejs apps in forever

root@ubuntu:/# forever list
info:    Forever processes running
data:        uid  command         script forever pid   id logfile                 uptime       
data:    [0] mqgC /usr/bin/nodejs app.js 29570   31398    /root/.forever/mqgC.log 0:1:25:6.344 

To see logs for your application, do forever logs + ID of the app ( in our list it’s [0] – 0 )

root@ubuntu:/# forever logs 0
data:    app.js:31398 - Node app is running on port 5000

Convert unix timestamp to human readable date in MySQL select

If you are using INT for storing timestamps in your mysql database, very often you are dealing with weird numbers that don’t tell you much, e.g.

mysql> select time from example LIMIT 0,5;
+------------+
| time       |
+------------+
| 1480496034 |
| 1477817634 |
| 1472547234 |
| 1469868834 |
| 1467276834 |
+------------+
5 rows in set (0.00 sec)

To convert it into human readable format, use

mysql> select FROM_UNIXTIME(time) from example LIMIT 0,5;
+---------------------+
| FROM_UNIXTIME(time) |
+---------------------+
| 2016-11-30 09:53:54 |
| 2016-10-30 09:53:54 |
| 2016-08-30 10:53:54 |
| 2016-07-30 10:53:54 |
| 2016-06-30 10:53:54 |
+---------------------+
5 rows in set (0.00 sec)

You can even change the date format freely using DATE_FORMAT function ( www.w3schools.com/sql/func_date_format.asp )

mysql> select FROM_UNIXTIME(time), DATE_FORMAT(FROM_UNIXTIME(time), '%j. day of year on %a') from example LIMIT 0,5;
+---------------------+-----------------------------------------------------------+
| FROM_UNIXTIME(time) | DATE_FORMAT(FROM_UNIXTIME(time), '%j. day of year on %a') |
+---------------------+-----------------------------------------------------------+
| 2016-11-30 09:53:54 | 335. day of year on Wed                                   |
| 2016-10-30 09:53:54 | 304. day of year on Sun                                   |
| 2016-08-30 10:53:54 | 243. day of year on Tue                                   |
| 2016-07-30 10:53:54 | 212. day of year on Sat                                   |
| 2016-06-30 10:53:54 | 182. day of year on Thu                                   |
+---------------------+-----------------------------------------------------------+
5 rows in set (0.00 sec)

Laravel – The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.

If you see this error you are missing APP_KEY.
Make sure you have .env in your main directory.

If you don’t have it one yet, create it.

root@vmware:/srv/www/laravel/public_html# > .env

Generate key

root@vmware:/srv/www/laravel/public_html# php artisan key:generate
Application key [base64:i7QndWbN33zY1x013Yw2cju9KQsxpT/1nnf8/3ziZ+U=] set successfully.

And now just add it into your .env file, clear cache and you are good to go

root@vmware:/srv/www/laravel/public_html# cat .env
APP_KEY=base64:i7QndWbN33zY1x013Yw2cju9KQsxpT/1nnf8/3ziZ+U=
APP_DEBUG=true
APP_ENV=development
APP_URL=http://laravel

root@vmware:/srv/www/laravel/public_html# php artisan cache:clear
Cache cleared successfully.

phpMyAdmin blowfish secret generator

The configuration file now needs a secret passphrase (blowfish_secret).
You’ll see this error after every installation of phpmyadmin.
To resolve this issue, just open config.inc.php ( or rename config.sample.inc.php to config.inc.php if you haven’t done so yet ) and change this line

$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

to

$cfg['blowfish_secret'] = '2}.JGeCFjQx2Uf}-rYTTMxKOHCK2L}LY';

To generate new blowfish secret, simply hit this https://phpsolved.com/phpmyadmin-blowfish-secret-generator/?g=67c2d10ead06a