Introduction:
Ghost is a blogging platform which run on nodejs. I have tested this in a Ubuntu-12.04 64bit- 128mb/128mb openvz vps. Ghost requires Node.js 0.10.x (latest stable). Recommended Node.js 0.10.30 & npm 1.4.21.
Objective:
We will install nodejs, npm, lighttpd, mariadb for ghost blog. Lighttpd is for reverse proxy for ghost blog and it is really light enough to run smoothly on small vps boxes. Mariadb for saving posts as it is better than Mysql in some cases and also optimized for good performance. A benchmark of Mysql vs Mariadb. We will also install sendmail for ghost blog to act as a fully functional blog.
Installation Procedure:
1st Step: Nodejs – Npm
Let us install nodejs and npm as ghost blog build to run on this. We need repository to install latest versions.
First install curl and nano to download and edit files and also unzip to extract files.
1 |
apt-get install curl nano unzip |
Then let’s use curl to get repository. This command will add repository and will let us to download/install latest nodejs.
1 |
curl -sL https://deb.nodesource.com/setup | sudo bash - |
After running above command we can now install nodejs.
1 |
apt-get install nodejs |
Check the versions.
1 2 |
npm -v node -v |
2nd Step: Lighttpd and Mariadb
Install the repo manager to use “add-apt-repository” command.
1 |
sudo apt-get install python-software-properties |
Import the GnuPG signing key
1 |
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db |
Add repository.
1 |
sudo add-apt-repository 'deb http://ftp.osuosl.org/pub/mariadb/repo/10.0/ubuntu precise main' |
Update Source and install:
1 2 3 |
apt-get update apt-get install mariadb-server apt-get install lighttpd |
Now create a database.( It will ask you for root database password.)
1 2 3 |
mysql -u root -p create database ghost; exit; |
3rd Step: Ghost
Let we will install ghost in a domain “domain.com”, so we will create folder.
1 |
mkdir -p /var/www/domain_com |
Now enter into that folder.
1 |
cd /var/www/domain_com |
Now we will download the zip file by which we will install ghost. (Latest) in this folder.
1 |
curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip |
Now let’s extract the zip file into a directory.
1 |
unzip -uo ghost.zip -d ghost |
Above unzip command will extract ghost blog to a folder “ghost”, enter ghost directory.
1 |
cd ghost |
Now have to run below code as we will run our blog in production mode. This command will get the dependencies.
1 |
npm install --production |
We have to configure config file by our choice. Let’s replicate the sample config file to config.js-
1 |
cp config.example.js config.js |
Now edit that config file by our need.
1 |
nano config.js |
Find // ### Production. This is the start of Production based configuration. Also find // Developers only need to edit below here and above this line end of Production based configuration. You can just delete all from that and paste below codes which is good enough with sendmail and database.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
// ### Production // When running Ghost in the wild, use the production environment // Configure your URL and mail settings here production: { url: 'http://my-ghost-blog.com', mail: { transport: 'SMTP', options: { service: 'Sendmail', } }, database: { client: 'mysql', connection: { host: '127.0.0.1', user: 'root', password: 'password', database: 'database', charset: 'utf8' } }, server: { // Host to be passed to node's `net.Server#listen()` host: '127.0.0.1', // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT` port: '2368' } }, |
Change that domain with yours and change database section like above with the latest created database and add the server/vps ip in 127.0.0.1 and save it. In database connection do not use localhost, use 127.0.0.1 instead.
Now let’s test the ghost and nodejs server.
1 |
npm start --production |
the oputput should be something like this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
…………………….. > node index Migrations: Database initialisation required for version 003 Migrations: Creating tables... Migrations: Creating table: posts Migrations: Creating table: users Migrations: Creating table: roles Migrations: Creating table: roles_users Migrations: Creating table: permissions Migrations: Creating table: permissions_users Migrations: Creating table: permissions_roles Migrations: Creating table: permissions_apps Migrations: Creating table: settings Migrations: Creating table: tags Migrations: Creating table: posts_tags Migrations: Creating table: apps Migrations: Creating table: app_settings Migrations: Creating table: app_fields Migrations: Creating table: clients Migrations: Creating table: accesstokens Migrations: Creating table: refreshtokens Migrations: Populating fixtures Migrations: Populating permissions Migrations: Creating owner Migrations: Populating default settings Migrations: Complete Ghost is running... Your blog is now available on http://domain.com |
So it is running but we will not be able to browse by that domain yet. We have to use http://domain.com:2368 as ghost or nodejs run by ports and we installed ghost in 2368 port.
4th Step: Start Script
Create a blank file as ghost.conf in /etc/init/ folder.
1 |
touch /etc/init/ghost.conf |
Edit that file by nano and put below code.
1 |
nano /etc/init/ghost.conf |
1 2 3 4 5 6 7 |
# ghost start on startup script cd /var/www/domain_com/ghost npm start --production end script |
Change the location And save that file. Now you can start and stop the service by simply running below command.
1 |
service ghost start |
1 |
service ghost status |
1 |
service ghost restart |
1 |
service ghost stop |
This will also act as an auto start configuration file when reboot the server.
5th Step: Lighttpd and Virtualhost
Edit /etc/lighttpd/lighttpd.conf and pur below codes in the bottom of that config file. But remember to change the ip and domain name and directory name.
1 2 3 4 5 6 7 8 |
$HTTP["host"] =~ "(^|\.)domain.com$" { server.document-root = "/var/www/domain_com/" cache.enable = "enable" proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => 2368 ) ) ) } |
Save the file and run below command-
1 |
lighttpd-enable-mod proxy |
Then restart lighttpd server. Above command for enabling proxy feature of lighttpd server.
1 |
service lighttpd restart |
Now you can access your blog by the domain name only.
Final Step:
Make sure you restarted the service accurately.
1 2 |
service ghost restart service lighttpd restart |
Now you will be able to register and use your very fast blogging platform. 🙂
Conclusion: We have installed successfully our beloved ghost blog with sendmail function and mariadb+lighttpd. This box is 128mb openvz and it’s running smoothly.
I have also tested the server by Apache Benchmark. It just doesn’t bother. 🙂
You can tweak mysql/mariadb and lighttpd to give it a fast reaction capability. A good optimised lighttpd+mysql will give you a breeze with ghost blog and your small vps. You can find some interesting post in this site about how to tweak mysql for better traffic handling.
Happy Blogging !
hello, my VPS LES 128 SG.
when i start npm:
it’s always: KILLED
how i can fix it?
You are probably running out of memory.
I see you also posted on the LES Forum ( http://forum.lowendspirit.com/viewtopic.php?id=1978 ) and that you did get help there…. nice!
I’ve received to say that I was very impressed with the mmusicality aand complexity of those accompaniment chord patterns
aand the facht you could also control different facets of the intelligent chords by
taking out or muting the actual devices, bass line, orr drum rhythms, or a mixture of two or
more of these features while you’re playing the chord.
Can I simply say what a relief to uncover somebody who truly understands
what they’re discussing on the web. You certainly
know how to bring an issue to light and make it important.
More people ought to check this out and understand this side of your story.
I was surprised you are not more popular because you most certainly possess the gift.
Excellent goods from you, man. I’ve be mindful your stuff prior to
and you are simply too wonderful. I actually like what you have bought here, really like
what you’re stating and the way in which through which you
are saying it. You make it enjoyable and you continue to take care of to stay it wise.
I can not wait to read far more from you. This is really a wonderful site.
I am no longer positive the place you’re getting your information,
but good topic. I must spend some time learning much more or understanding more.
Thanks for wonderful information I was searching for this information for my mission.
I likewise chechk in (as well as went down bucks) at St Marks Seems, Used Rose, aand also Academy on 18th.
Howdy I am so thrilled I found your blog page, I really found you by accident, while I was searching on Aol for something else, Anyways I am here now and would just like to say kudos for a marvelous post and a all round entertaining blog (I also love the theme/design), I don’t have time to look over it all at the
minute but I have saved it and also added in your RSS feeds,
so when I have time I will be back to read a lot more,
Please do keep up the superb job.
You should be a part of a contest for one of the most useful sites on the web.
I most certainly will highly recommend this site!
Woah! I’m really loving the template/theme of this blog.
It’s simple, yet effective. A lot of times it’s challenging to get that “perfect balance” between superb usability and visual
appearance. I must say you have done a great job with this.
Also, the blog loads super quick for me on Firefox.
Superb Blog!
I like reading a post that can make men and women think.
Also, thank you for allowing for me to comment!
Genuinely no matter if someone doesn’t understand after that its up
to other visitors that they will help, so here it takes place.
Good post. I certainly love this website. Thanks!
Great article.
thank you for sharing this installation steps with details which proves to be really helpful.
Oh my goodness! Impressive article dude! Thank you, However I am
going through troubles with your RSS. I don’t understand the reason why
I cannot join it. Is there anybody having similar RSS issues?
Anyone who knows the answer will you kindly respond?
Thanks!!
Thanks For Sharing Bro. I like
thank you i really like it
thank you very muacchhhh http://104.219.250.236/
I do consider all of the ideas you’ve offered in your post.
They are really convincing and will certainly work.
Still, the posts are too short for starters. Could you please prolong them
a little from next time? Thank you for the post.
can u share tutorial how to install a wordpress site with VPS IP. thanks