Knowledgebase: MySQL
Install or Update Ghost
Posted by H9 Admin on 24 October 2014 03:21 PM

Install Ghost with Softaculous

If you want to install a fresh instance of Ghost on your cPanel account you can do so very easily with Softaculous. Softaculous is an auto-installer for cPanel that can auto-install over 266 useful scripts. It's a pretty awesome tool.

Note: if Softaculous isn't currently available in your cPanel account (Shared hosting customers get it by default) you can request to have it installed by our friendly and helpful support staff! 

To get started:

  1. Log in to cPanel for the domain

  2. Navigate to the Software section and click Softaculous App Installer

  3. In the search field in the top left-hand corner of the navigation menu search 'ghost' and press the Enter key when it populates

  4. ​Click the Install tab

  5. On the Install screen in the Software Setup section do the following:

    • Protocol can be left unchanged unless you have a SSL certificate installed on the domain or prefer the 'www' prefix to exist for the site address

    • Choose your target domain from the Choose Domain dropdown menu

    • If you would like to have the software installed in the root of your domain, leave 'In Directory' empty, otherwise input directory name relative to the domain's folder

  6. In the Blog Settings section add your blog name and its description in the applicable blanks, and add the email you want to be used as the Administrator email for the account in the applicable blank as well

  7. In the User Settings section add your full name and email address as well as a password for the new Ghost account

  8. Tick the box in the Notes section to confirm you've read the Ghost notes available (and check out the URLs the section provides)

  9. Database Settings can be left with defaults unless you'd like a different database table prefix or sample data imported​

  10. Click the Advanced Options plus sign to drop down the options; configure the Advanced Options as per your preference

  11. Next to the 'Email installation details:' text, and in the blank text box, add your email address

  12. ​Click the Install button

Install Ghost Manually

Note: the tactic detailed below ONLY works for shared plans. If you have a VPS/Cloud or Dedicated server, no fear... just get in touch with us. We'll prep your server for the Ghost change.

Prepare Your Account For Ghost

Note: you can now use Ghost in a subfolder, but you cannot use the folder "ghost" or you'll break it!

  1. Log in to your cPanel account and create a database

  2. You will need to know the name of  the database, the database user, and the password for the database user when installing Ghost

    For the purposes of this document, we'll use 'user_dbname', 'user_dbuser' and 'dbpassword' as examples.

Note: you will need shell access, which is typically enabled by default, to complete a Ghost installation.

Install Ghost

  1. Create a folder in which you can install Ghost

    Note: Since SSH is required in later steps we'll walk through the process using SSH. The folder should not be within your public_html folder and should exist in a non-web accessible area of your web hosting space.

  2. cd /home/user

  3. mkdir ghost

  4. Via the download link at http://ghost.org ;obtain the current source version of Ghost

  5. Place the Ghost source code in the newly created folder

  6. cd ghost

  7. wget --no-check-certificate https://ghost.org/zip/ghost-0.4.2.zip

  8. unzip ghost-0.4.2.zip     

  9. rm -f ghost-0.4.2.zip

Upgrade Ghost

  1. If you're installing Ghost for the first time, please skip this section and proceed to Installing Ghost

  2. ​For our instructional purposes, we'll assume our Ghost install is located at /home/user/ghost
    It is strongly recommended that you have proper backups before upgrading any software or scripts, Ghost included.

  3. cd /home/user/ghost

  4. ​​​​rm -fr core node_modules app.js

  5. wget --no-check-certificate https://ghost.org/zip/ghost-0.4.2.zip

  6. unzip -o ghost-0.4.2.zip​

  7. npm install --production

  8. ln -s index.js app.js

  9. mkdir -p tmp

  10. touch tmp/restart.txt

Configure Ghost for Your Website and Database

