how to

installing grav cms from terminal

Installing Grav CMS from the Terminal

installing grav cms from the console
Installing Grav CMS from the Terminal

Installing Grav CMS using the Command Line

Grav CMS is a great flat-file CMS written in PHP. It’s been around for a while and features plenty of themes and plugins. Though, the community around it tends to roll their own.

Written in twig, php, css, html and markdown. Grav finds itself one of the fastest CMS out there. It’s a real competitor to WordPress and Drupal, especially if you have a good web developer. Lets deploy one, so we can play with it.

How to get Grav and where to extract it.

Grab the latest zip from https://www.getgrav.org or https://github.com/getgrav/grav . Note: If you choose to use github and do not plan on doing and core development on the CMS, it’s a better idea to get a zip from the website or the Releases tab on GitHub.

Once you have the latest release, go ahead and sftp it up to your webserver and follow right behind by SSHing in. Extract the compressed release archive and move all of the files into webroot. Be careful not to forget hidden files, often “dot files”, like ‘.htaccess’.

installing grav from terminal
installing grav from command line

500 – Internal Server Error – How to fix Grav’s file permissions.

Now that that’s out of the way, all we need to do is fix the file permissions and we’re up and running. Once we check that, we should go ahead and install some useful bits.

find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
setup grav proper file permissions
fixing file permissions during a grav cms install

I’m going to grab the admin plugin, so I can manage Grav’s flat file CMS from the comfort of a web GUI. Please note, that if you decide to do the same, you’ll want to break out your web browser again. So you can register an admin on the world’s fastest flat file CMS before some random miscreant comes by and does it him or herself.

installing grav's admin panel
installing grav’s admin panel

Now you can pick a theme and start blogging with Grav!

successfully setup grav cms
Grav CMS’ administration panel

If you need any kind of back end server work, Gray Hat Freelancing is eager to help. Fill out this form for a free consultation!

freebsd desktop installer

Building a FreeBSD Desktop Quickly and Easily

Building a FreeBSD Desktop Quickly and Easily
freebsd desktop installer (starting with a vagrant)

Deploying a desktop on FreeBSD is not as hard as many people claim. In fact, if you “just want to be up and running” quickly, it’s entirely possible to do so. I often take this approach, before I start compiling things for my particular setup.

I’m going to show you how to do this properly, using VirtualBox and vagrant, just for the sake of this post.

How to Quickly Build a FreeBSD Desktop

As usual, once we boot into FreeBSD, we’ll want to check for any updates. It’s best to make sure we have the latest and greatest version of our release. As well as the most up-to-date version of any and all packages, as possible. Then go ahead and reboot, if necessary

Update FreeBSD and Your Package Repository

freebsd-update fetch
freebsd-update install
reboot
pkg update
pkg upgrade

Great, now we can get to building our FreeBSD desktop, for the sake of productivity we’ll start with the binary pkg version. You’re going to slap me, if you spend more than 20 minutes building your first FreeBSD desktop from scratch. But, this is all you had to do.

freebsd desktop installer pkg install desktop-installer
install the freebsd desktop-installer using pkg binaries
pkg install desktop-installer
desktop-installer
install desktop for freebsd lxqt
freebsd desktop lxqt setup

Select Your Favorite Window Manager

No joke. That’s all there is too it. I selected (8) for LXQT. But, you may select which ever you like. In general, Gnome or KDE tend to be larger, clunkier desktops full of bells and whistles, full featured, etc.. while the other’s tend to be more of a hodge podge.

But, you’ll probably find, as I have, that the flexibility offered by XFCE, Openbox, MATE, LXQT, etc.. is worth the hassle of rolling your own desktop. Of course, for the keyboard-only crowd, there’s i3/i3-gaps, bspwm, awesome and many more to choose from.

Happy hacking!

lxqt installed on freebsd as a desktop
LXQT FreeBSD Desktop
upgrade freebsd 11 to freebsd 12

The Fastest Way to Upgrade FreeBSD 11 to FreeBSD 12

How to Quickly Upgrade FreeBSD 11 to FreeBSD 12

Ever need to upgrade FreeBSD to the next release? It’s not hard! We can compile kernels some other day. Today, we’re just going to do binaries. Quick and easy, FreeBSD is the best.

Go ahead and log in to your machine, elevate yourself up to root (or use sudo). Lets get this show on the road: freebsd-update fetch

freebsd-update fetch & freebsd-update install

freebsd-update fetch && freebsd-update install
upgrade freebsd 11 to freebsd 12
upgrade freebsd

This process is not hands off. So, you’ll need to accept a few prompts. Generally, this is the only time you’ll really have to reboot FreeBSD, if you’ve been treating it well. But, in this case, I don’t run into the need for that (heh).

Once the update tool finishes grabbing all of the patches and applying them. We’ll need to update the pkg tool. The pkg tools is used to maintain binary packages on the system. If you’re a sane person, you either use pkg or the ports tree. The sanest people build binary packages from ports and keep a local repository, but that’s for another article.

upgrading freebsd 11 to 12 from the terminal
upgrade FreeBSD 11 to 12

Upgrading Binary Packages on FreeBSD

This tool keeps things as simple as they can be. So, if you’re familiar with POSIX compliant systems, you’ll recognize this process. Let’s continue to upgrade FreeBSD 11 to FreeBSD 12.

Use the static pkg binary to update the tool and then all of the installed packages. Again, I’m just going to go ahead and bang it one in one line. Any time you see me use &&, you can safely break the command into two commands, if you want. It is two commands anyway, just on one line.

pkg-static upgrade pkg && pkg upgrade
upgrading freebsd packages with pkg-static
using pkg-static to upgrade pkg tool
freebsd's pkg-static has upgraded the pkg tool
pkg-static upgrade pkg success
using pkg upgrade to upgrade freebsd 11's binary packages
use pkg upgrade to upgrade freebsd’s binary packages

Yeah, that’s a lot of packages. Let’s make sure we’re on the latest FreeBSD 11 release, which should be FreeBSD 11.3

uname -a
checking freebsd 11's minor version with uname -a
uname -a freebsd 11.3

Completing the Upgrade FreeBSD Process

Good. Now we can get back to upgrading the kernel to the next major release. Time’s running out for security updates for 11.3 and we don’t want to still be around, once it does. Back to the freebsd-update tool

freebsd-update upgrade -r 12.0-RELEASE
upgrading freebsd 11 to 12 - almost there
freebsd-update upgrade -r 12.0-RELEASE
ugprading freebsd 11 to freebsd 12 requires A LOT of patches
freebsd-upgrade -r 12.0-RELEASE

This one will take a while. It should inspect your system and ask you if you agree with what it has found, then it should go grab a matching FreeBSD 12 image to apply on top. Now we will need to reboot. But, take a walk, if you want, make a sandwich or whatever.

We’re almost done. We need to check some things and that’s about it after this. You can e-mail me if you want me to do any of these things for you. Please do not forget that. It’s how I put food on the table.

Next Time Don’t Wait So Long to Upgrade FreeBSD!

The Fastest Way to Upgrade FreeBSD 11 to FreeBSD 12
freebsd-update finally breaks free
The Fastest Way to Upgrade FreeBSD 11 to FreeBSD 12
freebsd-update install (going to freebsd 12)

You guessed it! We’re going to go ahead and apply all of those, oh so many, packages. Run freebsd-update install

freebsd-update install

It goes fast than you’d think. And, since we’ve finished patching away from FreeBSD 12. We now need to reboot and finish the final details of this FreeBSD version upgrade.

reboot
freebsd-update install

Congratulations! See how easy that was? I really love FreeBSD!

Apparently it wants us to run freebsd-update install three times, this time. If you compiled packages from ports. You’ll absolutely need to do this. And, if you didn’t, you’ll want to do this anyway because it removes a bunch of file lint that you’d otherwise have to do yourself.

Either way, welcome to FreeBSD 12.0-RELEASE!

freebsd-update install
uname -a
upgraded to freebsd 12.0-RELEASE
FreeBSD 12.0-RELEASE

The hackers at Gray Hat Freelancing are here to help you with any project you have that’s IT related. Tell me what you want to do and I’ll tell you how I can help you achieve that end. Have a good one!

terminal only wordpress deploy

A Perfect WordPress Deployment using the Terminal

How to Manually Perform a WordPress Deployment

I’m going to walk you through a WordPress deployment, using only the terminal. This is mostly because I need to put some content up here. And, once upon a time, this used to be one of my staple articles. Nothing has changed, really. But, I will reiterate the fact that you really should know how to do things manually, because you start plowing ahead and automating them.

Automation is good, it’s absolutely necessary, even. But, when things break, it’s best that you’re able to figure it out how it happened. And, the easiest way to obtain that information is, sadly, the hard way.

WordPress being so evolved.. Please do not expect a WordPress deploy to be something you can’t handle. Deploying WordPress is very straightforward. So, let’s get started.

virtual guest linux debian in a vagrant
Linux Debian 9 as a vagrant guest

LAMP: Linux, Apache, MySQL and PHP

WordPress runs very well on almost any web server. But, for the purposes of sticking to the documentation, we’re going to use Apache (not that I always stick to the documentation, mind you). You should familiarize yourself with a “LAMP” deployment anyway, it’s pretty much what powers the entire internet. Please note that MySQL is often replaced with either MariaDB or Percona Server. I won’t go into the differences here.

Go ahead and SSH into your web server, update your software repository and do a full system upgrade. There’s no reason to deploy LAMP without the latest patches. I’m using debian, so your commands may be slightly different for these types of things. Refer to your distributions handbook, if you need to.

sudo apt update
sudo apt dist-upgrade
sudo apt install apache2 mariadb-server php-fpm

