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.rpm

CentOS/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.rpm

2、
[subscribe]mod_php安装模式

yum install mod_php71w php71w-opcache php71w-pecl-apcu php71w-common php71w-mysqlnd php71w-pdo php71w-pecl-imagick

php-fpm安装模式(现在一般选这个)

yum install php71w-fpm php71w-opcache php71w-pecl-apcu php71w-common php71w-mysqlnd php71w-pdo php71w-pecl-imagick

[/subscribe]
3、安装其他插件包

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

4、启动php-fpm(默认端口9000)

systemctl start php-fpm

5、对应配置文件路径如下

/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.rpm

7、安装nginx

yum install nginx

8、启动nginx

systemctl start nginx

9、NGINX配置文件地址如下

/etc/nginx/nginx.conf

10、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
打赏
         

flying

   

码农

发表评论

电子邮件地址不会被公开。 必填项已用*标注