To execure a system command on a server, use PHP exec function. For example
1 2 3 4 5 |
<?php @exec("nslookup yahoo.com 2>&1", $result); echo "<pre>"; print_r($result); |
See php […]
To execure a system command on a server, use PHP exec function. For example
1 2 3 4 5 |
<?php @exec("nslookup yahoo.com 2>&1", $result); echo "<pre>"; print_r($result); |
See php […]
Install ruby from source Install rvm (ruby version manager) Nginx Rails Origin header didn’t match request.base_url Gem Package Manager Gem – Package Manager for Ruby Upgrade ruby gem […]
Install Python 3.8 on CentOS 6 from source Install python 3.6 on CentOS 7 Install Python 2.7 on CentOS 6 pip Install jupyter notebook virtualenv Running Web Server with python SimpleHTTPServer Hosting Python Application in Production gunicorn Python Errors error: Python.h: No such file or directory pip install mysqlclient mysql_config: not found ERROR: Failed building […]
On a site running Magento 1.9, user login is not working on Google Chrome. The problem is due to cookie setting in Magento. Login to Magento Admin, go to Admin > System > configuration > web > Session and Cookie Management Put your domain name in “Cookie Domain” text box and click Save Config. Magento […]
Laravel Database Migration Error Key too long How to find Laravel Framework Version Create project using latest laravel
1 |
composer create-project --prefer-dist laravel/laravel blog |
Create project using specific version of laravel.
1 |
composer create-project laravel/laravel=5.1.33 --prefer-dist blog |
You can see available laravel versions on site https://packagist.org/packages/laravel/laravel […]
When doing a database migration on Laravel, i get following error
1 2 3 4 5 6 7 8 |
$ php artisan migrate [Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`)) [PDOException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes $ |
This is because MariaDB use different UTF8 format. To fix, edit file
1 |
vi ./app/Providers/AppServiceProvider.php |
Inside, find
1 2 3 4 |
public function boot() { // } |
Replace with
1 2 3 4 |
public function boot() { Schema::defaultStringLength(191); } |
You will also need to add
1 |
use Illuminate\Support\Facades\Schema; |
here is how my file look like after editing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
$ cat ./app/Providers/AppServiceProvider.php <?php namespace App\Providers; use Illuminate\Support\Facades\Schema; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot() { Schema::defaultStringLength(191); } /** * Register any application services. * * @return void */ public function register() { // } } $ |
Laravel […]
Node.js applications when you run with nodejs command, you need to restart when a change is made to source code of the application. nodemon will watch your application source code for changes, restart if a change is detected. To install nodemon, run
1 |
npm install -g nodemon |
Example
1 |
nodemon app.js 3000 |
nodejs […]
Auto Start pm2 on boot pm2 is a process manager for node.js applications. It is similar to forever. http://pm2.keymetrics.io First you need to install npm, on Ubuntu/Debian, run
1 |
apt install npm |
To install pm2, run
1 |
npm install pm2 -g |
Start an Application
1 |
pm2 start app.js |
Start an Application with name
1 |
pm2 start app.js -n "app-name-here" |
Start Application in Cluster mode with
1 |
pm2 start app.js -n "app-name-here" -i 5 |
To Scale a clustered […]
To check if PHP session is working, upload following script
1 2 3 4 5 6 7 8 9 10 11 |
<?php session_start(); if (isset($_SESSION["ServerOk"])) { $_SESSION["ServerOk"] += 1; } else { $_SESSION["ServerOk"] = 1; } echo $_SESSION["ServerOk"]; |
Access the file, refresh the page in browser, if you see number increase with every refresh, PHP session is working properly on server. […]
To create a ruby on rails project, run
1 |
rails new |
Nginx Rails Origin header didn’t match request.base_url […]