安装介绍
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. android 任务栈及启动模式

    1.一个应用程序一般都是由多个activity组成的.2.任务栈(task stack)(别名back stack后退栈) 记录存放用户开启的activity的.3.一个应用程序一被开启系统就给他分配 ...

  2. Redis高可用分布式

    阅读目录: 高可用 数据同步 分布式 分布式集群时代 总结 高可用 高可用(High Availability),是当一台服务器停止服务后,对于业务及用户毫无影响. 停止服务的原因可能由于网卡.路由器 ...

  3. SpringMVC常用方法总结

    *) @RequestMapping(value="/xxx/{id}",method={RequestMethod.GET}) method 不写的话,默认GET.POST都支持 ...

  4. bash如何向上向下移动历史命令记录

    bash如何在 历史命令记录 中上下移动? 通过bash本身的设置,就可以做到! : 用shift+up , shift+down 来上下移动 : 单纯的up/down是调用历史命令

  5. EF6中一个关于时间类型 datetime2 的坑

    在一个访问下位机的程序中,返回的时间戳有时候因断线产生0001年01月01日的时间,而原先使用拼接SQL进行数据存储的操作时,这个问题是可以跳过的. 这次把拼接SQL的部分重新改为EF进行管理,这个坑 ...

  6. Java 位运算超全面总结

    1.原码.反码.补码 关于原码.反码.补码的相关知识作者不打算在这里长篇大论,相关知识已有别的大佬总结很好了,还请老铁自行 Google,不过有篇知乎回答是作者学编程以来见过对相关知识最通俗易懂,生动 ...

  7. c++静态成员变量初始化时不受访问权限控制

    1.要在类外初始化,const 成员变量才能在类内初始化 2.初始化在类外,而不在main函数内 class A{ private: string name; A(){ name = "a& ...

  8. Temporal-Difference Control: SARSA and Q-Learning

    SARSA SARSA algorithm also estimate Action-Value functions rather than State-Value function. The dif ...

  9. 20191105 《Spring5高级编程》笔记-第9章

    第9章 事务管理 一些名词: 2PC(2 Phase Commit) XA协议 JTS(Java Transaction Service) JCA(Java EE Connector Architec ...

  10. tomcat 端口8080占用问题

    启动tomcat时,有时会出现8080端口占用的问题. 解决方法: 终端:ps -e | grep tomcat 会看到下边的结果 途中标记的是进程号,kill掉即可. kill -9 9734(97 ...