安裝源配置
1.下載 epel 安裝源
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
- 安裝 epel 安裝源
rpm -Uvh epel-release-latest-7.noarch.rpm
2.安裝 webtatic 安裝源
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
3.更新yum緩存
yum makecache fast
安裝PHP7及相關(guān)插件
1.查看yum源是否能搜索到PHP7
yum list | php7
2.安裝php7及相關(guān)插件
yum install --enablerepo=webtatic-testing php71w-fpm php71w-opcache php71w-cli php71w-gd php71w-imap php71w-mysqlnd php71w-mbstring php71w-mcrypt php71w-pdo php71w-pecl-apcu php71w-pecl-mongodb php71w-pecl-redis php71w-pgsql php71w-xml php71w-xmlrpc php71w-devel mod_php71w
驗證是否安裝成功
1.查看PHP版本
php -v
2.查看PHP安裝的插件
php -m
配置PHP-FPM(以socket方式)
- vi /etc/php-fpm.d/www.conf
將listen = 127.0.0.1:9000改為:
listen = /var/run/php-fpm/php-fpm.sock
3.啟動php-fpm
systemctl start php-fpm
4.查看啟動是否成功
ps -ef | grep php-fpm
安裝以及配置nginx
1.安裝nginx
yum install -y nginx
2.驗證nginx是否安裝成功
nginx -v
3.整合nginx和php-fpm
vi /etc/nginx/nginx.conf
添加以下內(nèi)容
location ~ .php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
4.重啟nginx
systemctl restart nginx
6
以PHP-FPM方式運行PHP7
1.新建個php文件
touch /usr/share/nginx/html/info.php
2.添加以下內(nèi)容:
<?php
phpinfo();
3.瀏覽器輸入地址 http://127.0.0.1/info.php
看到輸出內(nèi)容表示運行成功愕把。