Quantcast
Channel: easytech blog » Drupal
Viewing all articles
Browse latest Browse all 11

Testing Drupal 8 in a RAM disk

$
0
0

Want to spin a Drupal 8 site on your machine but don’t want to configure DB users and virtual hosts? With just PHP installed with support for SQLite you can test Drupal 8 really easily. Another great thing about this hack is that if you are running a Linux / Mac OS X box your test site will fly.

CAVEAT: Keep in mind that this is simply to do some quick tests, maybe test a module or try something crazy with Drupal 8. All our database will be in RAM and any content you store there will disappear once you turn off / reboot your machine.

Although MySQL is the most popular database enigine used by Drupal sites you can run Drupal 8 with PostgreSQL and SQLite. For this test we’ll use the former. We don’t want to install and configure database users, etc. We also don’t want to install / configure Apache/Nginx virtual hosts, etc. So, go to http://drupal.org/project/drupal and download the latest beta of Drupal 8. At the time this post was written Beta 13 was the latest. In a terminal do:


$ mkdir test-d8
$ cd test-d8
$ wget http://ftp.drupal.org/files/projects/drupal-8.0.0-beta13.tar.gz
--2015-07-29 18:37:09-- http://ftp.drupal.org/files/projects/drupal-8.0.0-beta13.tar.gz
Resolving ftp.drupal.org... 23.235.46.68
Connecting to ftp.drupal.org|23.235.46.68|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10481509 (10.0M) [application/octet-stream]
Saving to: 'drupal-8.0.0-beta13.tar.gz'

drupal-8.0.0-beta13.tar.gz 100%[==========================================================================================================================================>] 10.00M 346KB/s in 21s

2015-07-29 18:37:31 (489 KB/s) – ‘drupal-8.0.0-beta13.tar.gz’ saved [10481509/10481509]

$ tar zxvf drupal-8.0.0-beta13.tar.gz
$ cd drupal-8.0.0-beta13

This will download and uncompress Drupal in a directory called drupal-8.0.0-beta13. Once you are there you can run PHP in server mode with the following command:


$ php -S 127.0.0.1:7777

This will use PHP’s native webserver and will listen on localhost port 7777. If you open your browser to that URL (http://127.0.0.1:7777) you should see Drupal 8 new install screen:

Drupal 8 install screen.

Now select your language, choose the default install profile and then you should see the database configuration screen. Here’s the neat thing: if you are using a recent / modern Linux distribution (I’m using Ubuntu) you should have a directory called /dev/shm. This directory is RAM disk which means all its content is stored in RAM. You can now use the SQLite engine which does not require any installation / configuration and store the database file in RAM. This will make your D8 installation fly. So, you can configure D8 database like this:

Drupal 8 database select screen

Choose SQLite database and set the database file to a path located on a RAM disk for super performance.

Before you know it you’ll have Drupal 8 installed! Now complete the last step with some quick info and you’ll have a D8 for you to play around without the hassle of installing either MySQL or a web server like Apache / Nginx.

On a Mac OS X you can create a RAM disk as described here and use that path for you SQLite file. You don’t need to make it so large: with maybe 50 – 100 MB you should be fine if all you want is to play a little with D8. For example, to create a 200 MB image and use that you do:


$ diskutil erasevolume HFS+ 'RAM Disk' `hdiutil attach -nomount ram://409600`
Started erase on disk3
Unmounting disk
Erasing
Initialized /dev/rdisk3 as a 200 MB case-insensitive HFS Plus volume
Mounting disk
Finished erase on disk3 RAM Disk

This code creates a directory called /Volumes/RAM Disk which you can use to store Drupal’s SQLite image (/Volumes/RAM Disk/.ht.sqlite in the Database file field of the install options).


Viewing all articles
Browse latest Browse all 11

Latest Images

Trending Articles





Latest Images