Friday, March 19, 2021

How to solve proxy_fcgi:error AH01071: Got error 'Unable to open primary script


Recently I got stuck with strange bug on centOS server. After I updated document root for my primary domain which has Laravel App installed. 

When we try to access app through domain, we got following error. 

No input file specified.

I initially thought it's the permission issue on .htaccess issue. Tried changing permissions and adding some rewrite rules but it didn't work. When I checked apache error logs. I got following error. 

proxy_fcgi:error AH01071: Got error 'Unable to open primary script

I had no idea how to solve this error. So tried few things like

  • Restart apache
  • Restart php-fpm
  • Restart VPS
  • Removed and added account few times.
  • Disabling php-fpm
But nothing worked. I spent almost entire night in solving this issue but no luck. But finally I was able to solve the issue by following steps. It was actually the issue with php fpm, as it was not able to find out root folder for the domain. So here is what you have to do. 

First go to userdata directory 


Here you will find one file.

Open this file with nano or vim editor and add following line at the end of it. 

php_admin_value_doc_root: { name: 'php_admin_value[doc_root]', value: /home/<USERNAME>/public_html/<DOCUMENT_ROOT> }

Save the file and then execute following commands one by one.

/scripts/php_fpm_config --rebuild 



This will rebuild php fpm config and restart php fpm service for apache. Now in the same folder open 


Change document root here as well and run following commands.



This will rebuild apache config file and restart apache. 

This is it and now if you visit your domain, you will not have the issue of file missing. 

Hope this saves your time

Wednesday, December 9, 2020

Restore MySql Database From Just frm and idb File


Few days back, I encountered a situation where we needed to restore MySql Database but we only had frm and idb file. Didn't have .sql file or log file from MySql server which is very much needed when you want to restore. So here in this blog I am going to explain how you can still restore MySql Database from only frm and idb file.

First you will need a tool called dbsake which you can install with following command.

curl -s > dbsake

Once installed, run following command to check if it's installed properly or not. 

chmod u+x dbsake

./dbsake --version

If it shows version and all, it's installed. Now first by using this tool we will get schema of table from frm file. Run following command. 

./dbsake frmdump /PATH_TO_FRM/file.frm

It will give you create table schema like this.

CREATE TABLE `table_name` (

  `column1` int(11) NOT NULL AUTO_INCREMENT,

  `column2` varchar(255) DEFAULT NULL,

  `column3` varchar(255) DEFAULT NULL,

  PRIMARY KEY (`column1`)


Copy it and run it in your sql editor. If you are migrating it from MySql 5 to 6 you may want to add ROW_FORMAT

CREATE TABLE `table_name` (

  `column1` int(11) NOT NULL AUTO_INCREMENT,

  `column2` varchar(255) DEFAULT NULL,

  `column3` varchar(255) DEFAULT NULL,

  PRIMARY KEY (`column1`)


Now it will create table. It's time to load data into it. 

First we will delete the table space which is idb file created. Run following command.


Now copy the old idb file and replace the existing one in your MySql server.

Now attach table space again.


That's it and now if you browse the data in table, you can see all your old rows. 

Tuesday, September 29, 2020

MySql Export / Import Large Database


In this blog I am going to explain a trick which I recently used for Export / Import large database. 

Let me first explain the issue I faced. The database was over 250 MB. I was using MySql WorkBench to export in single self contained file. But it was breaking in between as some tables were really huge. 

So here is what I did. First in MySql WorkBench, in stead of exporting it to self contained single file, export it to Dump project folder. Here it will create sql file for each table in the folder. So in my case it created approximately 180 sql files. 

Now open terminal and go to that folder. First step here is we will concat all those files and make a single file.

Run the following command in terminal from folder where you have all the sql files.

cat *.sql  > .single_file.sql

Above command will concat all the files into one file and create that file in same folder. Now we will use this file to import into our database.

/Applications/MAMP/Library/bin/mysql -u DB_USER -p DB < .single_file.sql

That's it. With this trick you can Import / Export large database. Please note that, for this you should have terminal access to your MySql server.