12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml

部署 LNMP 架构需要安装依赖包

[root@ZhouShuai ~]# yum -y install make gcc gcc-c++ flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel gd freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel gettext gettext-devel ncurses-devel gmp-devel unzip libcap lsof

安装 epel 扩展 yum 源

[root@ZhouShuai ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@ZhouShuai ~]# yum clean all
[root@ZhouShuai ~]# yum list

一、安装并配置Nginx

所需依赖包

[root@ZhouShuai ~]# yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre*
zlib:Nginx 提供 gzip 模块,需要 zlib 的支持
openssl:Nginx 提供 SSL 的功能

另外:需要在安装 Nginx 需要用到 pcre 程序,因此需要下载 pcre 程序包

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz

注:解压即可,不用安装,Nginx 安装时指定 pcre 的解压路径即可

[root@ZhouShuai ~]# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz
[root@ZhouShuai ~]# tar zxvf pcre-8.41.tar.gz -C /usr/local/src/
[root@ZhouShuai ~]# ls /usr/local/src/
pcre-8.41
[root@ZhouShuai ~]# 

创建 Nginx 运行用户

[root@ZhouShuai ~]# useradd -M -s /sbin/nologin nginx
[root@ZhouShuai ~]#  tail -1 /etc/passwd
nginx:x:1001:1001::/home/nginx:/sbin/nologin
[root@ZhouShuai ~]# 

下载安装Nginx

[root@ZhouShuai ~]# wget http://nginx.org/download/nginx-1.16.0.tar.gz
[root@ZhouShuai ~]# tar zxf nginx-1.16.0.tar.gz -C /usr/local/src
[root@ZhouShuai ~]# cd  /usr/local/src/
[root@ZhouShuai src]# ll
total 12
drwxr-xr-x 8 nginx nginx  158 Apr 23 21:13 nginx-1.16.0
drwxr-xr-x 7  1169  1169 8192 Jul  5  2017 pcre-8.41
[root@ZhouShuai src]# cd /usr/local/src/nginx-1.16.0/
[root@ZhouShuai nginx-1.16.0]# 
[root@ZhouShuai nginx-1.16.0]# ./configure --prefix=/usr/local/nginx --with-http_dav_module --with-http_stub_status_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.41 --user=nginx --group=nginx
[root@ZhouShuai nginx-1.16.0]# make -j 4 && make install
[root@ZhouShuai nginx-1.16.0]# echo $?

[root@ZhouShuai nginx-1.16.0]# ll /usr/local/nginx/
total 0
drwxr-xr-x 2 root root 333 Jun 26 13:21 conf
drwxr-xr-x 2 root root  40 Jun 26 13:21 html
drwxr-xr-x 2 root root   6 Jun 26 13:21 logs
drwxr-xr-x 2 root root  19 Jun 26 13:21 sbin
[root@ZhouShuai nginx-1.16.0]# 

配置 Nginx 支持 php 文件

[root@ZhouShuai nginx-1.16.0]# cp /usr/local/nginx/conf/nginx.conf{,.bak}
[root@ZhouShuai nginx-1.16.0]# ls /usr/local/nginx/conf/
fastcgi.conf          fastcgi_params.default  mime.types          nginx.conf.bak      scgi_params.default   win-utf
fastcgi.conf.default  koi-utf                 mime.types.default  nginx.conf.default  uwsgi_params
fastcgi_params        koi-win                 nginx.conf          scgi_params         uwsgi_params.default
[root@ZhouShuai nginx-1.16.0]# vim /usr/local/nginx/conf/nginx.conf

修改用户为 nginx:

启用 PHP 支持

        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
        #   fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml_第1张图片

12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml_第2张图片

启动 Nginx 服务

[root@ZhouShuai nginx-1.16.0]#  /usr/local/nginx/sbin/nginx

编辑配置环境变量,让系统读到 Nginx 路径

[root@ZhouShuai nginx-1.16.0]# vim /etc/profile.d/nginx.sh
export PATH=usr/local/nginx/sbin/nginx:$PATH

[root@ZhouShuai nginx-1.16.0]# . /etc/profile.d/nginx.sh
[root@ZhouShuai ~]# nginx
ngettext  nginx     

使用软连接也可以

[root@ZhouShuai html]#  ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
[root@ZhouShuai html]# nginx -s reload
12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml_第3张图片

生成服务启动脚本

[root@ZhouShuai ~]# vim /etc/init.d/nginx
#!/bin/bash
# chkconfig: - 99 2
# description: Nginx Service Control Script
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.pid"
case "$1" in
        start)
        $PROG
        ;;
        stop)
        kill -3 $(cat $PIDF)
        ;;
        restart)
        $0 stop &> /dev/null
        if [ $? -ne 0 ] ; then continue ; fi
        $0 start
        ;;
        reload)
        kill -1 $(cat $PIDF)
        ;;
        *)
        echo "Userage: $0 { start | stop | restart | reload }"
        exit 1
esac
exit 0

>####配置服务开机自动启动
[root@ZhouShuai ~]# chmod +x /etc/init.d/nginx
[root@ZhouShuai ~]# chkconfig --add nginx
[root@ZhouShuai ~]# chkconfig nginx on
[root@ZhouShuai ~]# 

先关闭iptables 在浏览器访问验证:

12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml_第4张图片

Nginx维护 相关命令

[root@ZhouShuai ~]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@ZhouShuai ~]# nginx -v
nginx version: nginx/1.16.0
[root@ZhouShuai ~]# nginx -V
nginx version: nginx/1.16.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_dav_module --with-http_stub_status_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.41 --user=nginx --group=nginx
[root@ZhouShuai ~]# nginx -s reload
[root@ZhouShuai ~]# 

二、安装并配置 MySQL

1. MySQL从5.7版本之后,boost是必须的,建议把系统自带的boost库卸载,源码编译安装高版本

[root@ZhouShuai ~]# yum -y remove boost-*

卸载系统自带的mysql

[root@ZhouShuai ~]# yum -y remove mysql mariadb-*

2. 安装依赖包

[root@ZhouShuai ~]# yum install -y cmake make gcc gcc-c++ bison ncurses ncurses-devel

3. 添加用户和组

[root@ZhouShuai ~]#  groupadd mysql
[root@ZhouShuai ~]# useradd -M -s /sbin/nologin -r -g mysql mysql
[root@ZhouShuai ~]# 
12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml_第5张图片

mysql-5.7.26程序包下载

