日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > php >内容正文

php

Nginx 和 PHP的安装配置

發(fā)布時(shí)間:2025/5/22 php 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Nginx 和 PHP的安装配置 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1.安裝PHP(注意系統(tǒng)默認(rèn)安裝了php,要安裝高版本之前最好卸載舊版本,因?yàn)檫@個(gè)原因糾結(jié)了四個(gè)小時(shí))

./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目錄下面生成了兩個(gè)目錄php和fastphp,使用service php-fpm啟動(dòng)的時(shí)候有些配置文件報(bào)錯(cuò),拷貝相應(yīng)的文件到目錄即可

[root@nginx fastphp]# tree . |-- etc | |-- pear.conf | `-- php-fpm.conf `-- var`-- log`-- php-fpm.log3 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,然后訪問(wèn)10.160.65.44/index.php,在/web/htdocs下面顯示phpinfo。

?============================================================================================

  memcache對(duì)于php7的支持不太好,上述安裝完以后php的驗(yàn)證代碼一直無(wú)法運(yùn)行,可能是php7的源碼修改比較大?而且memadmin也無(wú)法使用,因而我重新安裝了php-5.6.28.tar。安裝過(guò)程相同,安裝完成之后編譯安裝memcache-2.2.4。

  安裝完成之后memadmin-master.zip,解壓后將其放置在/web/htdocs/目錄修改為mmaster目錄。通過(guò)http://10.160.65.44/mmaster/index.php可以訪問(wèn)管理主頁(yè)面。

?  測(cè)試php頁(yè)面:

<?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."; ?>

  訪問(wèn)http://10.160.65.44/test.php,得到下面的結(jié)果,表明php已經(jīng)可以使用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的會(huì)話保存在memcache中。

  測(cè)試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(); ?>

  

?

轉(zhuǎn)載于:https://www.cnblogs.com/python-study/p/6054750.html

總結(jié)

以上是生活随笔為你收集整理的Nginx 和 PHP的安装配置的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。