二维码

centos8之php安装

1795 人阅读 | 时间:2019年10月25日 14:35

环境:CentOS 7.4.1708

一、检查当前系统是否已经安装PHP

1
[root@localhost ~]# rpm -qa php

二、查看yum是否有可安装的PHP软件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[root@localhost ~]# yum list | grep php
emacs-php-mode.noarch                       1.18.2-1.el7               base    
graphviz-php.x86_64                         2.30.1-21.el7              base    
php.x86_64                                  5.4.16-45.el7              base    
php-bcmath.x86_64                           5.4.16-45.el7              base    
php-cli.x86_64                              5.4.16-45.el7              base    
php-common.x86_64                           5.4.16-45.el7              base    
php-dba.x86_64                              5.4.16-45.el7              base    
php-devel.x86_64                            5.4.16-45.el7              base    
php-embedded.x86_64                         5.4.16-45.el7              base    
php-enchant.x86_64                          5.4.16-45.el7              base    
php-fpm.x86_64                              5.4.16-45.el7              base    
php-gd.x86_64                               5.4.16-45.el7              base    
php-intl.x86_64                             5.4.16-45.el7              base    
php-ldap.x86_64                             5.4.16-45.el7              base    
php-mbstring.x86_64                         5.4.16-45.el7              base    
php-mysql.x86_64                            5.4.16-45.el7              base    
php-mysqlnd.x86_64                          5.4.16-45.el7              base    
php-odbc.x86_64                             5.4.16-45.el7              base    
php-pdo.x86_64                              5.4.16-45.el7              base    
php-pear.noarch                             1:1.9.4-21.el7             base    
php-pecl-memcache.x86_64                    3.0.8-4.el7                base    
php-pgsql.x86_64                            5.4.16-45.el7              base    
php-process.x86_64                          5.4.16-45.el7              base    
php-pspell.x86_64                           5.4.16-45.el7              base    
php-recode.x86_64                           5.4.16-45.el7              base    
php-snmp.x86_64                             5.4.16-45.el7              base    
php-soap.x86_64                             5.4.16-45.el7              base    
php-xml.x86_64                              5.4.16-45.el7              base    
php-xmlrpc.x86_64                           5.4.16-45.el7              base    
rrdtool-php.x86_64                          1.4.8-9.el7                base    
uuid-php.x86_64                             1.6.2-26.el7
             base

三、安装PHP

1
[root@localhost ~]# yum -y install php

四、查看版本及支持的扩展

1
2
3
4
[root@localhost ~]# php -v
PHP 5.4.16 (cli) (built: Apr 12 2018 19:02:01)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
[root@localhost ~]# php -m 
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
ereg
exif
fileinfo
filter
ftp
gettext
gmp
hash
iconv
json
libxml
mhash
openssl
pcntl
pcre
Phar
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
standard
tokenizer
xml
zip
zlib
[Zend Modules]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@localhost ~]# ll /etc/php.d/
total 20
-rw-r--r-- 1 root root 49 Apr 12 15:04 curl.ini
-rw-r--r-- 1 root root 57 Apr 12 15:04 fileinfo.ini
-rw-r--r-- 1 root root 49 Apr 12 15:04 json.ini
-rw-r--r-- 1 root root 49 Apr 12 15:04 phar.ini
-rw-r--r-- 1 root root 47 Apr 12 15:04 zip.ini
[root@localhost ~]# ll /usr/lib64/php/modules/
total 3100
-rwxr-xr-x 1 root root   74776 Apr 12 15:04 curl.so
-rwxr-xr-x 1 root root 2713464 Apr 12 15:04 fileinfo.so
-rwxr-xr-x 1 root root   44784 Apr 12 15:04 json.so
-rwxr-xr-x 1 root root  272112 Apr 12 15:04 phar.so
-rwxr-xr-x 1 root root   58496 Apr 12 15:04 zip.so

五、安装php-mysqlnd

