Now we are ready to enter the Ghost world!
Do some prep work.
Creating a Database
We want Ghost to run with MySQL database, so we need to create a MySQL database for Ghost. MySQL is already installed in front, so let's create a database:
Mysql-uroot-p-E ' Create database ghost; '
You will be prompted to enter the root account password for the MySQL database (remember the password you set when you installed MySQL in the previous section?) )。 After the instruction is executed, a database called Ghost is created, and in the future your article is here!
Configure Nginx
We would like to use Nginx to do Ghost front-end agent services. OK, we enter the/etc/nginx/sites-available/directory setting Nginx:
The code is as follows |
Copy Code |
cd/etc/nginx/sites-available/ sudo touch ghost.conf sudo vi ghost.conf
|
The last instruction is to open the ghost.conf file for editing with the Vim editor. We enter the following:
code is as follows |
copy code |
Server { Listen server_name ghostchina.com;//Replace with your own domain name! location/{ proxy_set_header X-real-ip $remote _addr; proxy_set_header host $ Http_host; proxy_pass http:/ /127.0.0.1:2368; } } |
If you do not use VIM, please Baidu. As long as the basic operation will be OK.
Then we do a soft link for the ghost.conf file to the/etc/nginx/sites-enabled/directory:
sudo ln-s/etc/nginx/sites-available/ghost.conf/etc/nginx/sites-enabled/ghost.conf
Install Forever
Currently we recommend using the upstart process daemon to start the Ghost. For information on how to start and monitor Ghost through upstart, please refer to this article: use upstart Guardian Ghost.
If you start Ghost via NPM start, if you close the remote connection, Ghost will stop, which we certainly do not want. Fortunately, there are forever tools to help us solve this problem. Next, execute the following instructions to install the Forever:
sudo npm install forever-g
Note: This instruction installs forever to the global environment. When installing the system will prompt some WARN, this is because forever relies on node.js version is too low, does not matter, does not have to ignore.
Ghost, walk you!
Download Ghost
Ghost installation package is compressed, on Linux we need to use the Unzip tool to extract it, so first to install the Unzip tool:
sudo apt-get install unzip
Next we download the Ghost installation package:
cd/srv/
sudo curl-l http://dl.ghostchina.com/Ghost-0.4.1.zip-o ghost.zip
Note: The above download link is a CDN accelerated download provided by Ghost Chinese network. In addition to acceleration, there is another reason: some sites can be harmonized at any time!
Unzip it:
sudo unzip ghost.zip-d Ghost
Now, the/srv/ghost/directory below is our ghost system!
modifying Ghost configuration Files
We enter the Ghost system directory, add configuration files for Ghost and configure the database:
cd/srv/ghost/
sudo cp config.example.js config.js
sudo vi config.js
The last instruction is to use VIM to open the Config.js file for editing. We only modify the configuration information for the production section and modify it to the following form (note: replace it with your own actual situation!) ):
The code is as follows |
Copy Code |
### Production When running Ghost into the wild, use the production environment Configure your URL and mail settings here Production: { URL: ' http://ghostchina.com ',//replace with your own domain name. Mail: {}, Database: { Client: ' MySQL ', Connection: { Host: ' 127.0.0.1 ', User: ' root ',//We'll use the MySQL root account Password: ' 123456 ',//Enter your MySQL password DB: ' ghost ',//The name of the database we created earlier for ghost CharSet: ' UTF8 ' } }, Server: { Host to is passed to node ' s ' Net. Server#listen () ' Host: ' 127.0.0.1 ', Port to is passed to node ' s ' Net. Server#listen () ', for Iisnode set this to ' Process.env.PORT ' Port: ' 2368 ' } }, |
After the check is correct, we save and exit the editor.
Installing Ghost-dependent libraries
Many students install to this step will encounter SQLite installation failure, the reason, or our great "wall" in trouble. Because the installation of SQLite need to download some components from Amazon's S3 server, but foreign servers are often wall, so in this step fell into the pit of the students are very innocent.
Unfortunately, there is no good solution at the moment.
However, our series of tutorials on the use of MySQL database with Ghost, so we can not install SQLite, the following actions:
Open the Ghost system directory under the Package.json file, will be "sqlite3": "2.2.0", this line removed (note that you see the SQLite version may be different, but, as long as the sqlite3 word, delete it).
Next, go to the directory where the Ghost system is stored and install the NPM package that Ghost relies on:
cd/srv/ghost/
sudo npm install--production
Soon all the dependencies are installed and a node_modules directory will be created in the current directory.
Start Ghost
Perform the following instructions to restart Nginx, start Ghost:
sudo service nginx restart
Cd/srv/ghost
sudo node_env=production forever start index.js
yeah! Now open the browser and enter your domain name to see if there is a familiar screen: