Published: 05 Sept 2017 › Updated: 05 Sept 2017
CentOS7安装PHP7与Nginx之PHP-FPM模式
采用yum安装PHP7.1.6Released版
1、添加PHP管理软件包的安装源
CentOS/RHEL 7.x安装源:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpmCentOS/RHEL 6.x安装源:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm2、 mod_php安装模式
yum install mod_php71w php71w-opcache php71w-common php71w-mysqlnd php71w-pdo php71w-pecl-imagickphp-fpm安装模式(现在一般选这个)
yum install php71w-fpm php71w-opcache php71w-common php71w-mysqlnd php71w-pdo php71w-pecl-imagick3、安装其他插件包
| Package | Provides |
|---|---|
| mod_php71w | php71w, mod_php, php71w-zts |
| php71w-bcmath | |
| php71w-cli | php-cgi, php-pcntl, php-readline |
| php71w-common | php-api, php-bz2, php-calendar, php-ctype, php-curl, php-date, php-exif, php-fileinfo, php-filter, php-ftp, php-gettext, php-gmp, php-hash, php-iconv, php-json, php-libxml, php-openssl, php-pcre, php-pecl-Fileinfo, php-pecl-phar, php-pecl-zip, php-reflection, php-session, php-shmop, php-simplexml, php-sockets, php-spl, php-tokenizer, php-zend-abi, php-zip, php-zlib |
| php71w-dba | |
| php71w-devel | |
| php71w-embedded | php-embedded-devel |
| php71w-enchant | |
| php71w-fpm | |
| php71w-gd | |
| php71w-imap | |
| php71w-interbase | php_database, php-firebird |
| php71w-intl | |
| php71w-ldap | |
| php71w-mbstring | |
| php71w-mcrypt | |
| php71w-mysql | php-mysqli, php_database |
| php71w-mysqlnd | php-mysqli, php_database |
| php71w-odbc | php-pdo_odbc, php_database |
| php71w-opcache | php71w-pecl-zendopcache |
| php71w-pdo | php71w-pdo_sqlite, php71w-sqlite3 |
| php71w-pdo_dblib | php71w-mssql |
| php71w-pear | |
| php71w-pecl-apcu | |
| php71w-pecl-imagick | |
| php71w-pecl-memcached | |
| php71w-pecl-mongodb | |
| php71w-pecl-redis | |
| php71w-pecl-xdebug | |
| php71w-pgsql | php-pdo_pgsql, php_database |
| php71w-phpdbg | |
| php71w-process | php-posix, php-sysvmsg, php-sysvsem, php-sysvshm |
| php71w-pspell | |
| php71w-recode | |
| php71w-snmp | |
| php71w-soap | |
| php71w-tidy | |
| php71w-xml | php-dom, php-domxml, php-wddx, php-xsl |
| php71w-xmlrpc |
systemctl start php-fpm5、对应配置文件路径如下
/etc/php-fpm.conf /etc/php.ini
6、安装nginx源 CentOS/RHEL 7.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm7、安装nginx
yum install nginx8、启动nginx
systemctl start nginx9、NGINX配置文件地址如下
/etc/nginx/nginx.conf10、NGINX整合PHP-FPM,按照如下格式修改nginx server节点。
#增加权限 否则报错
chmod +777 /var/run/php-fpm/php-fpm.sock
root /usr/share/nginx/html/;#PHP文件存放目录
location / {
index index.php index.html;
try_files $uri $uri/ /index.php?$args;
}
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;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
include fastcgi_params;
}
11、重新启动nginx
systemctl restart nginx
Leave CentOS7安装PHP7与Nginx之PHP-FPM模式 to:
Read more #centos7 posts
Best Posts From flying8
We have not curated any of flying8's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.