編譯安裝Nginx和php搭建KodExplorer網盤


編譯安裝Nginx和php搭建KodExplorer網盤

環境說明:

系統版本    CentOS 6.9 x86_64        

軟件版本    nginx-1.12.2        php-5.5.38        kodexplorer4.25

1、nginx的編譯安裝可以參照前面的博文,這里不再贅述

2、編譯安裝php

2.1 下載並安裝相關編譯器

  1. mkdir -p /service/tools     #創建目錄  
  2. cd /service/tools/  
  3. wget http://mirrors.sohu.com/php/php-5.5.38.tar.gz  #下載包  
  4. tar xf php-5.5.38.tar.gz    #解壓  
  5. yum install gcc gcc-c++ glibc -y #安裝編譯器,如果已經編譯安裝了nginx則不需要此步驟  
  6. yum install -y libxml2-devel curl curl-devel libjpeg-devel libpng-devel freetype-devel  
  7. #安裝編譯時所需庫  
  8. cd php-5.5.38           #進入php-5.5.38目錄  

2.2 編譯安裝

2.2.1 編譯生成makefile

  1. ./configure --prefix=/application/php-5.5.38 --with-jpeg-dir=/usr/lib64 --with-freetype-dir=/usr/lib64/  --with-curl  --enable-fpm --enable-mbstring  --with-gd    --with-fpm-user=nginx --with-fpm-group=nginx  

2.2.2 make && make install

3、配置

  1. [root@Web02 php-5.5.38]# ln -s /application/php-5.5.38 /application/php #創建軟鏈接  
  2. [root@Web02 php-5.5.38]# ln -s /application/php/bin/* /usr/bin/  #創建命令軟鏈接
  3. [root@Web02 php-5.5.38]# cp php.ini-production /application/php-5.5.38/etc/php.ini    
  4. #拷貝默認配置文件  
  5. [root@Web02 php-5.5.38]#  
  6. cp /application/php-5.5.38/etc/php-fpm.conf.default /application/php-5.5.38/etc/php-fpm.conf  
  7. #拷貝默認php-fpm配置文件,php-fpm    啟動進程數  

4、啟動

  1. [root@Web02 php-5.5.38]# /application/php/sbin/php-fpm  #啟動php  
  2. [root@Web02 php-5.5.38]# netstat -lntup|grep 9000       #查看進程9000端口  
  3. tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      97399/php-fpm  

5、配置nginx使其支持php

查看nginx.conf.default有關php的部分(65-71行),將此內容添加到nginx.conf中,並修改fastcgi_param指定script文件名$document_root$fastcgi_script_name

可以在/application/nginx/conf/fastcgi.conf查看

65 #location ~ \.php$ {

66 # root html;

67 # fastcgi_pass 127.0.0.1:9000;

68 # fastcgi_index index.php;

69 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

70 # include fastcgi_params;

71 #}

  1. [root@Web02 php-5.5.38]# cd /application/nginx/conf/  
  2. [root@Web02 conf]# vim nginx.conf  
  3. server {  
  4.         listen       80;  
  5.         server_name  localhost;  
  6.         index index.php index.html index.htm;  
  7.         location / {  
  8.             root   html;  
  9.         }  
  10.         location ~ \.php$ {  
  11.             root           html;  
  12.             fastcgi_pass   127.0.0.1:9000;  
  13.             fastcgi_index  index.php;  
  14.             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;              
  15. include       fastcgi_params;  
  16.         }         
  17.     }  
  18. }  

這個配置的意思是 在瀏覽器中訪問的.php文件,實際讀取的是 $document_root(網站根目錄)下的.php文件 -- 也就是說當訪問127.0.0.1/index.php的時候,需要讀取網站根目錄下面的index.php文件,如果沒有配置這一配置項時,nginx不回去網站根目錄下訪問.php文件,所以返回空白

配置項目中:include fastcgi_params; fastcgi_params 文件中含有各個nginx常量的定義,默認情況 SCRIPT_FILENAME = /scripts$fastcgi_script_name

檢查語法nginx -t

6、配置網盤

  1. [root@Web02 conf]# cd ../html/      #進入到站點目錄  
  2. [root@Web02 html]# ls  
  3. 50x.html  index.html  
  4. [root@Web02 html]# rm -rf *     #刪除原有的站點文件  
  5. [root@Web02 html]# wget http://static.kodcloud.com/update/download/kodexplorer4.25.zip  
  6. #下載  
  7. [root@Web02 html]# unzip kodexplorer4.25.zip    #解壓  
  8. [root@Web02 html]# nginx    #啟動nginx  

瀏覽器訪問

根據提示操作

su -c 'setenforce 0'        #關閉selinux,su -c 指定命令,用root執行

chmod -R 777 /var/www/html/    #按照提示修改權限

刷新頁面重新訪問,成功,設置管理員用戶名和密碼,進行登錄及后續圖形界面操作

 

博主原創文章,轉載請務必注明出處


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM