Keep your dev servers separate from your workstation

Setting up a development server on your local network separate from the machine you write and crunch code is a great way to keep the machine you rely on to operate as fast as possible.  I never try to install any virtual machine on the same machine I need to write code and design databases on, even a quad core with 8 GBs of RAM will slow down pretty quickly.

Virtualbox, Virtualmin and MySQL database server

So, after installing Virtualbox on another PC, usually the most recently replaced PC that used to be my main computer, I prefer instead of selling it to use it as another dev server on my network.  I prefer to install Virtualmin and use that to help speed up the process of deploying another dev server in minutes.  Obviously, the “M” in L.A.M.P. is short for MySQL, and without a local database to interact with, you are sure to get frustrated with the time lags involved in working with a remote database server.  This is a “dev” environment, after all, so you need every advantage to keep things running fast.  Dev is usually 80% of all the work you put into a new site and system.

Virtualmin allows you to install a new database server, Git repositories, and a myriad of other modules that will help you duplicate your existing host environment.  Of course, you can also open this server to the outside world if you have static IP as well.  Virtualmin allows easy deployment of new servers quickly and reliably.

Failure to connect to MySQL database

Once you set everything up in Virtualmin and can access your site, you will be tempted to go and establish a connection to the site’s database and start devving.  You will likely run into an error message saying your connection isn’t allowed.  This is what happens when I try to connect to the site’s MySQL server directly to its IP through MySQL Workbench:

Failure to connect through MySQL Workbench to local Virtualmin database

You did everything right, you set up your database and user privileges, so what gives?!  Well, Virtualmin can get a little confusing, so go back to your Virtualmin console then click “Edit Database” then go to the “Remote hosts” tab.  Here, you need to put in your IP address, if you’re not DHCP on your local network and that’s where you need to access your database from, it’s best to type in a wildcard of your network, which for me and my local network IPs are in the range from 192.168.1.1 – 192.168.1.255.  By entering the wildcard “192.168.1.%” this will allow any connection within the 192.168.1  IP range to access your database.

Virtualmin - open local IP to connect to your dev server databaseYou won’t have to restart MySQL, just go back to MySQL Workbench or whatever tool you’re using to access your database and see if it works now:

MySQL Workbench Virtualmin Database success screenshotSo, when you think you know where the proper settings are, in Virtualmin, this is something that often gets overlooked.


Apache .htaccess directives are pretty straight forward.  The “SetEnvIf” that passes different values if the conditions are met then are processed by the standard Deny/Allow directive.  Here’s a sample from Apache’s documentation:

#allow a single uri through .htaccess password protection
SetEnvIf Request_URI "/test_uri$" test_uri

 
#allows everything if its on a certain host
SetEnvIf HOST "^test.yoursite.com" test_subdomain_url

SetEnvIf HOST "^yoursite.com" live_url

Order Deny,Allow


AuthName "Restricted Area"
AuthType Basic
AuthUserFile /path/to/your/.htpasswd
AuthGroupFile /

Require valid-user

#Allow valid-user

Deny from all
Allow from env=test_uri
Allow from env=test_subdomain_url
Allow from env=live_url
Satisfy any

This is handy in case you want to control all password protected areas of your site all in one place.  I have even added an admin interface that can add new environments to the web root’s .htaccess file on the fly.  This is a simple way to improve your web security for different sections and works great!


Say what you want about GoDaddy, but I think in the past 2 years they have really stepped up with their hosting packages.  The new cPanel is very stable, clean, and super reliable.  Adding additional sites to your host package takes 5 minutes.  Installing the latest WordPress on a site?  Done with a click of a button.

One issue you probably will encounter is the small file size restriction on  your new GoDaddy WordPress site, which defaults to a paltry 2MBs.  For shared VPN hosting, all you have to do is create a new user.ini file and save it in your webroot folder.  Here are setttings to increase file uploads to 128MBs, which is probably more than enough for most sites.  Don’t forget to also increase your file maximum timeout setting, too however, or the PHP upload script may timeout before your bigger files get uploaded, a common problem with servers.  Many inexperienced server admins make the mistake of allowing larger file sizes but they don’t increase the script execution time!

Never heard of a user.ini file?  Here’s some more details about it on GoDaddy’s website.

upload_max_filesize = 128M
post_max_size = 128M
memory_limit = 128M
max_execution_time = 600

 

Here’s a sample of what I have in one of my website’s “user.ini” file.  By the way, “user.ini” is a special GoDaddy php.ini file they use on their hosting, it may be that if you are using a different hosting package that you need to put these settings in the php.ini file.  Also, I have seen you will need to put a php.ini file in your WordPress /wp-admin folder in other hosts for WordPress to see your new file upload settings.  You may also encounter that you did everything correctly but your host will override certain settings, if you find this is the case, you may have to upgrade or change hosts to accommodate the ability to upload larger file sizes.


I recently reviewed ReclaiMe’s free Data Recovery Tutorials and was really impressed at how much free information regarding procedures and steps a company can take to restore, or should I say reclaim their critical data that was lost on a failed hard drive.  Read the entire review here.

It happened to a me a few times where I’ve seen $50,000 worth of production and editing work on videos and 3D animations go up in dust.  Thankfully, each time I managed to find a way to recover the projects with minimal loss — except perhaps of time and the remaining hair on my head.

Please click here to read the latest review of ReclaiMe’s disk and data recovery tutorials.  I’d recommend visiting their website at www.ReclaiMe.com and know where to find the software in case you suddenly lose your hard drive!


From the command line in Linux, “stat” is a useful command.  Good luck committing it’s 30+ options to memory….  Here’s the help output for easy reference to study if you’re so inclined. I probably use %U and %G the most when I run into file permission issues and realized I cleared the Symfony cache accidentally under the “root” user because I was in the CLI running Composer updates or installing other server-level scripts.

[~/public_html/app]# stat --help

Usage: stat [OPTION]… FILE…

Display file or file system status.

-L, –dereference follow links
-Z, –context print the SELinux security context
-f, –file-system display file system status instead of file status
-c –format=FORMAT use the specified FORMAT instead of the default;
output a newline after each use of FORMAT
–printf=FORMAT like –format, but interpret backslash escapes,
and do not output a mandatory trailing newline.
If you want a newline, include \n in FORMAT.
-t, –terse print the information in terse form

–help display this help and exit

–version output version information and exit

The valid format sequences for files (without –file-system):

%a Access rights in octal
%A Access rights in human readable form
%b Number of blocks allocated (see %B)
%B The size in bytes of each block reported by %b
%C SELinux security context string
%d Device number in decimal
%D Device number in hex
%f Raw mode in hex
%F File type
%g Group ID of owner
%G Group name of owner
%h Number of hard links
%i Inode number
%n File name
%N Quoted file name with dereference if symbolic link
%o I/O block size
%s Total size, in bytes
%t Major device type in hex
%T Minor device type in hex
%u User ID of owner
%U User name of owner
%x Time of last access
%X Time of last access as seconds since Epoch
%y Time of last modification
%Y Time of last modification as seconds since Epoch
%z Time of last change
%Z Time of last change as seconds since Epoch

Valid format sequences for file systems:

%a Free blocks available to non-superuser
%b Total data blocks in file system
%c Total file nodes in file system
%d Free file nodes in file system
%f Free blocks in file system
%C SELinux security context string
%i File System ID in hex
%l Maximum length of filenames
%n File name
%s Block size (for faster transfers)
%S Fundamental block size (for block counts)
%t Type in hex
%T Type in human readable form