编译安装Apache httpd和php搭建KodExplorer网盘

环境说明:

系统版本    CentOS 6.9 x86_64

软件版本    httpd-2.2.31        php-5.5.26        kodexplorer4.25

1、创建规范目录

  1. [[email protected] ~]# mkdir -p /service/tools     #放软件包  

  2. [[email protected] ~]# mkdir /application      #软件安装目录  

2、编译安装httpd

  1. [[email protected] ~]# cd /service/tools/  

  2. [[email protected] tools]# wget http://archive.apache.org/dist/httpd/httpd-2.2.31.tar.gz  

  3. #从官方下载软件,要找到这个包也不容易  

  4. [[email protected] tools]# tar xf httpd-2.2.31.tar.gz  #解压  

  5. [[email protected] tools]# cd httpd-2.2.31  

  6. [[email protected] httpd-2.2.31]# yum install gcc gcc-c++ glibc zlib-devel -y  #安装编译器等  

  7. [[email protected] httpd-2.2.31]# ./configure --prefix=/application/apache2.2.31 --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite       #编译,生成makefile  

  8. [[email protected] httpd-2.2.31]# echo $?  

  9. 0   #编译完进行检查,输出为零,表示编译成功  

  10. [[email protected] httpd-2.2.31]# make && make install  

  11. [[email protected] httpd-2.2.31]# echo $?  

  12. 0   #再次检查  

  13. [[email protected] httpd-2.2.31]# ln -s /application/apache2.2.31 /application/apache  #创建软链接  

  14. [[email protected] httpd-2.2.31]# ls -l /application/  #查看软链接  

  15. total 4  

  16. lrwxrwxrwx  1 root root   26 May 12 15:27 apache -> /application/apache2.2.31  

  17. drwxr-xr-x 15 root root 4096 May 12 15:27 apache2.2.31  

 

3、配置

  1. [[email protected] httpd-2.2.31]# /application/apache/bin/apachectl start  #启动apache  

  2. httpd: apr_sockaddr_info_get() failed for Web01     #出现错误提示  

  3. httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName  

  4. [[email protected] httpd-2.2.31]# vim /application/apache/conf/httpd.conf  

  5. 修改98  

  6. #ServerName www.example.com:80  

  7. 修改为ServerName 127.0.0.1:80  

浏览器访问10.0.0.7

  1. [[email protected] httpd-2.2.31]# vim /application/apache/conf/httpd.conf  

  2. 修改132  

  3. <Directory "/application/apache2.2.31/htdocs">  

  4. 修改为<Directory "/application/apache2.2.31/html">  

  5. 修改378行去掉#   

  6. Include conf/extra/httpd-mpm.conf  

  7. 修改396行去掉#  

  8. Include conf/extra/httpd-vhosts.conf  

  9. [[email protected] html]# vim /application/apache/conf/extra/httpd-vhosts.conf  

  10. <VirtualHost *:80>  

  11.     ServerAdmin [email protected]   #邮箱  

  12.     DocumentRoot "/application/apache2.2.31/html"       #网站根目录  

  13.     ServerName 10.0.0.7 #主机名称或地址  

  14.     ServerAlias test    #别名  

  15.     ErrorLog "/application/apache2.2.31/logs/www-error_log" #日志路径  

  16.     CustomLog "/application/apache2.2.31/logs/www-access_log" common  

  17. </VirtualHost>  

  18. [[email protected] httpd-2.2.31]# mkdir -p /application/apache2.2.31/html  

  19. #创建网站根目录  

 

4、编译安装php依赖

  1. [[email protected] httpd-2.2.31]# cd /service/tools/  

  2. [[email protected] tools]# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz  

  3. #从官网下载libiconv  

  4. [[email protected] tools]# tar xf libiconv-1.14.tar.gz     #解压  

  5. [[email protected] tools]# cd libiconv-1.14  

  6. [[email protected] libiconv-1.14]# ./configure --prefix=/usr/local/libiconv    #编译生成makefile  

  7. [[email protected] libiconv-1.14]# make && make install  

