安装介绍
1.系统环境CentOS7

2.nginx版本1.12

3.PHP版本7.2 下载地址

4.MySQL版本5.7

安装nginx
添加centos7的 nginx yum源 然后执行安装

 sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
sudo yum install -y nginx

启动nginx

 sudo systemctl start nginx.service

PHP安装

安装依赖

yum -y install gcc gcc-c++ libxml2 libxml2-devel autoconf automake pcre-devel zlib zlib-devel bzip2 bzip2-devel openssl openssl-devel
libcurl-devel libjpeg-devel libpng-devel freetype-devel readline readline-devel libxslt-devel perl perl-devel psmisc.x86_64 recode recode-devel curl-devel expat-devel gettext-devel zlib-devel

以上的依赖包有这个可能安装不了【 libmcrypt libmcrypt-devel libtidy libtidy-devel】,貌似也没有影响

下载PHP源码

 mkdir /home/download && cd /home/download #下载到任何地方都可以

 wget http://cn2.php.net/distributions/php-7.2.0.tar.gz

 tar -zxvf php-7.2..tar.gz

开始编译

 cd php-7.2.

 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-opcache --with-gd --with-iconv --with-zlib --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-calendar --with-openssl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --with-curl --with-jpeg-dir --with-freetype-dir --with-mysqli --enable-embedded-mysqli --with-pdo-mysql

编译完成后执行安装,安装过程耗时较长

make && make install

生成 PHP 配置

 sudo cp php.ini-production /usr/local/php/etc/php.ini

 sudo cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

 sudo chmod +x /etc/init.d/php-fpm

 sudo cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

 sudo cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

 sudo cp /usr/local/php/bin/php /usr/bin/php

查看PHP版本,执行/usr/local/php/bin/php -v 显示下面的结果表示安装完成

PHP 7.1.4 (cli) (built: May  1 2017 00:26:16) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

配置 Nginx

 server {
listen default_server;
listen [::]: default_server;
server_name _; #这里可以配置域名
root /var/www; #这里配置项目目录
index index.php index.html index.htm;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
} location ~ \.php$ { root /var/www; #这里配置项目目录和上面一样 fastcgi_pass 127.0.0.1:9000; try_files $uri /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }

重启服务完成所有配置

 service nginx restart #重启 Nginx
service php-fpm restart # 重启 php-fpm

phpfpm和nginx设置开机自动启动

## 添加执行权限

 chmod a+x /etc/init.d/nginx

 chmod a+x /etc/init.d/php-fpm

## 加入服务

 chkconfig --add nginx

 chkconfig --add php-fpm

## 开机自启

 chkconfig nginx on

 chkconfig php-fpm on

查看服务列表:

 chkconfig --list

CentOS 7系统安装nginx+php的更多相关文章

  1. 在linux(centos)系统安装nginx教程

    最近在切换服务器操作系统,简单记录一下 一.安装nginx需要如下环境  1.gcc  编译依赖gcc环境,如果没有gcc环境,需要安装gcc yum install gcc-c++  2.PCRE ...

  2. CentOS7 编译安装 Nginx (实测 笔记 Centos 7.0 + nginx 1.6.2)

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...

  3. CentOS 5系统安装Django、Apache 、mod_wsgi部署Python环境教程

    Django,是一款针对Python环境的WEB开发框架,能够帮助我们构架快捷.简单的WEB框架设置,Django框架非常适合开发内容应用环境,所以在本文中,麦子将整理基于Centos系统部署安装Dj ...

  4. CentOS 6.6 nginx PHP 配置

    /************************************************************************* * CentOS 6.6 nginx PHP 配置 ...

  5. CentOS 6.6 nginx install

    /************************************************************************* * CentOS 6.6 nginx instal ...

  6. 删:Centos 7安装Nginx 1.8

    [CentOS 7] 安装nginx! 首先进行 nginx yum Nginx安装记录 注意:如果用源码安装,nginx配置时需要指定--with-pcer对应的压缩包路径,如果使用二进制安装不需要 ...

  7. linux/centos下安装nginx(rpm安装和源码安装)详细步骤

    Centos下安装nginx rpm包                                                                                 ...

  8. CentOS下安装Nginx并添加nginx_upload_module

    安装前,最好能保证依赖的系统软件已经升级.    yum update CentOS上安装Nginx,如果只是简单安装,不附加其他第三方模块,一句话可以搞定:    yum install nginx ...

  9. CentOS 7安装nginx

    CentOS 7安装nginx 参考网上其他文章做的 安装Nginx 我们从nginx官方的RPM源来安装一个预构建的稳定版本的nginx包. rpm --import http://nginx.or ...

随机推荐

  1. ionic slide组件使用

    ionic学习使用笔记 slide 组件的使用   开始做的时候,遇到了个要用ionic实现 有一系列的序列需要展示,但是当前页面上只能展示一小部分,剩余的在没有出现时是隐藏的,还得能滑动出现,但是又 ...

  2. WCF - Home

    https://www.tutorialspoint.com/wcf/index.htm WCF Tutorial WCF stands for Windows Communication Found ...

  3. Vue知识整理3:v-once的使用

    v-once可以使得数据绑定只绑定一次,后期不会再改变,如下图所示:

  4. lombok 简化 get set toString hash equals等方法

    1.lombok 在项目中使用Lombok可以减少很多重复代码的书写.比如说getter/setter/toString等方法的编写. 2.安装 下载 https://projectlombok.or ...

  5. fastboot烧录镜像--VTS&GSI镜像替换

    fastboot简介 Android提供的原生工具,主要用于替换镜像. 源码在SDK工程中,/system/core/fastboot目录下 安卓分区&镜像 见链接分区和映像--google官 ...

  6. 解决sql语句中参数为空(null)不会更新参数的问题

    用的mybatis自动生成的 情景: 修改页面中,修改某个字段,修改前有数据,修改后为空. mybatis中一般用到 如:(这种直接忽略为空的字段,不能更新空字段参数) <update id=& ...

  7. [11期]绕过安全狗、云锁等各大WAF注入,上传深入自动化Bypass攻击

    CDN       负载均衡.内容分发 解析漏洞一般在服务层      二进制,溢出,提权在系统层         渗透测试就是以上全部层 协议未正确解析 GET改POST   这叫参数污染 cook ...

  8. Vue路由注意事项

    一.vue中路由的使用 1.定义组件 <template> <div class="hello"> <h1 @click="info&quo ...

  9. ODBC Driver Development

    ODBC Driver Development By Vikash Agarwal, May 01, 2002 Open your database system to the world. Vika ...

  10. JS 数组的常用方法归纳之不改变原数组和其他

    不改变原数组的方法 concat() 连接两个或多个数组,不改变现有数组,返回新数组,添加的是数组中的元素 join(",") 把数组中的所有元素放入一个字符串,通过‘,’分隔符进 ...