0
点赞
收藏
分享

微信扫一扫

无脑安装一个PHP环境(指定PHP版本,包含swoole,mysql,redis,nginx)

mm_tang 2022-04-18 阅读 129

标题

安装php

##准备用来安装php的必备软件
yum install epel-release remi-release -y
yum whatprovides yum-config-manager
yum install yum-utils -y

指定php版本,不指定则为默认5.4

下载镜像源	
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
查看可安装版本
yum repolist all | grep php
选择自己想要的,比如7.4
yum-config-manager --enable remi-php74
yum install php
安装php扩展示范:opcache
yum php-opcache

常用php扩展

yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel php-redis

安装composer

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
chmod -R 777 /usr/local/bin/composer
composer -v

安装swoole4

安装必备扩展
yum -y install php-cli php-fpm php-common
安装工具
yum -y install php-devel
yum -y install php-pear
安装pecl
yum install php-pear
#pecl search key-word    #查找扩展
#pecl install key-word   #安装扩展
安装swoole
pecl install swoole

配置swoole

vim /etc/php.ini
最后面添加 extension=swoole.so

安装nginx

yum install nginx

安装redis

yum install -y gcc
wget http://download.redis.io/releases/redis-5.0.3.tar.gz
tar -zxvf redis-5.0.3.tar.gz
cd redis-5.0.3
make
make install PREFIX=/usr/local/redis

前台启动

cd /usr/local/redis/bin/
./redis-server

后台启动

#从 redis 的源码目录中复制 redis.conf 到 redis 的安装目录
cp /usr/local/redis-5.0.3/redis.conf /usr/local/redis/bin/
#修改 redis.conf 文件,把 daemonize no 改为 daemonize yes
vi redis.conf
 ./redis-server redis.conf

开机启动

 vi /etc/systemd/system/redis.service
[Unit]
Description=redis-server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
设置开机启动
systemctl daemon-reload
systemctl start redis.service
systemctl enable redis.service
ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis
服务操作命令
systemctl start redis.service   #启动redis服务
systemctl stop redis.service   #停止redis服务
systemctl restart redis.service   #重新启动服务
systemctl status redis.service   #查看服务当前状态
systemctl enable redis.service   #设置开机自启动
systemctl disable redis.service   #停止开机自启动
举报

相关推荐

0 条评论