019LNMP架构wordpress blog搭建教程

LNMP架构wordpress 个人blog搭建教程

1.mysql安装

请参考mysql安装教程(rpm)

2.安装PHP

yum install php php-fpm php-mysql
php-mysql安装时会产生报错

file /usr/share/mysql/ukrainian/errmsg.sys from install of mysql-libs-5.1.73-7.el6.x86_64 conflicts with file from package MySQL-server-5.6.21-1.linux_glibc2.5.x86_64

需要安装MySQL-shared-compat-5.6.14-1.el6.x86_64.rpm包

依赖软件下载
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-shared-compat-5.6.14-1.el6.x86_64.rpm
rpm -ivh MySQL-shared-compat-5.6.14-1.el6.x86_64.rpm

3.安装nginx

1.安装

nginx-1.10.2.tar.gz
yum -y install gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl openssl-devel
tar -zxvf nginx-1.10.2.tar.gz 
cd nginx-1.10.2
./configure --prefix=/usr/local/nginx
make && make install
防火墙关闭
/usr/local/nginx/sbin/nginx -t  检查nginx配置文件是否正确
/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx -s reload
开机自启
vi /etc/rc.local
/usr/local/nginx/sbin/nginx

2.开机自启动配置

vim /etc/init.d/nginx

启动脚本设置链接:https://www.nginx.com/resources/wiki/start/topics/examples/redhatnginxinit/

/etc/init.d/nginx start
/etc/init.d/nginx stop
/etc/init.d/nginx reload
chkconfig --add /etc/init.d/nginx
service nginx start
service nginx stop
service nginx reload
chkconfig --level 3 nginx on
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig:   - 85 15
# description:  NGINX is an HTTP(S) server, HTTP(S) reverse \
#               proxy and IMAP/POP3 proxy server
# processname: nginx
# config:      /etc/nginx/nginx.conf
# config:      /etc/sysconfig/nginx
# pidfile:     /var/run/nginx.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

nginx="/usr/sbin/nginx"
prog=$(basename $nginx)

NGINX_CONF_FILE="/etc/nginx/nginx.conf"

[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

make_dirs() {
   # make required directories
   user=`$nginx -V 2>&1 | grep "configure arguments:.*--user=" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
   if [ -n "$user" ]; then
      if [ -z "`grep $user /etc/passwd`" ]; then
         useradd -M -s /bin/nologin $user
      fi
      options=`$nginx -V 2>&1 | grep 'configure arguments:'`
      for opt in $options; do
          if [ `echo $opt | grep '.*-temp-path'` ]; then
              value=`echo $opt | cut -d "=" -f 2`
              if [ ! -d "$value" ]; then
                  # echo "creating" $value
                  mkdir -p $value && chown -R $user $value
              fi
          fi
       done
    fi
}

start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    make_dirs
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    configtest || return $?
    stop
    sleep 1
    start
}

reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
}

force_reload() {
    restart
}

configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}

rh_status() {
    status $prog
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}

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
esac

1.将其文件权限改为755
2.nginx=”/usr/local/nginx/sbin/nginx” 修改成自己安装nginx路径下面nginx执行程序的路径
3.NGINX_CONF_FILE=”/usr/local/nginx/conf/nginx.conf” 修改成自己安装nginx路径下面配置文件的路径。

4.安装wordpress

1.下载https://cn.wordpress.org/
2.安装

tar -zxvf wordpress-4.7-zh_CN.tar.gz
mv wordpress /var/www/html/

5.配置各软件衔接

5.1数据库配置

create datebase wordpress;
grant all on wordpress.* to wordpress@localhost identified by "wordpress123";   #为wordpress 创建wordpress账户的访问权限
flush privileges;

5.2nginx配置

vim /usr/local/nginx/conf/nginx.conf

            root   /var/www/html;
            index  index.html index.htm index.php;

        location ~ \.php$ {
            root           /var/www/html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/www/html$fastcgi_script_name;
            include        fastcgi_params;
        }

5.3启动php

service php-fpm start
chkconfig php-fpm on

6.博客试运行

1.登录网址http://127.0.0.1/wordpress
2.设置数据库信息
3.生成php文件或服务器上文件写入
vim /var/www/html/wordpress/wp-config.php
存入页面提示内容
4.输入博客管理员账户及设置密码

7.文章支持markdown语法

1.下载插件
https://wordpress.org/plugins/wp-markdown/installation/
2.解压至
/var/www/html/wordpress/wp-content/plugins路径
3.进入管理界面进行插件启用
4.设置->撰写->markdown选项

8.wordpress升级

mv /var/www/html/wordpress /var/www/html/wordpress.bak    #备份
tar -zxvf latest.tar.gz -C /var/www/html/
cp -R /var/www/html/wordpress/wp-content.bak/wp-content /var/www/html/wordpress/wp-content/  
cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php      #修改配置文件
diff /var/www/html/wordpress.bak/wp-config.php /var/www/html/wordpress/wp-config.php
进行修改数据库信息等
登录你的WordPress网站后台(/wp-admin                     #登录后台
登录http://example.com/wordpress/wp-admin/upgrade.php     #登录此地址进行相应的数据库升级(如需要)

你可能感兴趣的:(019LNMP架构wordpress blog搭建教程)