Nginx 和 PHP的安装配置
2016-11-11 16:31
253 查看
1.安装PHP(注意系统默认安装了php,要安装高版本之前最好卸载旧版本,因为这个原因纠结了四个小时)
2.安装完成之后在/usr/local目录下面生成了两个目录php和fastphp,使用service php-fpm启动的时候有些配置文件报错,拷贝相应的文件到目录即可
3.安装nginx,不赘述。
4.配置nginx
重启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页面:
访问http://10.160.65.44/test.php,得到下面的结果,表明php已经可以使用memcache了。
配置php的会话保存在memcache中。
测试php代码如下
setsess.php
showsess.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 3 directories, 3 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:9000; 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 0.7.x + PHP 5.2.10(FastCGI)搭建胜过Apache十倍的Web服务器 安装与配置(2)
- nginx+PHP+PHP-FPM(FastCGI)在Ubuntu上的安装和配置
- lemp安装配置mysql-5.5.15、 nginx-1.0.0、php-5.3.8
- 详解 CentOS 安装配置 Nginx 0.8.33+PHP 5.3.1+php-fpm+MySQL 全过程【转】
- 通过yum安装nginx-mysql-php-fastcgi配置LNMP
- Nginx 0.7.x + PHP 5.2.10(FastCGI)搭建胜过Apache十倍的Web服务器 安装与配置(3)
- 在Ubuntu 8.04 LTS(hardy)下安装配置nginx和fastcgi方式的php
- linux nginx+apache+php+mysql 安装配置
- ubuntu下nginx+php+mysql+memcached+mango的安装配置
- Redhat+Nginx+PHP+Mysql安装配置
- 如何在widnows下安装配置nginx及PHP
- CentOS5下安装配置nginx+fastcgi php+mysql
- Ubuntu 11.04下Nginx+PHP+Mysql+Tomcat安装配置
- Nginx安装配置(含PHP支持、虚拟主机、反向代理负载均衡)
- nginx+PHP+PHP-FPM(FastCGI)在Ubuntu上的安装和配置
- Nginx 0.7.x + PHP 5.2.10(FastCGI)搭建胜过Apache十倍的Web服务器 安装与配置(4)
- nginx+PHP+PHP-FPM(FastCGI)在Ubuntu上的安装和配置
- windows 下nginx php mysql memcache 的安装与配置(转)
- nginx+php+mysql安装配置
- linux 下 nginx phpcgi 的安装及配置