1. 云栖社区>
  2. PHP教程>
  3. 正文

Centos 7 yum 安装 php7 nginx

作者:用户 来源:互联网 时间:2017-12-01 11:36:37

安装centosyumnginxphp7

Centos 7 yum 安装 php7 nginx - 摘要: 本文讲的是Centos 7 yum 安装 php7 nginx, `cat /etc/redhat-release````CentOS Linux release 7.3.1611 (Core)```# Install PHP7## 1 添加源`yum -y install epel-release``



`cat /etc/redhat-release`
```
CentOS Linux release 7.3.1611 (Core)
```
# Install PHP7
## 1 添加源
`yum -y install epel-release`
`rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm`
## 2 安装php7
添加源后,更新一下,`yum updateinfo`,然后`yum search php7` 看下源里PHP7存在哪些小版本:
```
...
mod_php71w.x86_64 : PHP module for the Apache HTTP Server
php71w-bcmath.x86_64 : A module for PHP applications for using the bcmath
php71w-cli.x86_64 : Command-line interface for PHP
php71w-common.x86_64 : Common files for PHP
php71w-dba.x86_64 : A database abstraction layer module for PHP applications
php71w-devel.x86_64 : Files needed for building PHP extensions
php71w-embedded.x86_64 : PHP library for embedding in applications
php71w-enchant.x86_64 : Enchant spelling extension for PHP applications
...
```
看样子已经到PHP7.1了,那就体验下最新的特性,使用命令`yum install mod_php71w php71w-cli php71w-devel php71w-mysql`安装,如果没有MySQL需求,可以去掉php71w-mydql.
安装成功后,`php -v`查看版本信息:
```
PHP 7.1.5 (cli) (built: May 12 2017 21:54:58) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
```
# Install Nginx
安装nginx也比较简单,根据[官网指导教程](http://nginx.org/en/linux_packages.html)就可以完成。
我安装的是稳定版。
`vi /etc/yum.repos.d/nginx.repo`
```
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
```
然后`yum search nginx`查看版本,选择需要的版本,我选了默认的版本,并安装了扩展:`yum install nginx nginx-all-modules`.
安装完毕,`nginx -V`查看Nginx的版本和路径参数及扩展支持:
```
nginx version: nginx/1.12.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
```

以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索安装 , centos , yum , nginx php7 ,以便于您获取更多的相关知识。