编译安装Apache httpd和php搭建KodExplorer网盘
环境说明:
系统版本 CentOS 6.9 x86_64
软件版本 httpd-2.2.31 php-5.5.26 kodexplorer4.25
1、创建规范目录
- [root@Web01 ~]# mkdir -p /service/tools #放软件包
- [root@Web01 ~]# mkdir /application #软件安装目录
2、编译安装httpd
- [root@Web01 ~]# cd /service/tools/
- [root@Web01 tools]# wget http://archive.apache.org/dist/httpd/httpd-2.2.31.tar.gz
- #从官方下载软件,要找到这个包也不容易
- [root@Web01 tools]# tar xf httpd-2.2.31.tar.gz #解压
- [root@Web01 tools]# cd httpd-2.2.31
- [root@Web01 httpd-2.2.31]# yum install gcc gcc-c++ glibc zlib-devel -y #安装编译器等
- [root@Web01 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
- [root@Web01 httpd-2.2.31]# echo $?
- 0 #编译完进行检查,输出为零,表示编译成功
- [root@Web01 httpd-2.2.31]# make && make install
- [root@Web01 httpd-2.2.31]# echo $?
- 0 #再次检查
- [root@Web01 httpd-2.2.31]# ln -s /application/apache2.2.31 /application/apache #创建软链接
- [root@Web01 httpd-2.2.31]# ls -l /application/ #查看软链接
- total 4
- lrwxrwxrwx 1 root root 26 May 12 15:27 apache -> /application/apache2.2.31
- drwxr-xr-x 15 root root 4096 May 12 15:27 apache2.2.31
3、配置
- [root@Web01 httpd-2.2.31]# /application/apache/bin/apachectl start #启动apache
- httpd: apr_sockaddr_info_get() failed for Web01 #出现错误提示
- httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
- [root@Web01 httpd-2.2.31]# vim /application/apache/conf/httpd.conf
- 行
- 将#ServerName www.example.com:80
- 修改为ServerName 127.0.0.1:80
浏览器访问10.0.0.7
- [root@Web01 httpd-2.2.31]# vim /application/apache/conf/httpd.conf
- 行
- 将<Directory "/application/apache2.2.31/htdocs">
- 修改为<Directory "/application/apache2.2.31/html">
- 行去掉#号
- Include conf/extra/httpd-mpm.conf
- 行去掉#号
- Include conf/extra/httpd-vhosts.conf
- [root@Web01 html]# vim /application/apache/conf/extra/httpd-vhosts.conf
- <VirtualHost *:80>
- ServerAdmin test@test.com #邮箱
- DocumentRoot "/application/apache2.2.31/html" #网站根目录
- ServerName 10.0.0.7 #主机名称或地址
- ServerAlias test #别名
- ErrorLog "/application/apache2.2.31/logs/www-error_log" #日志路径
- CustomLog "/application/apache2.2.31/logs/www-access_log" common
- </VirtualHost>
- [root@Web01 httpd-2.2.31]# mkdir -p /application/apache2.2.31/html
- #创建网站根目录
4、编译安装php依赖
- [root@Web01 httpd-2.2.31]# cd /service/tools/
- [root@Web01 tools]# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
- #从官网下载libiconv
- [root@Web01 tools]# tar xf libiconv-1.14.tar.gz #解压
- [root@Web01 tools]# cd libiconv-1.14
- [root@Web01 libiconv-1.14]# ./configure --prefix=/usr/local/libiconv #编译生成makefile
- [root@Web01 libiconv-1.14]# make && make install
5、编译安装php
- [root@Web01 libiconv-1.14]# cd /service/tools/
- [root@Web01 tools]# wget http://mirrors.sohu.com/php/php-5.5.26.tar.gz #下载
- [root@Web01 tools]# tar xf php-5.5.26.tar.gz #解压
- [root@Web01 tools]# cd php-5.5.26
- [root@Web01 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 #安装依赖,也可以不安装先编译,但是编译会提示出错缺少依赖,还是要安装
- [root@Web01 php-5.5.26]# cd ..
- [root@Web01 tools]# yum install epel-release -y #安装epel-release
- [root@Web01 tools]# yum install -y libmcrypt-devel
- #安装libmcrypt-devel,亲测只能先安装epel-release才能安装,网上别的方式会失败
- [root@Web01 tools]# cd php-5.5.26
- [root@Web01 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
- #编译php生成makefile
- [root@Web01 httpd-2.2.31]# echo $?
- 0
- [root@Web01 php-5.5.26]# make && make install
- [root@Web01 httpd-2.2.31]# echo $?
- 0
- [root@Web01 php-5.5.26]# ln -s /application/php5.5.26 /application/php #创建软链接
- [root@Web01 php-5.5.26]# ll /application/
- total 8
- lrwxrwxrwx 1 root root 26 May 12 15:27 apache -> /application/apache2.2.31/
- drwxr-xr-x 16 root root 4096 May 12 15:40 apache2.2.31
- lrwxrwxrwx 1 root root 22 May 12 15:59 php -> /application/php5.5.26
- drwxr-xr-x 7 root root 4096 May 12 15:58 php5.5.26
- [root@Web01 php-5.5.26]# ll /application/apache/modules/ #检查结果
- total 34772
- -rw-r--r-- 1 root root 9194 May 12 15:26 httpd.exp
- -rwxr-xr-x 1 root root 35592935 May 12 15:58 libphp5.so
- [root@Web01 php-5.5.26]# grep libphp5.so /application/apache/conf/httpd.conf
- LoadModule php5_module modules/libphp5.so
- [root@Web01 php-5.5.26]# cp php.ini-production /application/php/lib/php.ini #拷贝php.ini
6、配置httpd.conf
- [root@Web01 php-5.5.26]# cd /application/apache/conf/
- [root@Web01 conf]# vim httpd.conf
- 行下增加:
- AddType application/x-httpd-php .php .phtml
- AddType application/x-httpd-php-source .phps
- 行下增加:
- DirectoryIndex index.php index.html
- 行下增加
- User www
- Group www
7、建立用户
- [root@Web01 conf]# useradd -u 513 -s /sbin/nologin www
- [root@Web01 conf]# id www
- uid=513(www) gid=513(www) groups=513(www)
8、启动并检查
- [root@Web01 conf]# /application/apache/bin/apachectl -t #检查语法
- Syntax OK
- [root@Web01 conf]# cd /application/apache/html/
- [root@Web01 html]# chown -R www.www .. #将html目录及下面的文件所属修改为www用户
- [root@Web01 html]# vim index.php #检查php
- <?php
- phpinfo();
- ?>
- [root@Web01 conf]# /application/apache/bin/apachectl graceful #重启apache
刷新浏览器
9、安装kodeplorer网盘
- [root@Web01 html]# wget http://static.kodcloud.com/update/download/kodexplorer4.25.zip
- #从官方下载网盘的包
- [root@Web01 html]# unzip kodexplorer4.25.zip #解压
刷新浏览器页面
根据提示执行chmod -R 777 /application/apache2.2.31/html/
再次刷新,环境检测成功,设置管理员密码等进行后续操作
博主原创文章,转载请务必注明出处