冠富商务通中文社区

 找回密码
 立即注册
查看: 8|回复: 0
打印 上一主题 下一主题
收起左侧

[建站经验] VPS主机搭建Ghost环境:Nginx Node.js MariaDB

[复制链接]
跳转到指定楼层
楼主
发表于 2017-1-9 23:37:37 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

Ghost是一款个人博客系统,它是使用Node.js语言和MySQL数据库开发的,同时支持MySQL、MariaDB、SQLite和PostgreSQL。用户可以在支持Node.js的服务器上使用自己的博客。它是由两位WordPress前工程师开发,特点就是轻 快 高效,并原生支持Markdown语法。
在WordPress变得越来越强大,同时又越来越臃肿的今天,Ghost的出现,无疑为博客系统界带来一股清风。 虽然如此,Ghost目前的使用者还局限于有一定代码基础的Geek,工程师们,它并不完善。如果您想尝试一下Ghost博客的轻便快速,不妨跟随本文来进行一番尝试。
本文使用的环境如下: CentOS 6.6 x86_64纯净系统 。搭建目标如下:
1.nginx 1.9.2 编译SPDY模块 ;
2.node.js v0.12.4 ;
3.MariaDB 10.1.5(YUM快速安装) ;
4.安装并配置Ghost 0.6.3程序 。
更多的有关于博客系统搭建的信息可查看:静态博客程序使用入门
一、编译安装Nginx 1.9.2
1.首先我们去官方网站下载最新的nginx源码:
  1.     cd /usr/local/srcwget http://nginx.org/download/nginx-1.9.2.tar.gz
复制代码
2.解压nginx源码:
  1. tar xzvf nginx-1.9.2.tar.gzcd nginx-1.9.2
复制代码
3.编译openssl(为https准备,不需要请跳过该步骤)
  1. yum update -y && yum install -y ncurses-devel make gcc bc  
  2. cd /usr/local/src  
  3. wget http://www.openssl.org/source/openssl-1.0.1h.tar.gz  
  4. tar zxvf openssl-1.0.1h.tar.gz  
  5. cd openssl-1.0.1h  
  6. ./config
  7. make
复制代码
4.建立makefile(此处加入了https(--with-httpsslmodule)与spdy(--with-httpspdymodule)模块,若不需要请去掉)
  1. #安装依赖环境
  2. yum update -y && yum install pcre-devel zlib-devel  
  3. #编译nginx
  4. ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6 --with-http_spdy_module --with-openssl=/usr/local/src/openssl-1.0.1h
  5. useradd www -g www  
  6. make  
  7. make install  
复制代码
5.添加nginx管理脚本,设置开机启动
  1. #!/bin/sh
  2. #
  3. # nginx - this script starts and stops the nginx daemon
  4. #
  5. # chkconfig:   - 85 15
  6. # description:  Nginx is an HTTP(S) server, HTTP(S) reverse \
  7. #               proxy and IMAP/POP3 proxy server
  8. # processname: nginx
  9. # config:      /etc/nginx/nginx.conf
  10. # config:      /etc/sysconfig/nginx
  11. # pidfile:     /var/run/nginx.pid# Source function library.
  12. . /etc/rc.d/init.d/functions# Source networking configuration.
  13. . /etc/sysconfig/network# Check that networking is up.
  14. [ "$NETWORKING" = "no" ] && exit 0nginx="/usr/local/nginx/sbin/nginx"  
  15. prog=$(basename $nginx)NGINX_CONF_FILE="http://www.chinaz.com/usr/local/nginx/conf/nginx.conf"[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginxlockpold=/var/lock/subsys/nginxmake_dirs() {  # make required directoriesuser=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`if [ -z "`grep $user /etc/passwd`" ]; thenuseradd -M -s /bin/nologin $userfioptions=`$nginx -V 2>&1 | grep 'configure arguments:'`for opt in $options; doif [ `echo $opt | grep '.*-temp-path'` ]; thenvalue=`echo $opt | cut -d "=" -f 2`if [ ! -d "$value" ]; then# echo "creating" $valuemkdir -p $value && chown -R $user $valuefifidone
  16. }start() {  [ -x $nginx ] || exit 5[ -f $NGINX_CONF_FILE ] || exit 6make_dirsecho -n $"Starting $prog: "daemon $nginx -c $NGINX_CONF_FILEretval=$?echo[ $retval -eq 0 ] && touch $lockfilereturn $retval
  17. }stop() {  echo -n $"Stopping $prog: "killproc $prog -QUITretval=$?echo[ $retval -eq 0 ] && rm -f $lockfilereturn $retval
  18. }restart() {  configtest || return $?stopsleep 1start
  19. }reload() {  configtest || return $?echo -n $"Reloading $prog: "killproc $nginx -HUPRETVAL=$?echo
  20. }force_reload() {  restart
  21. }configtest() {  $nginx -t -c $NGINX_CONF_FILE
  22. }rh_status() {  status $prog
  23. }rh_status_q() {  rh_status >/dev/null 2>&1
  24. }case "$1" in  start)rh_status_q && exit 0$1;;stop)rh_status_q || exit 0$1;;restart|configtest)$1;;reload)rh_status_q || exit 7$1;;force-reload)force_reload;;status)rh_status;;condrestart|try-restart)rh_status_q || exit 0;;*)echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"exit 2
  25. esac  
