Nginx 和 PHP的安装配置
1.安装PHP(注意系统默认安装了php,要安装高版本之前最好卸载旧版本,因为这个原因纠结了四个小时)
./configure \
--prefix=/usr/local/php \
--exec-prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \--with-libxml-dir \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--with-zlib-dir \
--with-mhash \
--with-openssl-dir \
--with-jpeg-dir \
--enable-gd-jis-conv \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip
2.安装完成之后在/usr/local目录下面生成了两个目录php和fastphp,使用service php-fpm启动的时候有些配置文件报错,拷贝相应的文件到目录即可
[root@nginx fastphp]# tree
.
|-- etc
| |-- pear.conf
| `-- php-fpm.conf
`-- var
`-- log
`-- php-fpm.log directories, files
3.安装nginx,不赘述。
4.配置nginx
location / {
root /web/htdocs/;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /web/htdocs/;
index index.php;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
重启nginx,然后访问10.160.65.44/index.php,在/web/htdocs下面显示phpinfo。
============================================================================================
memcache对于php7的支持不太好,上述安装完以后php的验证代码一直无法运行,可能是php7的源码修改比较大?而且memadmin也无法使用,因而我重新安装了php-5.6.28.tar。安装过程相同,安装完成之后编译安装memcache-2.2.4。
安装完成之后memadmin-master.zip,解压后将其放置在/web/htdocs/目录修改为mmaster目录。通过http://10.160.65.44/mmaster/index.php可以访问管理主页面。
测试php页面:
<?php
$mem = new Memcache;
$mem->connect("127.0.0.1",11211) or die("Could not connect");
$version = $mem->getVersion();
echo "Server's version: ".$version."<br/>\n";
$mem->set('testkey','HelloWorld',0,600) or die("Failed to save data at the memcached server");
echo "Store data in the cache (data will expire in 600 seconds)<br/>\n";
$get_result = $mem->get('testkey');
echo "get_result is from memcached server.";
?>
访问http://10.160.65.44/test.php,得到下面的结果,表明php已经可以使用memcache了。
Server's version: 1.4.33
Store data in the cache (data will expire in 600 seconds)
get_result is from memcached server.
配置php的会话保存在memcache中。
测试php代码如下
setsess.php
<?php
session_start();
if (!isset($_SESSION['www.MageEdu.com'])){
$_SESSION['www.MageEdu.com'] = time();
}
print $_SESSION['www.MageEdu.com'];
print "<br><br>";
print "Session ID: " . session_id();
?>
showsess.php
<?php
session_start();
$memcache_obj = new Memcache;
$memcache_obj->connect('192.168.144.44',11211);
$mysess=session_id();
var_dump($memcache_obj->get($mysess));
$memcache_obj->close();
?>
Nginx 和 PHP的安装配置的更多相关文章
- Nginx单向认证的安装配置
Nginx单向认证的安装配置 首先系统要已经安装了openssl,以下是使用openssl安装配置单向认证的执行步骤与脚本: #------------------------------------ ...
- FastDFS_v5.05+nginx+cache集群安装配置手册
转载请出自出处:http://www.cnblogs.com/hd3013779515/ 1.FastDFS简单介绍 FastDFS是由淘宝的余庆先生所开发,是一个轻量级.高性能的开源分布式文件系统, ...
- nginx初探,下载安装配置负载均衡
上一篇我讲了正向代理和反向代理的概念,这个是为nginx做准备的前置技能,网上百度nginx可以知道nginx是什么: Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/PO ...
- nginx(五)nginx与php的安装配置
经过前面学习,对nginx有个大概的了解,来配置LNMP;只要是在系统安装过程中选择安装比较齐全的包,基本上系统都能满足安装要求,下面是我一个一个测试的,基本上全部安装所需的库文件,放心安装: [ro ...
- Tengine 2.1.2 (nginx/1.6.2)安装配置,淘宝 Web 服务器
简介 Tengine是由淘宝网发起的Web服务器项目.它在Nginx的基础上,针对大访问量网站的需求,添加了很多高级功能和特性.Tengine的性能和稳定性已经在大型的网站如淘宝网,天猫商城等得到了很 ...
- Nginx的应用之安装配置
一.Nginx简述 Nginx是一个开源且高性能.可靠的Http Web服务.代理服务. 开源: 直接获取源代码 高性能: 支持海量并发 可靠: 服务稳定 我们为什么选择 Nginx服务 Nginx非 ...
- Nginx服务安装配置
1.Nginx介绍 Nginx是一个高性能的HTTP和反向代理服务器,由俄罗斯人开发的,第一个版本发布于2004年10月4日.Nginx由于出色的性能,在世界范围内受到了越来越多人的关注,其特点是占有 ...
- centos 系统下安装FastDFS+nginx+fastdfs-nginx-module安装配置
前言: 以前的项目上传的文件都是保存到本地或者是局域网内的共享文件夹下,由于数据量,服务器的负载均衡(分机的某些图片无法访问的问题处理)等因素的情况下,就想到用fastdfs来文件管理,花了几天时间硬 ...
- 阿里云服务器Linux CentOS安装配置(八)nginx安装、配置、域名绑定
阿里云服务器Linux CentOS安装配置(八)nginx安装.配置.域名绑定 1.安装nginx yum -y install nginx 2.启动nginx service nginx star ...
随机推荐
- D3的基本设计思路
学习一项新技术,首先要搞清楚它的基本设计思路,有了这个宏观的技术架构,使用该技术起来,就会得心应手了.否则,就会不知道如何下手,即使看到人家的例子程序,可能也不知其所以然. 下面,就简单的结合自己研究 ...
- Squid代理服务器
缓存代理概述:做为应用层的代理服务软件,squid主要提供缓存加速,应用层过滤控制的功能. 1.代理的工作机制 当客户机通过代理来请求web页面时,指定的代理服务器会先检查自己的缓存,如果缓存中已经有 ...
- [Linux] - centos使用mount + nfs 远程共享存储
服务端安装nfs 1.使用yum安装nfs yum install nfs-utils nfs-utils-lib -y 如果安装过程出现这样的错误: 得先安装lvm2 yum install -y ...
- LeetCode "Arranging Coins"
A simple math.. take care of data overflow though. class Solution { public: int arrangeCoins(int n) ...
- android学习笔记57——电话管理器TelephoneyManager
电话管理器TelephoneyManager
- 读写hdfs文件(工作笔记)
import java.io.IOException; import java.io.InputStream; import java.util.List; import java.util.Map; ...
- OAF_开发系列09_实现OAF预提取LOV设定(案例)
20150712 Created By BaoXinjian
- hbase基础-系统架构
HBase 系统架构 HBase是Apache Hadoop的数据库,能够对大型数据提供随机.实时的读写访问.HBase的目标是存储并处理大型的数据.HBase是一个开源的,分布式的,多版本的,面向列 ...
- 3、NASA NIST Big Data Architecture
这篇关于大数据应用的讲解太好了,直接上图.Mattmann_S1P8_ESTF2015 来自为知笔记(Wiz)
- centos 7 + mono + jexus 环境安装
1.安装 mlocate yum list|grep locate yum install mlocate.x86_64 updatedb 2.安装 yum-utils yum list|grep y ...