CentOS6.9搭建 wordpress

  • 今天这一篇来告诉大家搭建最新版的wordpress
  • 如果有云服务器可以用云服务器搭建

准备工作

  • centos6.9
  • httpd-2.4.27.tar.bz2
  • apr-1.5.2.tar.bz2
  • apr-util-1.5.4.tar.bz2
  • mariadb-5.5.57-linux-x86_64.tar.gz <<二进制软件
  • php-5.6.31.tar.bz2
  • wordpress-4.8-zh_CN.tar.gz
  • xcache-3.2.0.tar.bz2
  • 首先全部下载好,版本号最好是对上号,不然中间会出问题

开始搭建

  • 这一篇就懒得啰嗦就直接开始搭建了
  • 但是还是要看看自己的yum源是否配了epel源,没有赶快配,因为php里面有个依赖包需要epel源下载
  • 首先我们先安装开发包组,运行命令
[root@localhost ~]# yum groupinstall "Development Tools" -y
  • 安装完毕以后,我们开始安装httpd的依赖包运行命令
[root@localhost ~]# yum install pcre-devel  openssl-devel -y
  • 完成以后,首先我在家目录里面创建一个目录src,把我们下载的所有包上传上去,运行rz命令
  • 一般最小化安装里面是没有这个包的需要运行
[root@localhost ~]# `yum -y install lrzsz
  • rz命令把7个包全上传进系统内
  • 上传完毕以后接下来我们就开始编译了
  • 首先先解压apr-1.5.2.tar.bz2
 [root@localhost scr]# tar xfv apr-1.5.2.tar.bz2 
  • 在解压apr-util-1.5.4.tar.bz2
[root@localhost scr]# tar xfv apr-util-1.5.4.tar.bz2 
  • 最后解压 httpd-2.4.27.tar.bz2
[root@localhost scr]# tar xfv  httpd-2.4.27.tar.bz2 
  • 解压完毕以后就开始剪切,并给他改名apr
[root@localhost scr]# mv apr-1.5.2/        httpd-2.4.27/srclib/apr
  • 接下来开始剪切apr-util-1.5.4,并改名为apr-util
[root@localhost scr]# mv apr-util-1.5.4/   httpd-2.4.27/srclib/apr-util
  • 操作完毕以后,运行命令cd httpd-2.4.27
[root@localhost scr]# cd httpd-2.4.27
  • 切换进入以后我们就开始编译,运行下面命令
[root@localhost httpd-2.4.27]# ./configure --prefix=/app/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
  • 这条命令非常长单独给童鞋们放在下面
 ./configure --prefix=/app/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
  • 如果出现下面字样表编译成功
config.status: creating include/ap_config_auto.h
config.status: executing default commands
configure: summary of build options:

    Server Version: 2.4.27
    Install prefix: /app/httpd24
    C compiler:     gcc -std=gnu99
    CFLAGS:          -g -O2 -pthread
    LDFLAGS:         
    LIBS:           
    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE
    C preprocessor: gcc -E
  • 编译成功以后,接下来就是安装了运行make && make install开始安装
[root@localhost httpd-2.4.27]# make && make install
  • 接下来只有等待了,如果出现下面字样表示安装完成
