LNMP架構(gòu)wordpress 個(gè)人blog搭建教程
1.mysql安裝
請參考mysql安裝教程(rpm)
2.安裝PHP
yum install php php-fpm php-mysql
php-mysql安裝時(shí)會(huì)產(chǎn)生報(bào)錯(cuò)
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
防火墻關(guān)閉
/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
開機(jī)自啟
vi /etc/rc.local
/usr/local/nginx/sbin/nginx
2.開機(jī)自啟動(dòng)配置
vim /etc/init.d/nginx
啟動(dòng)腳本設(shè)置鏈接: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.將其文件權(quán)限改為755
2.nginx=”/usr/local/nginx/sbin/nginx” 修改成自己安裝nginx路徑下面nginx執(zhí)行程序的路徑
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數(shù)據(jù)庫配置
create datebase wordpress;
grant all on wordpress.* to wordpress@localhost identified by "wordpress123"; #為wordpress 創(chuàng)建wordpress賬戶的訪問權(quán)限
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啟動(dòng)php
service php-fpm start
chkconfig php-fpm on
6.博客試運(yùn)行
1.登錄網(wǎng)址http://127.0.0.1/wordpress
2.設(shè)置數(shù)據(jù)庫信息
3.生成php文件或服務(wù)器上文件寫入
vim /var/www/html/wordpress/wp-config.php
存入頁面提示內(nèi)容
4.輸入博客管理員賬戶及設(shè)置密碼
7.文章支持markdown語法
1.下載插件
https://wordpress.org/plugins/wp-markdown/installation/
2.解壓至
/var/www/html/wordpress/wp-content/plugins路徑
3.進(jìn)入管理界面進(jìn)行插件啟用
4.設(shè)置->撰寫->markdown選項(xiàng)
8.wordpress升級(jí)
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
進(jìn)行修改數(shù)據(jù)庫信息等
登錄你的WordPress網(wǎng)站后臺(tái)(/wp-admin #登錄后臺(tái)
登錄http://example.com/wordpress/wp-admin/upgrade.php #登錄此地址進(jìn)行相應(yīng)的數(shù)據(jù)庫升級(jí)(如需要)