1、编译安装搭建wordpress
实验使用的是CentOS、Apache、Mariadb、PHP的LAMP构架。
系统和软件包
Apache 2.4.39 http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.39.tar.bz2
APR 1.7.0 http://mirror.bit.edu.cn/apache//apr/apr-1.7.0.tar.bz2
APR-util 1.6.1 http://mirror.bit.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2
PHP 7.1.30 https://www.php.net/distributions/php-7.1.30.tar.bz2
Mariadb 10.2.24 https://downloads.mariadb.org/interstitial/mariadb-10.2.24/source/mariadb-10.2.24.tar.gz/from/http%3A//mirrors.tuna.tsinghua.edu.cn/mariadb/
WordPress 5.2.1 https://wordpress.org/latest.tar.gz
将准备好的包准备好统一放入一个目录中 /usr/local/src
安装开发包组和必要软件包
# yum groupinstall 'Development tools' “Server Platform Development”
# yum install openssl-devel pcre-devel expat-devel gcc gcc-c++ flex bison autoconf automake libpng-devel libjpeg-devel freetype-devel openjpeg-libs fontconfig-devel libXpm-devel cmake ncurses-devel apr-devel pcre-devel apr-util-devel openssl-devel libxml2-devel curl-devel -y
解压apache、arp、 arp-util的软件包编译安装apache
GD2 是一个生成图片所使用的依赖包
tar xf gd-2.0.34.tar.gz
cd gd-2.0.34
./configure --prefix=/usr/local/gd2
make && make install
tar xf apr-1.7.0.tar.bz2
cd apr
./configure --prefix=/usr/local/apr
make && make install
tar xf apr-util-1.6.1.tar.bz2
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
最后编译安装apache,首先创建用户
groupadd -r apache
useradd -r -g apache apache
拷贝解压好的apr和apr-util安装目录全部文件到httpd解压目录下srclib中。
#tar xf httpd-2.4.39.tar.bz2
#cp -r apr-1.7.0 httpd-2.4.39/srclib/apr
#cp -r apr-util-1.6.1 httpd-2.4.39/srclib/apr-util
cd httpd-2.4.39
./configure --prefix=/usr/local/httpd \
--sysconfdir=/etc/httpd \
--enable-so \
--enable-ssl \
--enable-cgi \
--enable-rewrite \
--enable-zlib \
--enable-modules=most \
--enable-mpms-shared=all \
--with-mpm=event \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--with-included-apr \
--enable-cache \
--enable-cache-disk \
--enable-sed \
--enable-http \
--enable-cgid \
--enable-vhost-alias
make && make install
添加/usr/local/httpd/bin/至PATH环境变量
echo "export PATH=$PATH:/usr/local/httpd/bin/" >> ~/.bashrc
#/usr/local/httpd/bin/apachectl start
访问 http://localhost 测试
编译安装MariaDB
# yum install ncurses-devel
删除系统原有mariadb
yum earse mariadb -y
查看默认数据库配置文件
~]# find -H /etc/ | grep my.c
删除默认数据库配置文件
# rm -rf /etc/my.cnf /etc/my.cnf.d/
卸载系统自带mariadb-libs
rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps
创建mysql系统用户组
groupadd -r mysql
useradd -r -g mysql -s /sbin/nologin -d /usr/local/mysql -M mysql
创建mariadb安装目录,创建数据库存放目录,改变数据库存放目录所属用户及组为 mysql:mysql
# mkdir -p /usr/local/mysql
# mkdir -p /data/mysql
# chown -R mysql:mysql /data/mysql
执行编译安装
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DSYSCONFDIR=/etc \
-DWITHOUT_TOKUDB=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STPRAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWIYH_READLINE=1 \
-DWIYH_SSL=system \
-DVITH_ZLIB=system \
-DWITH_LOBWRAP=0 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make && make install
配置MariaDB
cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf
vi /etc/my.cnf
在[mysqld]标签下加入三行
user = mysql
skip_name_resolve=ON
innodb_file_per_table=ON
echo "export PATH=$PATH:/usr/local/mysql/bin/" >> ~/.bashrc
# cd /usr/local/mysql/
> 使用 `mysql` 用户执行脚本, 安装数据库到数据库存放目录
# /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql
> 输出以下信息:Installing MariaDB/MySQL system tables in '/data/mysql' ...
OK
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
加固mysql服务器,在安装完成后,运行mysql_secure_installation命令
[root@localhost mysql]# mysql -uroot -h127.0.0.1 -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.2.24-MariaDB Source distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
登入创建wordpress数据库并授权
create database wp;
Grant ALL ON wp.* TO 'wp'@'127.0.0.1' IDENTIFIED BY 'wp';
FLUSH PRIVILEGES;
编译安装php
yum -y install libicu-devel
Development files for International Components for Unicode
linmcrypt 与 mhash zlib、freetype、openssl是 php 会依赖的一些包
cd /usr/local/src && wget http://www.zlib.net/zlib-1.2.11.tar.gz
tar -xvzf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=/usr/local/zlib
make && make install
cd /usr/local/src && wget https://www.openssl.org/source/openssl-1.1.0e.tar.gz --no-check-certificate
tar -xzf openssl-1.1.0e.tar.gz
cd openssl-1.1.0e/
./config --prefix=/usr/local/openssl
./config -t
make && make install
cd /usr/local/src && wget https://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.gz --no-check-certificate
tar -zxvf freetype-2.4.0.tar.gzcd freetype-2.4.0/
./configure --prefix=/usr/local/freetype
make && make install
tar xf libmcrypt-2.5.8.tar.bz2
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt
make && make install
tar xf mhash-0.9.9.9.tar.bz2
cd mhash-0.9.9.9
./configure --prefix=/usr/local/mhash
make && make install
tar -zxvf php-7.0.30.tar.gz
cd php-7.0.30./configure \
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-config-file-scan-dir=/usr/local/php/etc/php.d \
--enable-embedded-mysqli \
--with-mysqli \
--mandir=/usr/local/php/share/man \
--infodir=/usr/local/php/share/info \
--with-pdo-mysql=/usr/local/mysql/ \
--enable-fpm \
--enable-mbstring \
--enable-bcmath \
--enable-opcache \
--enable-sockets \
--enable-zip \
--enable-soap \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curlwrappers \
--enable-mbregex \
--enable-exif \
--enable-ftp \
--enable-intl \
--with-libxml-dir \
--enable-xml \
--with-curl \
--with-gd \
--with-jpeg-dir=/usr/local/zlib \
--with-png-dir=/usr/local/zlib \
--with-mcrypt=/usr/local/libmcrypt/ \
--with-freetype-dir=/usr/local/freetype \
--with-zlib=/usr/local/zlib \
--with-openssl=/usr/local/openssl \
--enable-gd-native-ttf \
--with-mhash=/usr/local/mhash/ \
--with-apxs2=/usr/local/httpd/bin/apxs \
--disable-cgi \
--disable-cli
make && make install
mkdir /usr/local/php/etc
cp php.ini-production /usr/local/php/etc/php.ini
配置 apache 与 php 集成
vim /usr/local/php/etc/php.ini
添加
include_path = "/usr/local/php/lib/php"
vim /usr/local/httpd/httpd.conf
添加
AddType application/x-httpd-php.php.phtml
Addtype application/x-httpd-php-source.phps
查找 DirectoryIndex index.html 添加 index.php
DirectoryIndex index.html index.php
去掉注释
LoadModuleproxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModuleproxy_module modules/mod_proxy.so
Include /etc/httpd/extra/httpd-mpm.conf
Include /etc/httpd/extra/httpd-info.conf
Include /etc/httpd/extra/httpd-vhosts.conf
启动php-fpm
/usr/local/php/sbin/php-fpm
测试
创建WordPress虚拟主机
# vim /etc/httpd/conf.d/wordpress.conf
<VirtualHost 192.168.5.100:80>
ServerName www.wp.com
DocumentRoot "/data/wp"
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/wp/$1
ProxyRequests Off
<Directory "/data/wp">
Options None
AllowOverride None
Require all granted </Directory>
</VirtualHost>
2、搭建php-admin
# yum -y install php-mbstring support for multi-byte string handling to PHP
解压下载文件至指定目录
# tar -xzvf phpMyAdmin-4.0.10.20-all-languages.tar.gz -C /data
# mv phpMyAdmin-4.0.10.20-all-languages phpMyAdmin
创建phpMyAdmin虚拟主机
<VirtualHost 192.168.5.100:80>
ServerName www.phpMyAdmin.com
DocumentRoot "/data/phpMyAdmin"
<Directory "/data/phpMyAdmin">
Options None
AllowOverride None
Require all granted
</Directory>
</VirtualHost>