复制代码
6、使用以上代码时,请注意代码的中英文字符在复制过程中是不是有变化。执行:vim /etc/init.d/nginx  。按I编辑,贴入上方脚本。按Esc,然后按:键,输入wq,回车保存。接着执行以下代码:
  1. chkconfig --add /etc/init.d/nginx  
  2. service nginx start  
  3. chkconfig --level 2345 nginx on  
复制代码
6.nginx有关路径:nginx:/usr/local/nginx  ,nginx.conf:/usr/local/nginx/conf/nginx.conf
二、yum快速安装MariaDB 10.1.5
1.添加MariaDB源:
  1. cd /etc/yum.repos.d  
  2. vim MariaDB.repo  
  3. #输入如下内容
  4. [mariadb]
  5. name = MariaDB  
  6. baseurl = http://yum.mariadb.org/10.1.5/centos6-amd64/  
  7. gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB  
  8. gpgcheck=1  
  9. #保存退出
复制代码
2.安装启动MariaDB
  1. yum install MariaDB-server MariaDB-client MariaDB-devel  
  2. service mysql start  
复制代码
3.更改MariaDB root密码:/usr/bin/mysqladmin -u root password '你的密码'
4.设置MariaDB字符集:
  1. cd /etc/my.cnf.d  
  2. vim server.cnf  
  3. #在[mysqld]段下加入
  4. character-set-server=utf8  
  5. #在[server]段上方输入
  6. [client]
  7. default-character-set=utf8  
  8. #保存退出
  9. service mysql restart  
复制代码
5.编辑完后如下图:

5.建立ghost数据库
  1. mysql -uroot -p你的密码  
  2. #MariaDB>表示在mysql客户端中输入
  3. MariaDB>CREATE DATABASE ghost;  
  4. MariaDB>quit  
复制代码
6.MariaDB配置文件路径:my.cnf:/etc/my.cnf  ,my.cnf引用:/etc/my.cnf.d
三、安装node.js v0.12.4
1.下载node.js二进制源码包(这个是编译好的程序,可直接使用,只要设置环境变量即可)
  1. tar xzvf nginx-1.9.2.tar.gzcd nginx-1.9.20
复制代码
2.设置环境变量:
  1. tar xzvf nginx-1.9.2.tar.gzcd nginx-1.9.21
复制代码
3.附图:编辑后的/etc/profile

注:相关网站建设技巧阅读请移步到建站教程频道。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|关于我们|申请友链|Archiver|手机版|拘留所|冠富商务通

GMT+8, 2025-5-18 12:47 , Processed in 0.117007 second(s), 24 queries , Wincache On.

Powered by HCMS Version 2.0

© 2008-05-14 guanfu.net.cn

快速回复 返回顶部 返回列表