目录
- CentOS7编译安装LAMP
- 二进制安装mariadb
- 编译安装httpd-2.4.39
- CentOS7 fpm方式编译安装PHP
- 安装wordpress 和 discuz
CentOS7编译安装LAMP
- mairadb:通用二进制格式,mariadb-10.2.23
- httpd:编译安装,httpd-2.4.39
- php5:编译安装,php-7.3.5
顺序:mariadb–>httpd–>php
192.168.99.103安装mariadb
192.168.99.101安装httpd和php
二进制安装mariadb
- 添加用户
[103]$ useradd -r -s /sbin/nologin mysql -d /data/mysql
- 创建数据库目录,并给权限
[103]$ mkdir /data/mysql
[103]$ chown -R mysql.mysql /data/mysql
- 解压二进制文件
[103]$ tar xf mariadb-10.2.23-linux-x86_64.tar.gz
- 移动到指定的目录
[103]$ mv mariadb-10.2.23-linux-x86_64 /usr/local/
- 创建软连接
[103]$ cd /usr/local/
[103]$ ln -s mariadb-10.2.23-linux-x86_64/ mysql
- 创建环境变量
[103]$ echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[103]$ source /etc/profile.d/mysql.sh
- 初始化数据库
#依赖这个包
[103]$ yum -y install libaio
[103]$ cd mysql/
[103]$ scripts/mysql_install_db --datadir=/data/mysql --user=mysql
- 复制模版配置文件
[103]$ mkdir /etc/mysql/
[103]$ cp support-files/my-huge.cnf /etc/mysql/my.cnf
- 修改配置
[103]$ vim /etc/mysql/my.cnf
#加三行
[mysqld]
datadir =/data/mysql
innodb_file_per_table = ON
skip_name_resolve = ON
- 启动mysql
[103]$ cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
[103]$ chkconfig --add mysqld
[103]$ service mysqld start
- 在mysql创建2个数据库和2个帐号备用
[103]$ mysql
MariaDB [(none)]> create database wordpress;
MariaDB [(none)]> create database discuz;
MariaDB [(none)]> grant all on wordpress.* to wordpress@'%' identified by '123';
MariaDB [(none)]> grant all on discuz.* to discuz@'%' identified by '123';
编译安装httpd-2.4.39
1. 准备源码安装Apache的包 ```sh [101]$ wget ftp://192.168.99.1/Magedu37/files/lamp/apr-1.7.0.tar.bz2 [101]$ wget ftp://192.168.99.1/Magedu37/files/lamp/apr-util-1.6.1.tar.bz2 [101]$ wget ftp://192.168.99.1/Magedu37/files/lamp/httpd-2.4.39.tar.bz2 ```
- 安装编译环境
[101]$ yum install gcc pcre-devel openssl-devel expat-devel autoconf libtool gcc-c++
- 解压
[101]$ tar xf apr-util-1.6.1.tar.bz2
[101]$ tar xf apr-1.7.0.tar.bz2
[101]$ tar xf httpd-2.4.39.tar.bz2
- 复制到httpd下,一起编译
[101]$ cp -r apr-1.7.0 httpd-2.4.39/srclib/apr
[101]$ cp -r apr-util-1.6.1 httpd-2.4.39/srclib/apr-util
- 编译
[101]$ cd httpd-2.4.39
[101]$ ./configure --prefix=/data/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
[101]$ make && make install
- 环境变量
[101]$ echo 'PATH=/data/httpd24/bin:$PATH' > /etc/profile.d/httpd24.sh
[101]$ source /etc/profile.d/httpd24.sh
#添加个用户
[101]$ useradd -r -s /sbin/nologin apache
- 编辑配置文件,注意行号
[101]$ vim /data/httpd24/conf/httpd.conf
120 LoadModule proxy_module modules/mod_proxy.so
...
124 LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
...
172 User apache
173 Group apache
...
260
261 DirectoryIndex index.php index.html
262
...
514 Include conf/extra/test.conf
- 编辑test.conf
1 listen 8001
2 listen 8002
3
4 servername blog.tt.com
5 documentroot /data/wordpress
6
7 require all granted
8
9 ProxyRequests off
10 ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/wordpress/$1
11
12
13
14 servername blog.tt.com
15 documentroot /data/discuz
16
17 require all granted
18
19 ProxyRequests off
20 ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/discuz/$1
21
- 创建文件备用
[101]$ mkdir /data/{wordpress,discuz}
- 设置systemctl启动
#先把原来的停了
[101]$ apachectl stop
- 新建脚本
[101]$ vim /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 = /data/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 wa
nt
# 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 g
ive
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true
[Install]
WantedBy=multi-user.target
- 这样就行了
systemctl start httpd24
CentOS7 fpm方式编译安装PHP
- 安装编译环境
yum -y install libxml2-devel bzip2-devel libmcrypt-devel
- 下载包
[101]$ wget https://www.php.net/distributions/php-7.3.5.tar.bz2
- 解压
[101]$ tar xvf php-7.3.5.tar.bz2
[101]$ cd php-7.3.5/
- 编译
[101]$ ./configure --prefix=/data/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
[101]$ make && make install
- 配置启动文件
[101]$ cp php.ini-production /data/php/etc/php.ini
#把fpm脚本复制到init.d下
[101]$ cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[101]$ chmod +x /etc/init.d/php-fpm
- 添加到chkconfig
[101]$ chkconfig --add php-fpm
[101]$ chkconfig php-fpm on
- 创建个php测试主页
vim /data/httpd24/htdocs/index.php
- 修改下httpd的配置,让其支持php
vim /data/httpd24/conf/httpd.conf
#最后行
514 AddType application/x-httpd-php .php
515 AddType application/x-httpd-php-source .phps
516 Include conf/extra/test.conf
可以用电脑测试下
- 继续配置fpm
[101]$ cd /data/php/etc
[101]$ cp php-fpm.conf.default php-fpm.conf
[101]$ cp php-fpm.d/www.conf.default php-fpm.d/www.conf
- 修改下
[101]$ vim php-fpm.d/www.conf
23 user = apache
24 group = apache
- 启动
[101]$ service php-fpm start
安装wordpress 和 discuz
- 解压wordpress和discuz
[101]$ tar xf wordpress-5.2.2.tar.gz
[101]$ unzip Discuz_X3.3_SC_UTF8.zip
- 移动到指定的目录
[101]$ mv upload/* /data/discuz/
[101]$ chown -R apache.apache /data/discuz
[101]$ mv wordpress/* /data/wordpress/
[101]$ chown -R apache.apache /data/wordpress
准备台图形界面
- 设置下hosts文件
[110]$ vim /etc/hosts
192.168.99.101 blog.tt.com bbs.tt.com
- 打开浏览器试试吧