Installing configuration files
mkdir /app/httpd24/conf
mkdir /app/httpd24/conf/extra
mkdir /app/httpd24/conf/original
mkdir /app/httpd24/conf/original/extra
Installing HTML documents
mkdir /app/httpd24/htdocs
Installing error documents
mkdir /app/httpd24/error
Installing icons
mkdir /app/httpd24/icons
mkdir /app/httpd24/logs
Installing CGIs
mkdir /app/httpd24/cgi-bin
Installing header files
Installing build system files
Installing man pages and online manual
mkdir /app/httpd24/man
mkdir /app/httpd24/man/man1
mkdir /app/httpd24/man/man8
mkdir /app/httpd24/manual
make[1]: Leaving directory `/root/scr/httpd-2.4.27'
  • 安装完成以后接下来我们,开始配置环境变量,运行命令vim /etc/profile.d/app.sh
[root@localhost httpd-2.4.27]# vim /etc/profile.d/app.sh
  • 打开以后把数据库和httpd24的变量写进入保存
  • 然后运行一个简单的小命令. /etc/profile.d/app.sh,注意点和空格必须要
  • 以上的运行完毕以后,我们就开始安装脚本 httpd
[root@localhost httpd-2.4.27]# yum install httpd  -y
  • 然后切换到init.d下面
cd   /etc/rc.d/init.d/
  • 来复制一个,我们以后就用这个24做脚本了
[root@localhost init.d]# cp httpd httpd24
  • 当然,我们还需要修改几项,运行vim httpd24
[root@localhost init.d]# vim httpd24
  • 修改以下几行就可以,注意修改好好检查
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/app/httpd24/bin/apachectl
httpd=${HTTPD-/app/httpd24/bin/apachectl}
prog=httpd
pidfile=${PIDFILE-/app/httpd24/logs/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
STOP_TIMEOUT=${STOP_TIMEOUT-10}
  • 完成以后我们就可以启动下看看了,运行service httpd24 start命令
[root@localhost init.d]# service httpd24 start
  • 我们出去用游览器连接看看,出现下面字样表示连接成功
  • 或者用ss -nutl命令来查看下端口,80端口有没有打开
[root@localhost init.d]# ss -nutl
Netid State      Recv-Q Send-Q                                 Local Address:Port                                   Peer Address:Port 
udp   UNCONN     0      0                                                  *:68                                                *:*     
udp   UNCONN     0      0                                                  *:68                                                *:*     
tcp   LISTEN     0      128                                               :::80                                               :::*     
tcp   LISTEN     0      128                                               :::22                                               :::*     
tcp   LISTEN     0      128                                                *:22                                                *:*     
tcp   LISTEN     0      100                                              ::1:25                                               :::*     
tcp   LISTEN     0      100                                        127.0.0.1:25                                                *:*  
  • 如果连接不上可能是你的CentOS系统防火墙的问题,必须要关闭掉防火墙
查询防火墙状态:
[root@localhost ~]# service   iptables status
停止防火墙:
[root@localhost ~]# service   iptables stop
启动防火墙:
[root@localhost ~]# service   iptables start
重启防火墙:
[root@localhost ~]# service   iptables restart
永久关闭防火墙:
[root@localhost ~]# chkconfig   iptables off
永久关闭后启用:
[root@localhost ~]# chkconfig   iptables on
  • 自己看着用
  • 接下来我们要创建数据库
  • 我们装的数据库是mariadb-5.5.57,和mysql差不多关于历史自行百度
  • 首先我们还是要先切换到我们原来上传软件的目录
  • 切换进入以后,我们解压数据库,记住数据库一定要是二进制的,不是源代码,这是为了后期加速的稳定
  • 运行命令tar xvf mariadb-5.5.57-linux-x86_64.tar.gz -C /usr/local
[root@localhost scr]# tar xvf mariadb-5.5.57-linux-x86_64.tar.gz -C  /usr/local
  • 解压以后,我们在创建用户
[root@localhost scr]# useradd -r -m -s /sbin/nologin -d /app/mysqldb mysql
  • 在改所有者,运行命令chown mysql.mysql /app/mysqldb
[root@localhost scr]# chown mysql.mysql /app/mysqldb
  • 在切换下目录
[root@localhost scr]# cd /usr/local
  • 创建软连接
[root@localhost local]# ln -s mariadb-5.5.57-linux-x86_64/ mysql
  • 在切换目录
[root@localhost local]# cd mysql
  • 运行以下命令
[root@localhost mysql]# scripts/mysql_install_db --datadir=/app/mysqldb --user=mysql
  • 在创建文件
[root@localhost mysql]# mkdir /etc/mysql
  • 运行下面命令
[root@localhost mysql]# cp support-files/my-large.cnf /etc/mysql/my.cnf
  • 找到这一行
  • 在mysqld下面添加三行
  • 然后保存
  • 接下来我们运行,来创建日志
[root@localhost mysql]# touch /var/log/mysqld.log 
  • 创建了我们来修改日志的所有者
[root@localhost mysql]# chown mysql  /var/log/mysqld.log
  • 所有者改好以后就可以来运行啦
[root@localhost mysql]# service mysqld start 
  • 也可以用ss -nutl来查询,看有没有3306端口
[root@localhost mysql]# ss -nutl
Netid State      Recv-Q Send-Q                                 Local Address:Port                                   Peer Address:Port 
udp   UNCONN     0      0                                                  *:68                                                *:*     
udp   UNCONN     0      0                                                  *:68                                                *:*     
tcp   LISTEN     0      50                                                 *:3306                                              *:*     
tcp   LISTEN     0      128                                               :::80                                               :::*     
tcp   LISTEN     0      128                                               :::22                                               :::*     
tcp   LISTEN     0      128                                                *:22                                                *:*     
tcp   LISTEN     0      100                                              ::1:25                                               :::*     
tcp   LISTEN     0      100                                        127.0.0.1:25                                                *:*     
  • 接下来我们设置安全上下文命令:mysql_secure_installation 关于怎么设定
  • 之间回车以后回登录数据库,登录了以后回让你设置密码,看下图
  • 完成以后我们开始创建wordpress使用的数据库和用户及权限
[root@localhost mysql]# mysql -uroot -p111111 -e "create database blogdb; grant all on blogdb.* to wpuser@'localhost' identified by '111111';"
  • 完成以后测试验证登录成功
  • 接下来我们就要开始编译PHP了
  • 回到我们的上传目录,运行tar xfv php-5.6.31.tar.bz2
[root@localhost scr]# tar xfv php-5.6.31.tar.bz2 
  • 先安装依赖包
[root@localhost mysql]#yum -y install bzip2-devel  libxml2-devel libmcrypt-devel
  • 在切换到php-5.6.31目录下,运行下面命令
[root@localhost php-5.6.31]# ./configure --prefix=/app/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir  --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/app/httpd24/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d  --with-bz2
  • 如果出现下面字样表示编译成功
Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
|                        *** WARNING ***                             |
|                                                                    |
| You have built PHP for Apache's current non-threaded MPM.          |
| If you change Apache to use a threaded MPM you must reconfigure    |
| PHP with --enable-maintainer-zts                                   |
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
  • 然后开始安装
[root@localhost php-5.6.31]# make  && make install    
  • 安装完毕以后,运行以下命令
[root@localhost php-5.6.31]# cp php.ini-production /etc/php.ini
  • 然后我们开始修改httpd的配置文件,让他支持PHP
[root@localhost php-5.6.31]# vim /app/httpd24/conf/httpd.conf
  • 做完以后以后重启下httpd24
[root@localhost php-5.6.31]# service httpd24 restart
  • 接下下来我们测试下,用以下命令来创建下
[root@localhost php-5.6.31]# vim /app/httpd24/htdocs/index.php
  • 把下面粘贴进去
<?php
    $conn=mysql_connect('localhost','wpuser','111111');
    if($conn)
        echo "OK";
    else
        echo "Not OK";
    mysql_close();
    phpinfo();
?>
  • 然后我们出去刷新下网页
  • 出来了表示成功
  • 接下我们去解压wordpress
    [root@localhost scr]# tar xfv wordpress-4.8-zh_CN.tar.gz -C /app/httpd24/htdocs/
  • 在切换到/app/httpd24/htdocs/下面,改下他的名字
[root@localhost htdocs]# mv wordpress/  blog
  • 接下来切换到 blog下面
[root@localhost htdocs]# cd blog/
  • 切换完成以后运行下以后命令
[root@localhost blog]# cp wp-config-sample.php wp-config.php  
  • 然后在开始修改配置文件
[root@localhost blog]# vim  wp-config.php  
  • 修改完成以后,我们在去网页看看
  • 已经成功接下来的事都是你们自己的事了
  • 网页是别忘记了是http://172.16.253.185/blog/
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 218,525评论 6 507
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,203评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,862评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,728评论 1 294
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,743评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,590评论 1 305
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,330评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,244评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,693评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,885评论 3 336
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,001评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,723评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,343评论 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,919评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,042评论 1 270
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,191评论 3 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,955评论 2 355

推荐阅读更多精彩内容