当前系统已安装的mysql版本是:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
[root@localhost ~]# rpm -qi mysql-community-server
Name        : mysql-community-server
Version     : 8.0.11
Release     : 1.el7
Architecture: x86_64
Install Date: Thu 17 May 2018 09:40:08 PM EDT
Group       : Applications/Databases
Size        : 1633523890
License     : Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Under GPLv2 license as shown in the Description field.
Signature   : DSA/SHA1, Sun 08 Apr 2018 01:07:21 PM EDT, Key ID 8c718d3b5072e1f5
Source RPM  : mysql-community-8.0.11-1.el7.src.rpm
Build Date  : Sun 08 Apr 2018 03:29:08 AM EDT
Build Host  : siv27.no.oracle.com
Relocations : (not relocatable)
Packager    : MySQL Release Engineering <mysql-build@oss.oracle.com>
Vendor      : Oracle and/or its affiliates
URL         : http://www.mysql.com/
Summary     : A very fast and reliable SQL database server
Description :
The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
and robust SQL (Structured Query Language) database server. MySQL Server
is intended for mission-critical, heavy-load production systems as well
as for embedding into mass-deployed software. MySQL is a trademark of
Oracle and/or its affiliates
The MySQL software has Dual Licensing, which means you can use the MySQL
software free of charge under the GNU General Public License
(http://www.gnu.org/licenses/). You can also purchase commercial MySQL
licenses from Oracle and/or its affiliates if you do not wish to be bound by the terms of
the GPL. See the chapter "Licensing and Support" in the manual for
further info.
The MySQL web site (http://www.mysql.com/) provides the latest news and
information about the MySQL software.  Also please see the documentation
and the manual for more information.
This package includes the MySQL server binary as well as related utilities
to run and administer a MySQL server.

安装php-mysqld插件

1
[root@localhost ~]# yum -y install php-mysqlnd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[root@localhost ~]# ll /etc/php.d/
total 48
-rw-r--r-- 1 root root 49 Apr 12 15:04 curl.ini
-rw-r--r-- 1 root root 57 Apr 12 15:04 fileinfo.ini
-rw-r--r-- 1 root root 49 Apr 12 15:04 json.ini
-rw-r--r-- 1 root root 55 Apr 12 15:04 mysqlnd.ini
-rw-r--r-- 1 root root 69 Apr 12 15:04 mysqlnd_mysqli.ini
-rw-r--r-- 1 root root 67 Apr 12 15:04 mysqlnd_mysql.ini
-rw-r--r-- 1 root root 47 Apr 12 15:04 pdo.ini
-rw-r--r-- 1 root root 63 Apr 12 15:04 pdo_mysqlnd.ini
-rw-r--r-- 1 root root 61 Apr 12 15:04 pdo_sqlite.ini
-rw-r--r-- 1 root root 49 Apr 12 15:04 phar.ini
-rw-r--r-- 1 root root 55 Apr 12 15:04 sqlite3.ini
-rw-r--r-- 1 root root 47 Apr 12 15:04 zip.ini
[root@localhost ~]# ll /usr/lib64/php/modules/ 
total 3772
-rwxr-xr-x 1 root root   74776 Apr 12 15:04 curl.so
-rwxr-xr-x 1 root root 2713464 Apr 12 15:04 fileinfo.so
-rwxr-xr-x 1 root root   44784 Apr 12 15:04 json.so
-rwxr-xr-x 1 root root  133224 Apr 12 15:04 mysqlnd_mysqli.so
-rwxr-xr-x 1 root root   53624 Apr 12 15:04 mysqlnd_mysql.so
-rwxr-xr-x 1 root root  256632 Apr 12 15:04 mysqlnd.so
-rwxr-xr-x 1 root root   28880 Apr 12 15:04 pdo_mysqlnd.so
-rwxr-xr-x 1 root root  116408 Apr 12 15:04 pdo.so
-rwxr-xr-x 1 root root   29240 Apr 12 15:04 pdo_sqlite.so
-rwxr-xr-x 1 root root  272112 Apr 12 15:04 phar.so
-rwxr-xr-x 1 root root   51472 Apr 12 15:04 sqlite3.so
-rwxr-xr-x 1 root root   58496 Apr 12 15:04 zip.so

要让PHP以FastCGI的方式与nginx进行交互,需要有PHP-FPM模块的支持。

 安装PHP-FPM

1
[root@localhost ~]# yum -y install php-fpm
1
2
3
4
[root@localhost ~]# php-fpm -v
PHP 5.4.16 (fpm-fcgi) (built: Apr 12 2018 19:03:25)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

启动PHP-FPM

1
[root@localhost ~]# systemctl start php-fpm
以上安装完成后,接下来,配置Nginx支持PHP(FastCGI方式)。

修改 /usr/local/nginx/conf/nginx.conf 把如下图红色框中的#去掉就可以了。

centos8之php安装

这里面都是默认的,root是配置php程序放置的根目录。

还需要修改的就是fastcgi_param中的/scripts为$document_root

 

centos8之php安装

修改完成后,让nginx重新加载配置以生效:

1
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s reload

测试

1
2
3
4
5
6
7
[root@localhost ~]# cd /usr/local/nginx/html/
[root@localhost html]# touch index.php
[root@localhost html]# vim index.php
[root@localhost html]# cat index.php
<?php 
phpinfo(); 
?>

centos8之php安装

分类: Linux


取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

©著作权归作者所有:来自ZhiKuGroup博客作者没文化的原创作品,如需转载,请注明出处,否则将追究法律责任 来源:ZhiKuGroup博客,欢迎分享。

评论专区
  • 昵 称必填
  • 邮 箱选填
  • 网 址选填
◎已有 0 人评论
搜索
作者介绍
30天热门
×
×
关闭广告
关闭广告
本站会员尊享VIP特权,现在就加入我们吧!登录注册×
»
会员登录
新用户注册
×
会员注册
已有账号登录
×