PHP7.2 、git、swoole安装

一、安装php

1.安装gcc

yum -y install gcc gcc-c++

2.安装一些库

1 yum -y install php-mcrypt libmcrypt-devel libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel 
libpng-devel freetype-devel libmcrypt-devel

3、下载php

http://cn2.php.net/distributions/php-7.2.4.tar.gz

4、配置参数

./configure --prefix=/usr/local/php7 
--with-config-file-path=/usr/local/php7/etc 
--with-mysqli=mysqlnd 
--with-pdo-mysql=mysqlnd 
--with-mysql-sock=/tmp/mysql.sock 
--enable-mysqlnd 
--with-gd 
--with-iconv 
--with-zlib 
--enable-bcmath 
--enable-shmop 
--enable-sysvsem 
--enable-inline-optimization 
--enable-mbregex 
--enable-fpm 
--enable-mbstring 
--enable-ftp 
--with-openssl 
--enable-pcntl 
--enable-sockets 
--with-xmlrpc 
--enable-zip 
--enable-soap 
--with-gettext 
--with-curl 
--with-jpeg-dir 
--with-freetype-dir

5、编译

make
mkae install

6、配置php

cp php.ini-development /usr/local/php7/etc/php.ini

7、加入

vim /usr/local/php7/etc/php.ini
zend_extension=/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/opcache.so

复制php-fpm.conf

cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf

编辑php-fpm.conf,把pid 改成 /run/php-fpm.pid

vim /usr/local/php7/etc/php-fpm.conf
pid = /run/php-fpm.pid

编辑php-fpm配置www.conf会加载在php-fpm.conf

cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf

加php-fpm管理器到systemctl中

vim /usr/lib/systemd/system/php-fpm.service

按i写入以下内容

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=simple
PIDFile=/run/php-fpm.pid
ExecStart=/usr/local/php7/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php7/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID

[Install]
WantedBy=multi-user.target

启动php-fpm

systemctl start php-fpm.service

添加到开机启动

systemctl enable php-fpm.service

下机为systemctl指令
systemctl enable *.service #开机运行服务
systemctl disable *.service #取消开机运行
systemctl start *.service #启动服务
systemctl stop *.service #停止服务
systemctl restart *.service #重启服务
systemctl reload *.service #重新加载服务配置文件
systemctl status *.service #查询服务运行状态
systemctl --failed #显示启动失败的服务

修改 php.ini 文件 设置 expose_php = Off
vim /usr/local/php7/etc/php.ini
找到 expose_php = On
改为 expose_php = Off

二、安装git

1.安装依赖

yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker autoconf

2、下载

wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz

3、解压

tar zxvf git-2.9.5.tar.gz 

4、配置参数

cd git-2.9.5/
./configure prefix=/usr/local/git/

5、编译安装

make
make install

6、编辑profile文件,并在最后一行添加export PATH=$PATH:/usr/local/git/bin

vi /etc/profile
export PATH=$PATH:/usr/local/git/bin

7、刷新文件

source /etc/profile

三、swoole安装

1、下载swoole

git clone https://gitee.com/swoole/swoole.git

2、扩展模块

/usr/local/php7/bin/phpize

3、配置参数

./configure --with-php-config=/usr/local/php7/bin/php-config

4、编译安装

make
make install

5、编辑php.ini添加swoole(大约在900行左右)

vi php.ini
extension=swoole

6、重启 php

systemctl restart php-fpm.service

7、查看是否添加swoole模块

php -m

8、测试

cd /usr/local/src/swoole/examples/server
php echo.php
netstat -anp|grep 9501
原文地址:https://www.cnblogs.com/xb88/p/8830640.html