[root@ZhouShuai ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26.tar.gz
[root@ZhouShuai ~]# wget http://liquidtelecom.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
#带boost的mysql源码
[root@ZhouShuai ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.26.tar.gz
[root@ZhouShuai ~]# 

4. 解压源码包

[root@ZhouShuai ~]#  tar xf mysql-5.7.26.tar.gz -C /usr/local/src/
[root@ZhouShuai ~]# tar xf boost_1_59_0.tar.gz -C /usr/local/src/
[root@ZhouShuai ~]# cd /usr/local/src/mysql-5.7.26/

5. 规划安装目录:

安装目录: /var/lib/mysql
数据目录: /var/lib/mysql/data

[root@ZhouShuai mysql-5.7.26]# mkdir -p /var/lib/mysql/data
[root@ZhouShuai mysql-5.7.26]# chown -R mysql:mysql /var/lib/mysql
[root@ZhouShuai mysql-5.7.26]# 

6. 编译安装:

[root@ZhouShuai mysql-5.7.26]# cmake -DCMAKE_INSTALL_PREFIX=/var/lib/mysql  -DMYSQL_DATADIR=/var/lib/mysql/data  -DSYSCONFDIR=/etc  -DWITH_MYISAM_STORAGE_ENGINE=1  -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWITH_MEMORY_STORAGE_ENGINE=1  -DWITH_READLINE=1  -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock  -DMYSQL_TCP_PORT=3306  -DENABLED_LOCAL_INFILE=1  -DWITH_PARTITION_STORAGE_ENGINE=1  -DEXTRA_CHARSETS=all  -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci  -DDOWNLOAD_BOOST=1  -DWITH_BOOST=/usr/local/src/boost_1_59_0

编译参数的帮助寻找方法(官方):
http://www.mysql.com → Documentation → MySQL Server MySQL栏的 Reference Manual (选择对应的版本5.7(MySQL 5.7 Reference Manual))→ Installation and Upgrades MySQL → Installing MySQL from Source → MySQL Source-Configuration Options。
**最终的URL是 https://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html **

7. 编译

mysql-5.7.19编译时会占用大量的系统资源,建议使用多个核心同时进行编译,否则可能会编译失败

[root@ZhouShuai mysql-5.7.26]# make -j 4
make -j 4   #注:-j 用来指定CPU核心数,可加快编译速度。 加 -j 4我用4核心来编译的,可以提高编译速度;当然你要确定CPU多少核心
[root@ZhouShuai mysql-5.7.26]# make
[root@ZhouShuai mysql-5.7.26]# echo $?
0

8. 安装

[root@ZhouShuai mysql-5.7.26]# make install
[root@ZhouShuai mysql-5.7.26]# echo $?
0

9. 编辑配置文件

[root@ZhouShuai ~]# vim /etc/my.cnf
[mysqld]
basedir=/var/lib/mysql
datadir=/var/lib/mysql/data
port=3306
socket=/var/lib/mysql/mysql.sock
character-set-server=utf8
log-error=/var/log/mysqld.log
pid-file=/tmp/mysqld.pid
[mysql]
socket=/var/lib/mysql/mysql.sock
[client]
socket=/var/lib/mysql/mysql.sock

10. 添加path路径,让系统能读到mysql的命令:

[root@ZhouShuai ~]# vim /etc/profile.d/mysql.sh
export PATH=/var/lib/mysql/bin:$PATH

11. 使修改生效

[root@ZhouShuai ~]# . /etc/profile.d/mysql.sh
[root@ZhouShuai ~]# source /etc/profile.d/mysql.sh

12. 生成服务启动脚本

[root@ZhouShuai ~]# cp /var/lib/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@ZhouShuai ~]# chmod +x /etc/init.d/mysqld
[root@ZhouShuai ~]# chkconfig --add mysqld
[root@ZhouShuai ~]# chkconfig  mysqld  on

13. 初始化数据库

[root@ZhouShuai ~]# cd /var/lib/mysql/data/
[root@ZhouShuai data]# rm -rf ./*
[root@ZhouShuai data]# /var/lib/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/var/lib/mysql --datadir=/var/lib/mysql/data
[root@ZhouShuai data]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
[root@ZhouShuai data]# mysql
mysql> set password  for  root@localhost = password('123456');
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> 

14.安全初始化:

[root@ZhouShuai data]# mysql_secure_installation

15.增加一个新用户用于navicat远程连接

[root@ZhouShuai data]# mysql -uroot -p123456
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'zhoushuai'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION ;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> 

三、安装并配置PHP

1. 安装依赖关系

2. 解决依赖:yum安装解决

[root@ZhouShuai ~]# yum -y install php-mcrypt  libmcrypt  libmcrypt-devel php-pear libxml2 libxml2-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype-devel
[root@ZhouShuai ~]#yum -y install lrzsz

1.下载 官网地址:http://php.net/

[root@ZhouShuai ~]# wget https://www.php.net/distributions/php-7.3.6.tar.gz
[root@ZhouShuai ~]# tar xf php-7.3.6.tar.gz -C /usr/local/src
[root@ZhouShuai ~]# cd /usr/local/src/php-7.3.6/

2. php7.3-编译安装过程中碰到的3个错误

12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml_第6张图片

configure: error: Please reinstall the libzip distribution

#解决方法:
wget https://nih.at/libzip/libzip-1.2.0.tar.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make && make install

configure: error: off_t undefined; check your library configuration

#解决方法
vim /etc/ld.so.conf 
#添加如下几行
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64 
#保存退出
:wq
ldconfig -v # 使之生效
或者
#解决方法
# 添加搜索路径到配置文件
echo '/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64'>>/etc/ld.so.conf
# 更新配置
ldconfig -v

/usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or dire

#解决方法:手动复制过去
cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h

4. 编译并安装

[root@ZhouShuai php-7.3.6]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/ --enable-fpm  --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts

[root@ZhouShuai php-7.3.6]# make -j 4 
[root@ZhouShuai php-7.3.6]# make install

12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml_第7张图片

12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml_第8张图片

配置php和php-fpm

[root@ZhouShuai php-7.3.6]# cp /usr/local/src/php-7.3.6/php.ini-production /usr/local/php/php.ini #生成php自身配置文件
[root@ZhouShuai php-7.3.6]# php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/php/
Loaded Configuration File => /usr/local/php/php.ini
[root@ZhouShuai php-7.3.6]# 

[root@ZhouShuai php-7.3.6]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.conf #生成php-fpm配置文件
[root@ZhouShuai php-7.3.6]# 
PHP-FPM启动脚本
修改 /usr/local/php/etc/php-fpm.conf 运行用户和组改为nginx
[root@ZhouShuai php-7.3.6]# vim /usr/local/php/etc/php-fpm.conf
 user = nginx
 group = nginx
12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml_第9张图片
[root@ZhouShuai php-7.3.6]# cp /usr/local/src/php-7.3.6/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm  #生成php-fpm启动脚本
[root@ZhouShuai php-7.3.6]# chmod +x /etc/init.d/php-fpm
[root@ZhouShuai php-7.3.6]# chkconfig php-fpm on
[root@ZhouShuai php-7.3.6]# /etc/init.d/php-fpm start
Starting php-fpm  done

#检测PHP-FPM启动成功与否
[root@ZhouShuai php-7.3.6]# netstat -antup | grep php-fpm
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      130020/php-fpm: mas 
[root@ZhouShuai php-7.3.6]# echo "" > /usr/local/nginx/html/index.php
[root@ZhouShuai php-7.3.6]# 
[root@ZhouShuai ~]# ln -s /usr/local/php/bin/php /usr/local/bin/php
12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml_第10张图片
安装完成

三、redis模块安装http://pecl.php.net/package/redis

[root@ZhouShuai ~]# wget http://pecl.php.net/get/redis-4.3.0.tgz
[root@ZhouShuai ~]#  tar xf redis-4.3.0.tgz -C /usr/local/src
[root@ZhouShuai ~]# cd /usr/local/src/redis-4.3.0/
[root@ZhouShuai redis-4.3.0]# 
[root@ZhouShuai redis-4.3.0]# /usr/local/php/bin/phpize 
Configuring for:
PHP Api Version:         20180731
Zend Module Api No:      20180731
Zend Extension Api No:   320180731
[root@ZhouShuai redis-4.3.0]# ./configure --with-php-config=/usr/local/php/bin/php-config
Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20180731/
[root@ZhouShuai redis-4.3.0]# php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/php/
Loaded Configuration File => /usr/local/php/php.ini
[root@ZhouShuai redis-4.3.0]# 
[root@ZhouShuai redis-4.3.0]# vim /usr/local/php/php.ini
extension=redis.so

[root@ZhouShuai redis-4.3.0]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done
[root@ZhouShuai redis-4.3.0]# 

12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml_第11张图片

四、 memcached 模块安装http://pecl.php.net/package/memcached

[root@ZhouShuai ~]# wget http://pecl.php.net/get/memcached-3.1.3.tgz
[root@ZhouShuai ~]# tar zxvf memcached-3.1.3.tgz -C /usr/local/src
[root@ZhouShuai ~]# cd /usr/local/src/memcached-3.1.3/
[root@ZhouShuai memcached-3.1.3]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:         20180731
Zend Module Api No:      20180731
Zend Extension Api No:   320180731
[root@ZhouShuai memcached-3.1.3]# 
[root@ZhouShuai memcached-3.1.3]# yum -y install libmemcached libmemcached-devel
[root@ZhouShuai memcached-3.1.3]#  ./configure --with-php-config=/usr/local/php/bin/php-config
[root@ZhouShuai memcached-3.1.3]# make && make install
Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20180731/
[root@ZhouShuai memcached-3.1.3]# echo $?
0
[root@ZhouShuai redis-4.3.0]# vim /usr/local/php/php.ini
extension=memcached.so
[root@ZhouShuai memcached-3.1.3]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done
[root@ZhouShuai memcached-3.1.3]# 
12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml_第12张图片

五、Swoole模块安装https://www.swoole.com/

[root@ZhouShuai ~]# wget https://github.com/swoole/swoole-src/archive/v4.3.5.tar.gz
[root@ZhouShuai ~]# tar zxvf v4.3.5.tar.gz -C /usr/local/src
[root@ZhouShuai ~]# cd /usr/local/src/swoole-src-4.3.5/
[root@ZhouShuai swoole-src-4.3.5]# yum install -y autoconf
[root@ZhouShuai swoole-src-4.3.5]# /usr/local/php/bin/phpize 
Configuring for:
PHP Api Version:         20180731
Zend Module Api No:      20180731
Zend Extension Api No:   320180731
[root@ZhouShuai swoole-src-4.3.5]# 
[root@ZhouShuai swoole-src-4.3.5]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@ZhouShuai swoole-src-4.3.5]#  make && make install
Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20180731/
Installing header files:          /usr/local/php/include/php/
[root@ZhouShuai swoole-src-4.3.5]# ls /usr/local/php/lib/php/extensions/no-debug-zts-20180731/
memcached.so  opcache.a  opcache.so  redis.so  swoole.so
[root@ZhouShuai swoole-src-4.3.5]# 
[root@ZhouShuai swoole-src-4.3.5]# vim /usr/local/php/php.ini
extension=swoole
[root@ZhouShuai swoole-src-4.3.5]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done
[root@ZhouShuai swoole-src-4.3.5]# 

[root@ZhouShuai swoole-src-4.3.5]# php --ri swoole

swoole

Swoole => enabled
Author => Swoole Team 
Version => 4.3.5
Built => Jun 26 2019 18:46:30
coroutine => enabled
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
http2 => enabled
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608
[root@ZhouShuai swoole-src-4.3.5]# 

12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml_第13张图片

六、Composer安装

阿里云 Composer 全量镜像

[root@ZhouShuai ~]# curl -sS https://getcomposer.org/installer | php
[root@ZhouShuai ~]# mv composer.phar /usr/local/bin/composer
[root@ZhouShuai ~]# 
[root@ZhouShuai ~]# composer config -g repo.packagist composer https://packagist.phpcomposer.com
[root@ZhouShuai ~]# composer config -g repo.packagist composer https://packagist.laravel-china.org
12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml_第14张图片

七、 Yaconf – 一个高性能的配置管理扩展

[root@ZhouShuai ~]# git clone https://github.com/laruence/yaconf.git
[root@ZhouShuai ~]# cd yaconf/
[root@ZhouShuai yaconf]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:         20180731
Zend Module Api No:      20180731
Zend Extension Api No:   320180731
[root@ZhouShuai yaconf]# 
[root@ZhouShuai yaconf]#  ./configure --with-php-config=/usr/local/php/bin/php-config
[root@ZhouShuai yaconf]# make 
Build complete.
Don't forget to run 'make test'.
[root@ZhouShuai yaconf]# make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20180731/
Installing header files:          /usr/local/php/include/php/
[root@ZhouShuai yaconf]# ls  /usr/local/php/lib/php/extensions/no-debug-zts-20180731/
memcached.so  opcache.a  opcache.so  redis.so  swoole.so  yaconf.so
[root@ZhouShuai yaconf]# vim /usr/local/php/php.ini
[Yaconf]
extension=yaconf.so 
yaconf.directory=/home/swooleApp/ini
yaconf.check_delay=100 
[root@ZhouShuai yaconf]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done
[root@ZhouShuai yaconf]# 
12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml_第15张图片

Kafka[高吞吐量的分布式发布订阅消息系统]

https://github.com/edenhill/librdkafka
https://github.com/arnaud-lb/php-rdkafka
https://arnaud.le-blanc.net/php-rdkafka/phpdoc/rdkafka.installation.manual.html

#一、安装librdkafka
[root@ZhouShuai ~]# cd /usr/local/src/
[root@ZhouShuai src]# git clone https://github.com/edenhill/librdkafka.git
[root@ZhouShuai src]# cd librdkafka/
[root@ZhouShuai librdkafka]# ./configure
[root@ZhouShuai librdkafka]# make
[root@ZhouShuai librdkafka]# make install
[root@ZhouShuai librdkafka]# ln -s /usr/local/lib/librdkafka.so.1 /usr/lib/

#二、安装php-rdkafka
[root@ZhouShuai ~]# cd /usr/local/src/
[root@ZhouShuai src]# git clone https://github.com/arnaud-lb/php-rdkafka.git
[root@ZhouShuai src]# cd php-rdkafka
[root@ZhouShuai php-rdkafka]# /usr/local/php/bin/phpize 
Configuring for:
PHP Api Version:         20180731
Zend Module Api No:      20180731
Zend Extension Api No:   320180731
[root@ZhouShuai php-rdkafka]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@ZhouShuai php-rdkafka]# make all -j 5
[root@ZhouShuai php-rdkafka]# make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20180731/
[root@ZhouShuai php-rdkafka]# ls /usr/local/php/lib/php/extensions/no-debug-zts-20180731/
ldap.so  memcached.so  opcache.a  opcache.so  rdkafka.so  redis.so  swoole.so  yaconf.so
[root@ZhouShuai php-rdkafka]# 

#三、修改php.ini
[root@ZhouShuai php-rdkafka]# vim /usr/local/php/php.ini
extension=rdkafka.so
[root@ZhouShuai php-rdkafka]# /usr/local/php/bin/php  -m | grep rdk
rdkafka

#四、重启php-fpm
[root@ZhouShuai php-rdkafka]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done
[root@ZhouShuai php-rdkafka]# 
12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml_第16张图片

12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml_第17张图片

Yar 是一个轻量级, 高效的RPC框架

它提供了一种简单方法来让PHP项目之间可以互相远程调用对方的本地方法. 并且Yar也提供了并行调用的能力. 可以支持同时调用多个远程服务的方法.


ZooKeeper

Apache ZooKeeper is an effort to develop and maintain an open-source server which enables highly reliable distributed coordination.


Yaml

YAML-1.1 parser and emitter

你可能感兴趣的:(12.CentOS7.5源码编译搭建LNMP架构+Swoole+Composer+Yaconf+Kafka+Yar+ZooKeeper+Yaml)