Enable the Necessary Apache Modules

Hah! Before, that required us grabbing a whole lot more packages than it does these days. But, don’t worry! We will still need to go get various PHP libraries for our WordPress deploy to be successful (specifically, for it to interact with mariadb). Still, you don’t need to do anything else there on Debian, unless Apache was previously configured with libapache2-mod-php. Then go ahead and issue the following (unexplained):

sudo a2dismod php
sudo a2dismod mpm_prefork
sudo a2enconf php7.3-fpm (at time of writing, 7.3 was stable)
sudo a2enmod mpm_event fcgid cgi proxy_fcgi setenvif rewrite
using terminal to swap apache modules for a manual wordpress deploy
Configure Apache

There’s plenty of other Apache modules that are beneficial for WordPress, but we’re just doing a deploy right now.

Prepare MariaDB for Production

I’m pretty sure that we all knew MySQL shipped with insecure defaults for many years. So, I have no idea, why this tradition has carried through to MariaDB. But, it’s my opinion, that we should damn not be having to still do this bit here. But, set a root password for the SQL db. And, disable remote access. Run ‘mysql_secure_installation’, press Y to everything and set a password.

Install the Minimum PHP Requirements

As I just said about Apache, there’s also plenty of PHP libraries that will benefit WordPress, but they’re beyond the scope of this walk through. So, we’re only going to grab what WordPress requires to install without complaint, as well as what is required to return a green health check.

sudo apt install php-mysql php-gd php-bz2 php-curl php-zip php-xml php-gmp php-intl php-mbstring php-xmlrpc php-token-stream php-mcrypt
manual wordpress deploy, installing required php modules
install php modules

I, honestly, don’t know what to tell you about PHP modules. Depending on your linux distribution, your PHP package is going to come with different modules. There’s really no telling what was bundled with it and what wasn’t. If you’re on Debian, this will get WordPress up and running, at least. But, on others, the packages will be named differently anyway. So, try to reach this minimum.

WordPress Deployed from Terminal

On Debian, Apache’s default “webroot” is in /var/www/html . Your “webroot” may be in a different location. If you don’t know, check your Apache configuration. It should be located in /etc/apache2 or /etc/httpd – The filename would either be apache2.conf or httpd.conf

Anyway, back to manually WordPress deploying from the terminal. I’ll have to clean this up later. But, for now, I’ll just finish what I started. Jump on over to webroot, grab the latest version from wordpress.org and extract it. All that’s left after that is to create a user for “MySQL”, set permissions and run the installer.

cd /var/www/html
wget https://wordpress.org/latest.zip
unzip latest.zip
quite literally deploying wordpress into a folder, out of compressed zip file
extract wordpress

Note: this next part you can ignore. What I am doing is deleting my webroot and moving the folder wordpress extracted to in place of my webroot. If you extracted wordpress into ./html/ then you don’t need to do this.

rm -rf ./html/
mv ./wordpress/ ./html/

Create a MySQL Database, a MySQL User, Marry Them

Now we need to create a MySQL database. Create a MySQL user and grant it privileges to write to the database. Then, fix the file permissions and we’re done with the terminal (the website is technically up, a that point.

mysql -u root -p (perhaps prefix with sudo, if you're not root)
mysql> create database wordpress;
mysql> grant all privileges on wordpress.* to 'wordpress'@localhost identified by '[email protected]';
mysql> flush privileges;
mysql> quit
grant all privileges on WordPress Deploy to Deploy@WordPress identified by 'ASSWORD'
Identified by assword?!

Let’s set some privileges, first give the user that runs Apache ownership of the files. Then set the directories to read/write, read/write by Apache’s user and group. Finally, give the files read/write to Apache’s user and read/execute to everyone else (since php-fpm needs to read and run them).

Fix File Permissions and Be Done!

chown -R www-data:www-data /var/www/html
find /var/www/html -type d -exec chmod 755 {} ;
find /var/www/html -type f -exec chmod 644 {} ;

At this point, we really need to bust out our browser and complete the install, so we can prevent about a billion zombies from hammering away at our install script and owning the box (just log password attempts on WordPress for a week and you’ll see what I mean). So get your browser out and finish this bitch off! You’re done.

Good luck. Have fun! And, next map. If you’d like this handled for you, drop me a line at Gray Hat Freelancing!

wordpress initial configuration - final step of wordpress deployment
Porky Pig

FIN – Our Job Here is Done

There’s plenty more to do. Especially from a security standpoint. I can tell you right now, our file permissions are decent but not perfect. There’s optimizations that need to be made or your blog could become a zombie in a DDoS, etc.. But, those are for another article. For now, enjoy the WordPress deploy!

wordpress has been deployed - hello world
Hello World!
deploying wordpress - do the speak english in wordpress deployment?
Self-explanatory
wordpress database configuration - almost done with wordpress deployment
@ssword