Business, suitecrm, Technology, Tutorial, Ubuntu

How to make SuiteCRM Localhost Test Environment

Somehow I got pretty far in life in age and suffering, managed to figure out how to install SuiteCRM on an ubuntu server and basically maintain it (even back it up) but one day I needed to test some custom code on a non-production machine. This is when I realized that I didn’t know (at all) how to make Apache2 connect to MySQL and basically work as a server on my local machine. I kind of thought you could just ‘connect them’ but it seems that what you really need to do is turn your local machine into a ‘server server’ including all the stuff you did to install it remotely.


I somehow assumed that the database name, the user of the database and the password for the database were somehow magically connected to the .sql file. I thought I could just import the .sql file into MYSQL, fire it up and then just use everything the way it was. I was wrong.


For this part I basically just followed my own blog and set up my local machine just like a server. Because that’s what I think we’re supposed to do here, go figure… so install PHP stuff, set up database stuff, etc. Start with PHP and read the third party blog found in my blog for sure.


I tested by typing sudo mysql and it got me in ok so I’m assuming now it’s working.

I then continued the third party blog (from my blog) and installed the php stuff

Note when i was testing the ‘phpinfo.php’ it wouldn’t seem to work when i put it into the url field of browser so i did another restart of apache2.service and also manually typed out the http:// in the field rather than without (I had assumed it was assumed by browser to be there…) and then it started working. not sure which of the two above did it but now it also seems to work without typing the http://…

The other thing is I’m not sure if it matters where I stick my suitecrm files on localhost…. for example, can I direct apache to my desktop to find all the files? I don’t know. So because i’m not sure I”m going to stick everything into exactly where it was on my server into: /var/www/html/ as a starting point. The good news is that this worked in the end…so I guess I can advise you to copy me?

To move the big dump of the suitecrm files (the motherlode) It seemed I needed some higher level of authority to move the files there with Nautilus file manager so I just used the terminal and did a sudo cp -R ~/Desktop/suitecrm /var/www/html

When it comes time to move the custom one-off suitecrm files from your local machine into your ‘localhost’ var directory you will need sudo privileges. I found it most easy to use sudo nautilus from the terminal (or whatever linux file manager you are using on your OS..) to just drag and drop the files with the GUI. Otherwise you can do it all via mv filename /var/www/html/suitecrm/path/to/whatever if you’d prefer…

After copying the suitecrm backup files to /var/www/html I did a quick test by going to my browser and trying localhost/suitecrm/ and got a ‘could not connect to the database.Please refer to suitecrmlog for details(0)”

I had copied my sql file accidentally and had ‘ (copy) ‘ in the filename which seems to mess up the process of importing the sql file. After I erased the brackets and spaces and had a suitecrm_backup_database.sql format it started to work.


I’m not 100% sure you have to do this on local host but I did it… let me know if it’s not needed in the comments, otherwise, I guess do it?

sudo chown -R www-data:www-date /var/www/html/suitecrm and
sudo chmod -R 755 /var/www/html/suitecrm



Biggest take-away point of learning from all this, as mentioned above, is the fact that it is needed, it seems, to recreate your database, users, and pws. So hopefully you have these saved safely from before…


You can follow my blog above if you haven’t already or this blog is great too for having a quick teaching on installing (and uninstalling if you hit a hiccup) mysql.

sudo apt install default-mysql-server

After doing the secure install process (sudo mysql_secure_installation) check to make sure mysql is up and running. If it’s NOT and you have a painful life, be sure to check out the bonus bottom section called ‘SNAGGED WITH A MYSQL UBUNTU BUG’….

sudo systemctl status mysql.service

Log into MYSQL as root:
sudo mysql -u root -p

You will be asked for a password. But what password is this? The answer is, it’s BLANK! Who would have thunk it? So when asked, just hit the enter key the first time and that should get you in. This tip may only be relevant if you didn’t do the recommended secure install above. Disregard this tip if you did a secure install

On your flashy new localhost and logged in as root to your mysql:

  1. Create database with same name as the one you backed up: CREATE DATABASE suitecrm;
  2. Tell mysql to use this new empty db you just created: use suitecrm;
  3. Into this re-created database, we will import the backup sql file with this source /path/to/your/suitecrm.sql; (of course adjust to where your file is…) and press ‘fire’ and see what happens. If it starts working you should see a stream of ‘Query OK 0 rows affected..’ messages as it works

There is another way to do this if you are interested, for you keeners out there: This blog is pretty solid I’m going to cd to my .sql backup file and then execute this command: mysql -u {user} -p {database} < {file}.sql


How do you get the hard path to your .sql file if it’s somewhere on your local machine? And how do you easily get that path into the command above in Step 3? Easily, thankfully! Just right click on your sql file and click ‘copy’ and, lo and behold, when you paste into your terminal it will paste the PATH (who would have known??). You will get the file:// stuff at the front so just delete everything except the first forward slash. To be more clear, when you copy and paste it will look like this:


but make it look like this:



This section may be skipped if you don’t encounter it (likely you will not) but for a quick education maybe scan it so that you know there is a solution if you ever hit this situation.

After going throught the process of getting the suitecrm files where they should be and even importing (I thought) the database, nothing was working. I did a check to be sure with this (and you should too after installing Mysql: sudo systemctl status mysql.service

I tried everything I could think of – permissions, uninstalling-reinstalling mysql, etc etc. Nothing worked.

As fate would have it i had some weird bug going on in my MYSQL setup preventing it from running – period. It turns out that some files and directories refused to purge from the /etc/mysql folder so thankfully I found [this blog](

In my case (yours might be slightly different) I had a weird red CAPS LOCK “FROZEN” thing going on and an old mariadb.conf.d directory so I did this to the frozen thing:

sudo rm -R FROZEN and wiped that

Then I did a rename of the mariadb thing since i didn’t know what it was:

sudo mv mariadb.conf.d mariadb.conf.d_bax

Then i restarted the install from this after I knew everything was purged completely and that nothing that was left in there would conflict with anything installing.

sudo apt install default-mysql-server

After doing the secure install process (sudo mysql_secure_installation):

sudo systemctl status mysql.service

Revealed that mysql is now up and running.

TIP! If your mysql doesn’t run for whatever reason, make sure that the /etc/mysql folder is purged and without potentially conflicting files and directories.

Tagged , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *