配置源

纯净的Centos 6.5系统

配置163yum源 (这个比较简单,百度能解决很多问题)

开始

安装  开发软件包:yum  -y groupinstall  "Development Tools"

安装  mysql     : yum  -y install mysql mysql-server mysql-devel

下载  php-5.6.2   wgethttp://cn2.php.net/distributions/php-5.6.2.tar.gz

解压  tar -zxvf php-5.6.2.tar.gz

cd php-5.6.
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=php-fpm \
--with-fpm-group=php-fpm \
--with-mysql=mysqlnd \ //这里mysqlnd 是内部查找命令
--with-mysql-sock=/tmp/mysql.sock \
--with-libxml-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-iconv-dir \
--with-zlib-dir \
--with-mcrypt \
--enable-soap \
--enable-gd-native-ttf \
--enable-ftp \
--enable-mbstring \
--enable-exif \
--disable-ipv6 \
--with-pear \
--with-curl \
--with-openssl

出现未安装的错误,直接用yum 进行安装即可,不要忘了装上 -devel (libcurl libpng libcrul12等等)

make
make install

修改配置文件

cd php-5.6.
cp php.ini-production /usr/local/php/etc/php.ini
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf

保存配置文件后,检验配置是否正确的方法为

/usr/local/php/sbin/php-fpm -t

如果出现诸如 “test is successful” 字样,说明配置没有问题

启动php-fpm

service php-fpm start

如果想让它开机启动,执行

chkconfig php-fpm on

检测是否启动

ps aux |grep php-fpm
netstat -ant |grep

安装nginx

wget http://nginx.org/download/nginx-1.6.2.tar.gz                   //最新稳定版哦
tar zxvf nginx-1.6..tar.gz
cd nginx-1.6.
./configure \
--prefix=/usr/local/nginx \
--with-http_realip_module \
--with-http_sub_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-pcre=/root/pcre-8.35 //很多人没讲这里,这里为pcre的解压目录。不过得先安装pcre

如果出错了,yum安装pcre-devel。如果yum安装不了,就到官网上自行下载源码包,然后解压安装。

make
make install

添加一个nginx主程序的符号链接

ln -sf /usr/local/nginx/sbin/nginx /usr/sbin/nginx
nginx -t //测试一下吧

nginx配置

把原来的配置文件清空

> /usr/local/nginx/conf/nginx.conf

“>”这个符号为重定向的意思,单独用它,可以把一个文本文档快速清空。

编辑nginx.conf

vi /usr/local/nginx/conf/nginx.conf

插入以下内容

user nobody nobody;
worker_processes ;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile ; events
{
use epoll;
worker_connections ;
} http
{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size ;
server_names_hash_max_size ;
log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
'$host "$request_uri" $status'
'"$http_referer" "$http_user_agent"';
sendfile on;
tcp_nopush on;
keepalive_timeout ;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
connection_pool_size ;
client_header_buffer_size 1k;
large_client_header_buffers 4k;
request_pool_size 4k;
output_buffers 32k;
postpone_output ;
client_max_body_size 10m;
client_body_buffer_size 256k;
client_body_temp_path /usr/local/nginx/client_body_temp;
proxy_temp_path /usr/local/nginx/proxy_temp;
fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
fastcgi_intercept_errors on;
tcp_nodelay on;
gzip on;
gzip_min_length 1k;
gzip_buffers 8k;
gzip_comp_level ;
gzip_http_version 1.1;
gzip_types text/plain application/x-javascript text/css text/htm application/xml; server
{
listen ;
server_name localhost;
index index.html index.htm index.php;
root /usr/local/nginx/html; location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
}
}

测试是否解析php文件

创建测试文件

vi /usr/local/nginx/html/.php

插入以下内容

<?php
echo "测试php解析";
?>

测试

curl localhost/.php

