一、环境准备
Centos7.6最小化安装
关闭防火墙、selinux
需要用到的安装包:
apr-1.7.0.tar.bz2 apr-util-1.6.1.tar.bz2 httpd-2.4.39.tar.bz2 mariadb-10.2.25-linux-x86_64.tar.gz
php-7.3.7.tar.xz wordpress-5.2.2.tar.gz Discuz_X3.3_SC_UTF8.zip
二、安装
1、解压安装包
for i in *.bz2 ;do tar xvf $i ;done
如果解压报错安装bzip2包
tar xvf php-7.3.7.tar.xz tar xvf wordpress-5.2.2.tar.gz unzip Discuz_X3.3_SC_UTF8.zip tar xvf mariadb-10.2.25-linux-x86_64.tar.gz -C /usr/local
2、编译安装apache
有2种方法一种是分别编译安装apr、apr-util、httpd,第二种就是三个软件放在一起编译安装,这里使用第二种方法
(1)合并文件、安装依赖包、
mv apr-1.7.0 httpd-2.4.39/srclib/apr
mv apr-util-1.6.1 httpd-2.4.39/srclib/apr-util
yum install gcc prce-devel openssl-devel expat-devel -y
useradd -s /sbin/nologin apache #创建用户
(2)编译安装
[root@swh httpd-2.4.39]#./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 [root@swh httpd-2.4.39]#make -j 2 && make install #安装部分截图
(2)设置环境变量
[root@swh httpd-2.4.39]#echo 'PATH=/app/httpd24/bin:$PATH' > /etc/profile.d/httpd24.sh
[root@swh httpd-2.4.39]#. /etc/profile.d/httpd24.sh
(3)编写systemctl启动脚本或者直接复制启动脚本用service管理也行
[root@swh httpd-2.4.39]#vi /usr/lib/systemd/system/httpd24.service
[Unit] Description=The Apache HTTP Server After=network.target remote-fs.target nss-lookup.target Documentation=man:httpd(8) Documentation=man:apachectl(8) [Service] Type=forking #EnvironmentFile=/etc/sysconfig/httpd ExecStart=/app/httpd24/bin/httpd $OPTIONS -k start #ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND ExecReload=/usr/sbin/httpd $OPTIONS -k graceful ExecStop=/bin/kill -WINCH ${MAINPID} # We want systemd to give httpd some time to finish gracefully, but still want # it to kill httpd after TimeoutStopSec if something went wrong during the # graceful stop. Normally, Systemd sends SIGTERM signal right after the # ExecStop, which would kill httpd. We are sending useless SIGCONT here to give # httpd time to finish. KillSignal=SIGCONT PrivateTmp=true [Install] WantedBy=multi-user.target
[root@swh httpd-2.4.39]#systemctl start httpd24 #启动服务测试
(4)修改配置文件
[root@swh httpd-2.4.39]#cp /app/httpd24/conf/httpd.conf /app/httpd24/conf/httpd.conf.bak
[root@swh httpd-2.4.39]#vi /app/httpd24/conf/httpd.conf
LoadModule proxy_module modules/mod_proxy.so #120行代理模块 LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so #124行 User apache #修改173、174行的用户和组 Group apache DirectoryIndex index.php index.html # 261行默认首页 #以下内容添加到最后面 AddType application/x-httpd-php .php #让apache能够识别php文件 AddType application/x-httpd-php-source .phps ProxyRequests Offservername wp.swh.com documentroot /data/wordpress require all granted ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/wordpress/$1servername dz.swh.com documentroot /data/discuz require all granted ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/discuz/$1
[root@swh mysql]#mkdir /data/wordpress 创建网站目录
[root@swh mysql]#mkdir /data/discuz
[root@swh mysql]#mv upload/* discuz/
[root@swh data]#setfacl -Rm u:apache:rwx /data/{wordpress,discuz}
重启httpd24服务
3、编译安装mysql
(1)安装参考
https://blog.51cto.com/14322729/2418319
(2)创建数据库和用户
MariaDB [(none)]> create database wordpress;
MariaDB [(none)]> create database discuz;
MariaDB [(none)]> grant all on wordpress.* to wpuser@'192.168.12.%' identified by '123456';
MariaDB [(none)]> grant all on discuz.* to dzuser@'192.168.12.%' identified by '123456';
4、编译安装php
(1)安装依赖包
yum install libxml2-devel bzip2-devel libmcrypt-devel openssl-devel gcc
(2)编译安装
[root@swh php-7.3.7]#./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 && make install
注意:php-7.0以上版本使用--enable-mysqlnd --with-mysqli=mysqlnd ,原--with-mysql不再支持
[root@swh php-7.3.7]#make && make install
cp php.ini-production /etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
cd /app/php/etc
cp php-fpm.conf.default php-fpm.conf
cd php-fpm.d/
cp www.conf.default www.conf
vim www.conf
user = apache #修改23、24行 group = apache
service php-fpm start
5、安装程序
修改windows的hosts文件C:\Windows\System32\drivers\etc\hosts
192.168.12.27 wp.swh.com dz.swh.com
注意之前数据库地址要填写192.168.12.27