Ghost provides an example configuration file that we'll use as a template. Where you just installed the Ghost source make a copy of the example configuration file to one Ghost will use.

  1. cp config.example.js config.js

  2. Open config.js and navigate to the Production section so that you can make a handful of changes:

    • url: - set this to the full URL for the finished ghost (like url: 'http://blog.domain.tld'

    • mail: - if you want to configure it refer to the config.example.js file for details (around lines 13-26), otherwise leave this blank

    • database: - set your database details per the following as examples

      database: { client: 'mysql', connection: {host: '127.0.0.1', user: 'user_dbuser', password: 'dbpassword', database: 'user_dbname', charset: 'utf8' }, ​

    • debug: - we recommend that this stays set to 'false'

Note: the server: section should be kept, but does not need to be adjusted.

Install Ghost's Dependencies

  1. npm install mysql

  2. npm install --production

    Note: you will see an error regarding sqlite3 in step 1.2; failing to compile. This is normal and should be ignored. Sqlite3 is available via the globally available node.js modules instead.

  3. Create the following symlink (to configure the node.js applications for the server): ln -s index.js app.js

  4. ​​Create a tmp directory for node.js applications so that Ghost can function properly: mkdir tmp

  5. To restart Ghost in the future: touch /home/user/ghost/tmp/restart.txt

  6. Go to the public_html directory for the domain that will be hosting Ghost (if the web hosting account has nothing else in it, this is probably public_html in the root of your account): cd /home/user/public_html

  7. Create a file named .htaccess (make sure to include the period at the beginning) and tell the web server to use Ghost by placing the following in the .htacces file:

    PassengerEnabled on PassengerAppRoot /home/user/ghost SetEnv NODE_ENV production ​SetEnv NODE_PATH /usr/lib/node_modules


Ghost should now be installed. Go ahead and create the administration user for Ghost by visiting http://blog.domain.tld/admin/ (if url: is set to http://blog.domain.tld), which will prompt you to create the admin user for Ghost.

You can stop here for a standard setup. If you're interested in multiple configurations or using SQLite, read on....

Multiple Configurations, SQLite and more

Ghost also supports SQLite for a database backend, along with multiple configurations. For instance, you could set up a developer config with an SQLite database for testing. In the config.js file from earlier we only had you adjust the production configuration.

To set up an alternate configuration:

Open config.js in your favorite editor and in the development: section set the database: portion to:

database: { client: 'sqlite3', connection: { filename: path.join(__dirname, '/content/data/mytesting.db') },

The filename about is relative to the installed directory, so in this case would be /home/user/ghost/content/data/mytesting.db

  1. In the .htaccess file from earlier adjust the NODE_ENV line to development, which you can do for any configuration in the config.js file, just make sure it matches the name from that file

    The new file will look like:

    PassengerEnabled on
    PassengerAppRoot /home/user/ghost
    SetEnv NODE_ENV development
    SetEnv NODE_PATH /usr/lib/node_modules

     

  2. If your blog is already running restart to apply the new configuration automatically: touch /home/user/ghost/tmp/restart.txt

  3. Visit your blog, which should now be using the alternate configuration

Note: all settings are stored in the database, so don't be surprised that it looks like a newly installed blog. Simply revert the change in the .htaccess file and restart Ghost again to bring it back.

Back Up Ghost

Ghost does provide rudimentary backup features, but please be aware that backups consist of text only. Binary items such as images are not included. For example purposes, we'll assume ghost is located at http://blog.domain.tld.

  1. Browse to http://blog.domain.tld/ghost/debug/

  2. Click the Export button

  3. Choose a safe location to save your backup

Ghost is Behaving Very Strangely

Images and links are broken, stylesheets are missing, etc.

Did you install Ghost to a sub-directory, with something like Wordpress installed above it? If so, the .htaccess file above the ghost install is most likely causing the problem. Open the .htaccess file you created for Ghost, and add this line at the top, then save the file:

RewriteEngine off

 

Updates to Ghost Theme Not Showing

Since Ghost runs as a persistent process for an amount of time, Ghost simply needs to be restarted for the changes to take effect. To do this, simply:

touch /home/user/ghost/tmp/restart.txt

 

Remember that the above path is only an example, you'd need to touch the tmp/restart.txt file under your actual ghost install.

(0 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
Help Desk Software by Kayako fusion