centos7.9 阿里云服务器环境安装日志

PHP环境安装

sudo yum install -y epel-release
sudo yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm

运行以下命令,启用PHP 版本对应的仓库。例如56


sudo yum install -y yum-utils
sudo yum-config-manager --enable remi-php56
安装php
sudo yum install -y php php-cli php-pgsql php-fpm php--pgsql php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-xmlreader


安装redis扩展
wget https://github.com/nicolasff/phpredis/archive/2.2.8.tar.gz
mv 2.2.8.tar.gz redis-2.2.8.tar.gz
tar xvzf redis-2.2.8.tar.gz
cd phpredis-2.2.8
/usr/bin/phpize
./configure --with-php-config=/usr/bin/php-config
make
 make install

安装完成之后,会出现nstalling shared extensions: /usr/lib64/php/modules/
vim etc/php.ini
添加extension=redis.so 到/etc/php.d/的目录下redis.ini



安装mongo扩展
yum install openssl-devel
下载PHP-mongodb扩展
(https://pecl.php.net/package/mongo)

wget http://pecl.php.net/get/mongo-1.6.12.tgz
tar xvzf mongo-1.6.12.tgz
cd mongo-1.6.12
phpize
./configure --with-php-config=/usr/bin/php-config
make && make install

在安装过程中可能会报以下错误
/var/tmp/mongo/contrib/php-ssl.h:33:25: error: openssl/evp.h: No such file or directory

需要安装openssl-devel
yum install openssl-devel

在php.ini文件中添加extension=mongo.so
extension=mongo.so

参考链接:https://help.aliyun.com/zh/ecs/use-cases/manually-build-an-lnmp-environment-on-a-centos-instance?spm=5176.2020520104.console-base_help.dexternal.60b643ecYEoYrX#095b2f6d35yoo

评论已关闭。