This tutorial will show you how to migrate your ninja invoice very easily from one hosting server to another with the assumptuion that you’ll be keeping the SAME url structure. This tutorial is still helpful even if you change URL’s.
In this example i’m going to migrate Invoice Ninja V4 from SiteGround to Cloudways. Please note, V4 does not work with PHP 7.4. You must use PHP 7.3. Invoice ninja V5 will be stable enough for PHP 7.4 when they officially release it.
At your current server
- Export your database using phphMyAdmin
- Download your entire invoice ninja directory files
On your new server
This tutorial utilizes Cloudways custom database as shown in the above video.
- (at Cloudways) Create a new custom php application. This will automatically create a new database for your invoice ninja.
- Launch Cloudways database manager (under access details)
- Import your database here. Keep note of the new database name, username and password. (How To Import a Database using phpMyAdmin)
- You are DONE with the database portion.
- NOW, Go to your website application (via FTP)
- Upload the unzipped ninja invoice file to the same path where it was located on your other server. For example: www.your-website.com/invoice-ninja
What’s makes Cloudways hosting awesome is that EACH of your applications on your server will be isolated from one another. This is a beautiful feature that you wont’ find at many hosting companies. An isolated application makes for a more secure application, more secure server and retains performance. If one website/application get’s hacked, it protects the other applications from getting hacked as well.
Yes, the limitation of one database per application and each application having its own public_html while on the same server is due to security purpose and we have made sure that every app on the server is isolated from each other and in case of one app gets compromised due to any faulty plugin or theme or code, it will not affect the other applications on the server. – Cloudways Support
So at SiteGround, being on a shared server, required that I use the same mysql database to load all my databases. All of my applications were also under public_html within their respective sub folders.
With Cloudways, I had to do this a little differently. My website and invoice ninja are in two different application installs.
- Grab your new database details (user/pass/db name) from the custom application you installed earlier at cloudways.
- Use an FTP client. I like to use Nova FTP for my work. If you’re familiar with Coda, Nova is the new and improved version for Macs. I’m very happy with it.
- Connect to your Cloudways Server via FTP. The name of your database is also the name of your application folder in FTP.
- Locate the file path where you installed your invoice ninja files. In my case, it was with my WordPress install.
- Open up the .env file. Open the .env.example file (located in root)
- in the example env, you’ll notice the following fields listed below. This is the bare minimum you should have to change to get the system working properly in it’s new location.
- What I did was disable the old .env file by renaming it .env.OFF. I then renamed .env.example to .env to make this the active .env file.
- Copy the APP keys from the old env to the new one.
- Replace the DB info , with the new database info you created at cloudways (found in the application’s access details)
- Once you have confirmed the system is now working on the new server, you can continue to modify other important fields if you are using them (mail, cloudflare, payments, cron jobs, etc)
Minimum Fields To Change To Get System Working on New Server (.env file)
APP_URL= PUT IN URL (grab from original .env file)
APP_KEY= PUT IN KEY (grab from original .env file)
DB_DATABASE=PUT IN DB NAME
DB_USERNAME=PUT IN DB USER
DB_PASSWORD=PUT IN DB PASS
Not on Cloudways yet? Check them out here.
The following are other resources that might help you in migrating your invoice ninja to a new server or deal with changing a new URL. There is also some instructions on how to upgrade to Invoice Ninja V5 if you would like to get a jump start.