新手搭建 nginx + php (LNMP)的更多相关文章

  1. 5分钟搭建 nginx +php --------------(LNMP)新手专用

    5分钟搭建 nginx +php --------------(LNMP)新手专用 2014-11-14 16:48 88876人阅读 评论(2) 收藏 举报 版权声明:本文为博主原创文章,未经博主允 ...

  2. Linux 之 LNMP服务器搭建-Nginx

    LNMP服务器搭建-Nginx 参考教程:[千峰教育] 系统版本: CentOS 6.8 关闭防火墙和Selinux service iptables stop setenforce 安装Nginx ...

  3. 在阿里云上搭建nginx + ThinkPHP 的实践

    作为一个程序猿,理应用linux系统来作为平时的工作机环境,哎,之前倒是用过一段时间的linux,可惜后来换了本本,后来竟然没有保持,嗷嗷后悔中... 废话不多说,大家用windows的理由都一样,但 ...

  4. Linux 学习笔记 6 搭建nginx 实现二级域名访问

    前言 在前一节的内容里面,我们学习了如何使用yum 包管理工具来安装我们需要的软件,这节内容,通过搭建Nginx 反向代理服务器,以及学习服务的配置等内容. NGINX Nginx是一款轻量级的Web ...

  5. ELK+redis搭建nginx日志分析平台

    ELK+redis搭建nginx日志分析平台发表于 2015-08-19   |   分类于 Linux/Unix   |  ELK简介ELKStack即Elasticsearch + Logstas ...

  6. 在阿里云服务器(ECS)上从零开始搭建nginx服务器

    本文介绍了如何在阿里云服务器上从零开始搭建nginx服务器.阿里云服务器(ECS)相信大家都不陌生,感兴趣的同学可以到http://www.aliyun.com/product/ecs去购买,或到体验 ...

  7. 基于ubuntu 14搭建nginx+php+mysql环境

    基于最新的Ubuntu 14.04(2014年9月)搭建nginx.php.mysql环境, 以下全部命令行操作: 1 由于需要大量的权限操作,方便起见临时提升权限,使用root账号 sudo su ...

  8. Win7搭建nginx+php+mysql开发环境以及websocket聊天实例测试

    Win7搭建nginx+php+mysql开发环境以及websocket聊天实例测试一.下载相关安装包 1.下载nginx最新版本(nginx1.3.13版之后才支持websocket协议) 下载地址 ...

  9. Net分布式系统之二:CentOS系统搭建Nginx负载均衡

    一.关于CentOS系统介绍 CentOS(Community Enterprise Operating System,中文意思是:社区企业操作系统)是Linux发行版之一,它是来自于Red Hat ...

随机推荐

  1. Python 字典的嵌套

    wf = { "name":"汪峰", "age":52, "hobby":["唱歌", " ...

  2. 高强度减脂Tabata练习

    每个动作20秒 动作间休息10秒 8个动作为一组 每次做四组 让你大汗淋漓全身酸爽 波比跳 ▼ 跳起箭步蹲 ▼ 登山者 ▼ 俯卧撑 ▼ 卷腹 ▼ 开合跳 ▼ 高抬腿 ▼ 俄罗斯转体 ▼ Bingo ▼ ...

  3. HDU 1501 Zipper(DFS)

    Problem Description Given three strings, you are to determine whether the third string can be formed ...

  4. OK335xS U-boot GPIO control hacking

    /**************************************************************************************** * OK335xS ...

  5. java正则表达式——Greedy、Reluctant和Possessive

    测试1: package jichu; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Mai ...

  6. Microsoft - Find Biggest Node

    public Node findBiggest (Node n1, Node n2){ Node c1 = n1; Node c2 = n2; boolean isPositive = false; ...

  7. smarty 学习 ——smarty 开发环境配置

    smarty 对于开发的便利性不用多说了,直接进行开发环境的配置. 1.下载smarty 开发包 直接在官网进行下载即可 2.引用开发核心库 将libs文件中的东西拷贝到工程. smarty.clas ...

  8. Xamarin版的C# SVG路径解析器

    原文:Xamarin版的C# SVG路径解析器 Xamarin版的C# SVG路径解析器,对SVG的Path路径进行解析,其中包括: 主程序SvgPathParser.cs, 相关接口定义:ISour ...

  9. PHP 的工作流组件记录

    我目前只知道在有审批流程中会用到工作流. 不过我我还没用过,还不知道怎么使用. 暂且先记录一下,目前我找到的几个 PHP 工作流组件. symfony https://github.com/symfo ...

  10. spring 使用 maven profile

    先看看 maven 定义 profile 的写法 <!-- profiles --> <profiles> <profile> <activation> ...