5、编译安装php

  1. [[email protected] libiconv-1.14]# cd /service/tools/  

  2. [[email protected] tools]# wget http://mirrors.sohu.com/php/php-5.5.26.tar.gz  #下载  

  3. [[email protected] tools]# tar xf php-5.5.26.tar.gz #解压  

  4. [[email protected] tools]# cd php-5.5.26  

  5. [[email protected] php-5.5.26]# yum install zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel libxslt-devel libmcrypt-devel mhash mhash-devel mcrypt openssl-devel -y     #安装依赖,也可以不安装先编译,但是编译会提示出错缺少依赖,还是要安装  

  6. [[email protected] php-5.5.26]# cd ..  

  7. [[email protected] tools]# yum install epel-release -y     #安装epel-release  

  8. [[email protected] tools]# yum install -y libmcrypt-devel    

  9. #安装libmcrypt-devel,亲测只能先安装epel-release才能安装,网上别的方式会失败  

  10. [[email protected] tools]# cd php-5.5.26  

  11. [[email protected] php-5.5.26]# ./configure --prefix=/application/php5.5.26 --with-apxs2=/application/apache/bin/apxs --with-mysql=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-short-tags --enable-zend-multibyte --enable-static --with-xsl --enable-ftp    

  12. #编译php生成makefile  

  13. [[email protected] httpd-2.2.31]# echo $?  

  14. 0  

  15. [[email protected] php-5.5.26]# make && make install  

  16. [[email protected] httpd-2.2.31]# echo $?  

  17. 0  

  18. [[email protected] php-5.5.26]# ln -s /application/php5.5.26 /application/php  #创建软链接  

  19. [[email protected] php-5.5.26]# ll /application/  

  20. total 8  

  21. lrwxrwxrwx  1 root root   26 May 12 15:27 apache -> /application/apache2.2.31/  

  22. drwxr-xr-x 16 root root 4096 May 12 15:40 apache2.2.31  

  23. lrwxrwxrwx  1 root root   22 May 12 15:59 php -> /application/php5.5.26  

  24. drwxr-xr-x  7 root root 4096 May 12 15:58 php5.5.26  

  25. [[email protected] php-5.5.26]# ll /application/apache/modules/    #检查结果  

  26. total 34772  

  27. -rw-r--r-- 1 root root     9194 May 12 15:26 httpd.exp  

  28. -rwxr-xr-x 1 root root 35592935 May 12 15:58 libphp5.so  

  29. [[email protected] php-5.5.26]# grep libphp5.so /application/apache/conf/httpd.conf  

  30. LoadModule php5_module        modules/libphp5.so  

  31. [[email protected] php-5.5.26]# cp php.ini-production /application/php/lib/php.ini #拷贝php.ini  

 

6、配置httpd.conf

  1. [[email protected] php-5.5.26]# cd /application/apache/conf/  

  2. [[email protected] conf]# vim httpd.conf  

  3. 311行下增加:  

  4. AddType application/x-httpd-php .php .phtml  

  5. AddType application/x-httpd-php-source .phps  

  6. 168行下增加:  

  7. DirectoryIndex index.php index.html  

  8. 67行下增加  

  9. User www  

  10. Group www  

 

7、建立用户

  1. [[email protected] conf]# useradd -u 513 -s /sbin/nologin www  

  2. [[email protected] conf]# id www  

  3. uid=513(www) gid=513(www) groups=513(www)  

 

8、启动并检查

  1. [[email protected] conf]# /application/apache/bin/apachectl -t #检查语法  

  2. Syntax OK  

  3. [[email protected] conf]# cd /application/apache/html/  

  4. [[email protected] html]# chown -R www.www ..  #html目录及下面的文件所属修改为www用户  

  5. [[email protected] html]# vim index.php    #检查php  

  6. <?php  

  7. phpinfo();  

  8. ?>  

  9. [[email protected] conf]# /application/apache/bin/apachectl graceful   #重启apache  

刷新浏览器

9、安装kodeplorer网盘

  1. [[email protected] html]# wget http://static.kodcloud.com/update/download/kodexplorer4.25.zip  

  2. #从官方下载网盘的包  

  3. [[email protected] html]# unzip kodexplorer4.25.zip    #解压  

刷新浏览器页面

根据提示执行chmod -R 777 /application/apache2.2.31/html/

再次刷新,环境检测成功,设置管理员密码等进行后续操作