安装nginx

1、安装依赖包

yum -y install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel perl perl-devel perl-ExtUtils-Embe

2、检查系统中是否已经安装nginx,如果安装过需先卸载nginx

find / -name nginx
yum remove nginx

3、上传nginx包和解压文件(不要更改解压之后的文件名否则会产生conf/koi-win’ and `/usr/local/nginx/conf/koi-win’ are the same file错误

nginx下载链接

tar -zxvf nginx-1.10.3.tar.gz
cd nginx-1.10.3

4、安装nginx默认安装在/usr/local/nginx

./configure –prefix=/usr/local/nginx 
–with-openssl=/usr/include (启用ssl) 
–with-pcre=/usr/include/pcre/ (启用正规表达式) 
–with-http_stub_status_module (安装可以查看nginx状态的程序) 
–with-http_memcached_module (启用memcache缓存) 
–with-http_rewrite_module (启用支持url重写)

./configure --with-http_perl_module --with-ld-opt="-Wl,-E" --with-http_ssl_module

5、安装完成nginx的信息如下所示

nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file:"/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"

6、 安装 nginx

make && make install

7、启动、停止、重载nginx并且检查端口和检查配置

/usr/local/nginx/sbin/nginx
netstat -ntlp | grep 80
ps -ef | grep nginx
/usr/local/nginx/sbin/nginx –t
/usr/local/nginx/sbin/nginx –s stop
/usr/local/nginx/sbin/nginx –t reload

8、配置开机自启动* /etc/rc.d/rc.local文件后面加上/usr/local/nginx/sbin/nginx*

vim /etc/rc.d/rc.local

9、安装完成

安装php

1、下载依赖包

yum -y install libxml2-devel bzip2 bzip2-devel curl curl-devel libjpeg-devel

其他的依赖可以参考此url

wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
tar -zxvf libmcrypt-2.5.7.tar.gz
./configure
make && make install

2、需要修改本地的配置文件

vim /etc/ld.so.conf.d/local.conf # 编辑库文件
/usr/local/lib # 添加该行
ldconfig -v # 使之生效

3、上传php的包,解压,进入文件夹

tar -zxvf php-5.6.27.tar.gz

4、编译和安装

./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt --enable-mbstring --enable-pdo --with-curl --disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-pdo-mysql --with-mysqli --with-gd --with-libdir=lib64 --with-jpeg-dir --with-freetype-dir --enable-calendar
make && make install

5、为php-fpm提供配置文件

cp /usr/local/phetc/php-fpm.conf.default /usr/local/phetc/php-fpm.conf
vim etc/php-fpm.conf

pid = /usr/local/php/var/run/php-fpm.pid 
pm.max_children = 300 
pm.start_servers = 10 
pm.min_spare_servers = 10 
pm.max_spare_servers = 50 
user = www 
group = www

6、创建登录用户

groupadd www
useradd -g www www

7、启动php-fpm

/usr/local/php/sbin/php-fpm
ps aux | grep php-fpm

8、nginx整合php

vim /usr/local/nginx/nginx.conf

下列内容取消注释

log_format main
'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
#添加index.php
location / {
root html;
index index.php index.html index.htm;
}

下列内容更新

location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
#include fastcgi_params;
include fastcgi.conf;
}

9、重新载入配置文件

/usr/loca/nginx/sbin/nginx -s reload
 
vim /usr/local/nginx/html/index.php
 
<?php
phpinfo();
?>

10、浏览器里面访问测试成功

安装nginx和php的更多相关文章

  1. centos直接yum安装nginx

    Ubuntu下安装nginx,直接apt-get install nginx就行了,很方便. 但是今天装了CentOS6.2,直接yum install nginx不行,要先处理下源,下面是安装完整流 ...

  2. 安装Nginx服务

    Nginx最大特点: 静态小文件(1M),支持高并发,同时占用系统资源很少.3W并发,10个进程,内存150M. Nginx特点: 1.配置简单,灵活,轻量. 2.高并发(静态小文件),静态几万的并发 ...

  3. Linux下安装nginx

    一直会使用nginx,也学习了好多nginx知识.也在本地安装过nginx,这次是第一次在正式的环境安装nginx,把这些记录下来总结经验. 一.安装环境 操作系统:CentOS release 6. ...

  4. centos系统编译安装nginx+php环境另加独立mysql教程

    以前看过的安装nginx+php环境都带了mysql数据库了,这个是因为很多站长都是nginx+php+mysql都在同一台服务器了,那么今天我们是单独处理了,一个是nginx+php环境,然后mys ...

  5. Mac OS使用brew安装Nginx、MySQL、PHP-FPM的LAMP开发环境

    准备工作 新版的 Mac OS 内置了Apache 和 PHP,我的系统版本是OS X 10.9.3,可以通过以下命令查看Apache和PHP的版本号: httpd -v Server version ...

  6. 手把手教你玩转nginx负载均衡(四)--源码安装nginx

    引言: 在上一篇,我们已经装好了虚拟机,并且已经配置好了网络,那么今天我们就要开始安装nginx服务器了. 安装工具以及过程 安装gcc编译套件以及nginx依赖模块 yum -y install g ...

  7. Centos7 编译安装 Nginx PHP Mariadb Memcached 扩展 ZendOpcache扩展 (实测 笔记 Centos 7.3 + Mariadb 10.1.20 + Nginx 1.10.2 + PHP 7.1.0 + Laravel 5.3 )

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7-x86_64-Minimal-1611.iso 安装步骤: 1.准备 1.0 查看硬 ...

  8. 安装nginx

    [yum安装nginx] yum clean all(这步不执行会出现no more mirrors to try错误) cd /etc/yum.repos.d/ vi nginx.repo 填写 [ ...

  9. unbuntu14.04 安装nginx配置

    记录一下linux下安装nginx的所需要的配置. 首先从 nginx官网 下载所需要的版本,复制链接,执行 wget http://nginx.org/download/nginx-1.8.0.ta ...

  10. linux 安装 nginx 及反向代理配置

    Nginx ("engine x") 是一个高性能的HTTP和反向代理服务器,以下为Linux centos平台下安装nginx并配置反向代理的过程(采用源码安装的方式) 一:安装 ...

随机推荐

  1. 在app内打开自己app的专用设置界面

    在我们的APP中,可能会使用多种服务,例如定位.推送.相册.拍照.通讯录等.选择是否允许一般只出现在安装app后第一次打开时,可是我们依然需要在使用到某种服务的时候判断是否用户是否允许了该服务,因为用 ...

  2. 属性动画之ValueAnimator

    原文链接:http://blog.csdn.net/guolin_blog/article/details/43536355

  3. RTMPdump(libRTMP) 源代码分析 8: 发送消息(Message)

    ===================================================== RTMPdump(libRTMP) 源代码分析系列文章: RTMPdump 源代码分析 1: ...

  4. PS 图像调整算法— —渐变映射

    这个调整简单来说就是先建立一张lookup table, 然后以图像的灰度值作为索引,映射得到相应的颜色值.图像的灰度值是由图像本身决定的,但是lookup table 却可以各种各样,所以不同的lo ...

  5. BT币(金融有风险,投资需谨慎)哥的失败投资

    谁都知道bt币是一个旁氏骗局, 而进去的人,就必须保证自己不赔钱,所以只能随着大潮往前走,谁也不能让它跌 压垮骆驼的最后一根稻草, 还是幕后有个 推手, 在炒作 BT币, 事实上,作为新的投资项目,B ...

  6. 高性能缓存系统Memcached在ASP.NET MVC中应用

    在Memcached中实体类型未经序列化不能在Memcached中缓存,因此需要对实体类进行处理,才能缓存下来. Memcached是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库 ...

  7. Spring Cloud 入门教程 - Eureka服务注册与发现

    简介 在微服务中,服务注册与发现对管理各个微服务子系统起着关键作用.随着系统水平扩展的越来越多,系统拆分为微服务的数量也会相应增加,那么管理和获取这些微服务的URL就会变得十分棘手,如果我们每新加一个 ...

  8. JVM笔记8-虚拟机性能监控与故障处理工具

    1.JDK命令行工具 Java开发人员肯定都知道JDK的bin目录有“java.exe”,"javac.exe"这两个命令行工具,但并非所有程序员都了解过JDK的bin目录之中其他 ...

  9. Day4_迭代器

    迭代器: 是一个重复的过程,每一次重复都是基于上一次的结果而来. 可迭代对象: 凡是对象有_iter_方法(对象._iter_),该对象就是可迭代对象. 字符串,列表,元组,字典等都是可迭代对象. 可 ...

  10. 走进netty

    三月份开始看公司RPC框架的源码,发现如果要折腾明白,网络通讯这块知识必不可少.于是从如下几点开始逐步研究. 一.基础知识篇 1.Unix下5种I/O模型 Linux的内核将所有外部设备都看作一个文件 ...