- 编译安装搭建wordpress
名称 | 版本 | 包名 |
---|---|---|
Centos | 7.4 | CentOS Linux release 7.4.1708 (Core) |
Apache | 2.4.37 | httpd-2.4.37.tar.bz2 |
APR | 1.6.5 | apr-1.6.5.tar.bz2 |
APR-util | 1.6.1 | apr-util-1.6.1.tar.bz2 |
PHP | 7.1.18 | php-7.1.18.tar.bz2 |
Mariadb | 10.2.15 | mariadb-10.2.15-linux-x86_64.tar.gz |
WordPress | 4.9.4 | wordpress-4.9.4-zh_CN.tar.gz |
1.编译安装httpd (1)解压httpd,APR,APR-util的软件包
tar xvf apr-1.6.5.tar.bz2
tar xvf apr-util-1.6.1.tar.bz2
tar xvf httpd-2.4.37.tar.bz2
(2)将APR和APR-util目录移动到httpd的srclib目录下
mv apr-util-1.6.1 httpd-2.4.37/srclib/apr-util
mv apr-1.6.5 httpd-2.4.37/srclib/apr
(3)开始编译:
cd httpd-2.4.37/
./configure --prefix=/app/httpd24 --sysconfdir=/etc/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
make & make install
(4)创建用户环境
useradd -r -s /sbin/nologin apache
[root@localhost src]# vim /etc/profile.d/httpd24.sh
export PATH=/app/httpd24/bin/:$PATH
. /etc/profile.d/httpd24.sh
(5)使用apachectl命令控制Apache服务
apachectl --options
2.二进制安装Mariadb
(1)准备用户:
useradd -r -d /data/mysql mysql
(2)准备数据目录:
mkdir /data/mysq
chown mysql:mysql /data/mysqll
(3)准备二进制程序
tar xvf mariadb-10.2.15-linux-x86_64.tar.gz -C /usr/local/
cd /usr/local/
ln -sv mariadb-10.2.15-linux-x86_64 mysql
chown -R root:mysql /usr/local/mysql/
(4)配置文件
mkdir /etc/mysql/
cp /usr/local/mysql/support-files/my-large.cnf /etc/mysql/my.cnf
[mysql]中添加
datadir = /data/mysql
innodb_file_per_table = on
skip_name_resolve = on
(5)创建数据库文件
cd /usr/local/mysql/
./scripts/mysql_install_db --datadir=/data/mysql --user=mysql
(6)准备服务脚本,并启动脚本
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
service mysqld start
(7)PATH路径
echo ‘PATH=/user/local/mysql/bin:$PATH’ > /etc/profile.d/mysql.sh
. /etc/profile.d/mysql.sh
(8)创建数据库和授权用户
mysql>create database wordpress;
mysql>grant all on wordpress.* to wpuser@'172.20.10/e.%' identified by 'wpuser';
3.编译安装PHP
(1)安装相关软件包
yum install libxml2-devel bzip2-devel libmcrypt-devel -y
(2)解压PHP并安装
tar xvf php-7.1.18.tar.xz
cd php-7.1.18/
./configure --prefix=/app/php --enable-mysqlnd --with-mysqli=mysqlnd --with-openssl --with-pdo-mysql=mysqlnd --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 --enable-maintainer-zts --disable-fileinfo
make && make install
(3)配置文件设置
cp php.ini-production /etc/php.ini
vim /etc/httpd24/httpd.conf
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
#在文件最后写入下面两行代码
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
(4)测试连接数据库
[root@localhost htdocs]# vim mysql.php
<?php
$mysqli=new mysqli("172.20.10.5","wpuser","wppass");
if(mysqli_connect_errno()){
echo "连接数据库失败!";
$mysqli=null;
exit;
}
echo "连接数据库成功!";
$mysqli->close();
?>
4.设置wordpress (1)解压wordpress包
tar xvf wordpress-4.9.4-zh_CN.tar.gz
mv wordpress /app/httpd24/htdocs/blog
(2)修改wordpress配置文件
[root@localhost blog]# vim wp-config.php
// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
/** WordPress数据库的名称 */
define('DB_NAME', 'wordpress');
/** MySQL数据库用户名 */
define('DB_USER', 'wpuser');
/** MySQL数据库密码 */
define('DB_PASSWORD', 'wppass');
/** MySQL主机 */
define('DB_HOST', '172.20.10.5');
/** 创建数据表时默认的文字编码 */
define('DB_CHARSET', 'utf8');
(3)设置登录账号 (4)登录: (5)访问: