LAMP ----- 編譯實現基於FASTCGI的LAMP的WordPress
一臺: httpd, php 192.168.21.104
安裝包存放路徑: /data apr-1.6.5.tar.bz2 httpd.apache.org #wget http://mirror.bit.edu.cn/apache//apr/apr-1.6.5.tar.bz2 apr-util-1.6.1.tar.bz2 httpd.apache.org #wget http://mirror.bit.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2 httpd-2.4.38.tar.bz2 httpd.apache.org #wget http://mirrors.shu.edu.cn/apache//httpd/httpd-2.4.38.tar.bz2 php-7.3.2.tar.xz www.php.net #wget http://cn2.php.net/get/php-7.3.2.tar.xz/from/this/mirror wordpress-5.0.3-zh_CN.tar.gz https://cn.wordpress.org/download/ #wget https://cn.wordpress.org/wordpress-5.0.3-zh_CN.tar.gz
一臺: mariadb 192.168.21.106
安裝包存放路徑:/root
mariadb-10.2.22-linux-x86_64.tar.gz
#wget https://downloads.mariadb.org/interstitial/mariadb-10.2.22/bintar-linux-x86_64/mariadb-10.2.22-linux-x86_64.tar.gz/from/http%3A//mirror.wtnet.de/mariadb/
2 在192.168.21.104上,安裝相關包
#yum -y install gcc glibc pcre-devel openssl-devel expat-devel libxml2-devel bzip2-devel libmcrypt-devel
3 源碼編譯安裝httpd
#tar xvf apr-1.6.5.tar.bz2
#tar xvf apr-util-1.6.1.tar.bz2
#tar xvf httpd-2.4.38.tar.bz2
把解壓後的apr, apr-util文件夾移到apache解壓文件的srclib路徑下重命名
#mv apr-1.6.5 httpd-2.4.38/srclib/apr
#mv apr-util-1.6.1 httpd-2.4.38/srclib/apr-util
#cd httpd-2.4.38/
./configure --prefix=/app/httpd24 \
--enable-so \
--enable-ssl \
--enable-rewrite \
--with-zlib \
--with-pcre \
--enable-modules=most \
--enable-mpms-shared=all \
--with-mpm=prefork \
--with-included-apr
#make -j 4 && make install
環境變量
#echo ‘PATH=/app/httpd24/bin:$PATH‘ > /etc/profile.d/lamp.sh
#source /etc/profile.d/lamp.sh
創建apache用戶
#useradd -r -s /sbin/nologin apache
把用戶和組改為:apache
#vim /app/httpd24/conf/httpd.conf
user apache
group apache
啟動apache
#apachectl
4 在192.168.21.106上, 二進制源碼包安裝mariadb
#tar xvf mariadb-10.2.22-linux-x86_64.tar.gz -C /usr/local/
#cd /usr/local
#ln -s mariadb-10.2.22-linux-x86_64/ mysql
#chown -R root.root /usr/local/mysql/
#useradd -r -s /sbin/nologin mysql
創建數據庫文件目錄
#mkdir -pv /data/mysql
#chown mysql.mysql /data/mysql
利用腳本生成數據庫文件
#scripts/mysql_install_db --datadir=/data/mysql --user=mysql
準備數據庫配置文件
#mkdir /etc/mysql/
#cp /usr/local/mysql/support-files/my-huge.cnf /etc/mysql/my.cnf
#vim /etc/mysql/my.cnf
datadir=/data/mysql
準備啟動腳本
#cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
#chkconfig --add mysqld
#chkconfig --list mysqld
數據庫安全加固
#mysql_secure_installation
#service mysqld start
配置環境變量
#echo ‘PATH=/usr/local/mysql/bin:$PATH‘ > /etc/profile.d/mysql.sh
#. /etc/profile.d/mysql.sh
#mysql -uroot -p
創建數據庫:wpdb (給WordPress用)
mysql>create database wpdb;
創建登陸wpdb數據庫的賬號: 用戶:wpuser 密碼:centos 並給設權限。
mysql>grant all on wpdb.* to wpuser@‘192.168.21.%‘ identified by ‘centos‘;
5 編譯安裝php
#tar xvf php-7.3.2.tar.xz
#cd php-7.3.2/
./configure --prefix=/app/php --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-mbstring --enable-xml --enable-sockets --enable-fpm --enable-maintainer-zts --disable-fileinfo
#make -j 4 && make install
進到php解壓縮的目錄
#cd /data/php-7.3.2
準備php 配置文件
#cp php.ini-production /etc/php.ini
準備php的啟動腳本
#cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
#chmod +x /etc/init.d/php-fpm
#chkconfig --add php-fpm
#chkconfig --list php-fpm
進到php安裝目錄
#cd /app/php/etc
準備php-fpm的配置文件
#cp php-fpm.conf.default php-fpm.conf
#cp php-fpm.d/www.conf.default php-fpm.d/www.conf
#service php-fpm start
#ss -ntl //查看9000的端口號是否已開啟
6 修改httpd的配置支持fpm
#vim /app/httpd24/conf/httpd.conf
取消下面兩行的註釋
LoadModule proxy_modulemodules/mod_proxy.so
LoadModule proxy_fcgi_modulemodules/mod_proxy_fcgi.so
修改下面行
<IfModuledir_module>
DirectoryIndex index.php index.html
</IfModule>
配置文件的最後加下面四行:shift + g (光標移到配置文件尾部)
AddType application/x-httpd-php.php
AddType application/x-httpd-php-source .phps
ProxyRequests Off
ProxyPassMatch^/(.*.php)$ fcgi://127.0.0.1:9000/app/httpd24/htdocs/$1
7 配置wordpress
#cd /data/
把WordPress解壓到apache的網站目錄下
#tar xvf wordpress-5.0.3-zh_CN.tar.gz -C /app/httpd24/htdocs/
#cd /app/httpd24/htdocs/wordpress
準備wordpress的配置文件
#cp wp-config-sample.php wp-config.php
#vim wp-config.php
/* WordPress數據庫的名稱 /
define(‘DB_NAME‘, ‘wpdb‘);
/* MySQL數據庫用戶名 /
define(‘DB_USER‘, ‘wpuser‘);
/* MySQL數據庫密碼 /
define(‘DB_PASSWORD‘, ‘centos‘);
/* MySQL主機 /
define(‘DB_HOST‘, ‘192.168.21.106‘);
測試:
#cd /app/httpd24/htdocs/
創建index.php測試頁面
#vim index.php
<?php
phpinfo();
?>
#ls
index.html index.php wordpress
本地瀏覽器訪問:
http://192.168.21.104/index.html
http://192.168.21.104/index.php
http://192.168.21.104/wordpress/
LAMP ----- 編譯實現基於FASTCGI的LAMP的WordPress