因老男孩的某个在线学员需要,特此发布,更多内容参见:
老男孩的在线课程或博客首页公告
(一)安装Apache
1、下载安装
yum install zlib-devel -ywget http://mirror.bit.edu.cn/apache/httpd/httpd-2.2.31.tar.gztar xf httpd-2.2.31.tar.gz cd 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-rewritemakemake installln -s /application/apache2.2.31/ /application/apachels -l /application/
2、启动服务,检查
/application/apache/bin/apachectl startnetstat -lntup|grep httpd
3、配置基于域名的虚拟主机
cd /application/apache/conf/vim httpd.conf 修改98行ServerName 127.0.0.1:80修改132修改378 Include conf/extra/httpd-mpm.conf修改396 Include conf/extra/httpd-vhosts.conf
==============================
[root@web02 conf]# cd extra/[root@web02 extra]# vim httpd-vhosts.confServerAdmin oldboy@oldboyedu.com DocumentRoot "/application/apache2.2.31/html/www" ServerName www.etiantian.org ServerAlias etiantian.org ErrorLog "/app/logs/www-error_log" CustomLog "/app/logs/www-access_log" common ServerAdmin oldboy@oldboyedu.com DocumentRoot "/application/apache2.2.31/html/bbs" ServerName bbs.etiantian.org ErrorLog "/app/logs/bbs-error_log" CustomLog "/app/logs/bbs-access_log" common ServerAdmin oldboy@oldboyedu.com DocumentRoot "/application/apache2.2.31/html/blog" ServerName blog.etiantian.org ErrorLog "/app/logs/blog-error_log" CustomLog "/app/logs/blog-access_log" common
创建站点目录及测试文件
mkdir -p /application/apache2.2.31/html/{www,bbs,blog}echo www.etiantian.org >/application/apache2.2.31/html/www/index.htmlecho bbs.etiantian.org >/application/apache2.2.31/html/bbs/index.htmlecho blog.etiantian.org >/application/apache2.2.31/html/blog/index.htmlmkdir /app/logs -p/application/apache/bin/apachectl -t/application/apache/bin/apachectl graceful
4、配置客户端host解析到如下域名商,检查
curl www.etiantian.org curl bbs.etiantian.orgcurl blog.etiantian.org
apache基于域名的虚拟主机配置成功。
==============================================
(二)搭建PHP,本地不装MYSQL
1、安装依赖包并检查
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repoyum 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 -yrpm -qa zlib-devel libxml2-devel libjpeg-turbo-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libmcrypt-devel mhash mhash-devel mcrypt openssl-develmkdir -p /home/oldboy/toolscd /home/oldboy/toolswget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gztar zxf libiconv-1.14.tar.gzcd libiconv-1.14./configure --prefix=/usr/local/libiconvmakemake installcd ..
2、安装php(无需安装MySQL)
cd /home/oldboy/toolstar xf php-5.5.26.tar.gzcd 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-ftpmakemake installln -s /application/php5.5.26/ /application/php
检查结果:
[root@web02 php-5.5.26]# ll /application/apache/modules/总用量 30568-rw-r--r-- 1 root root 9194 11月 10 20:37 httpd.exp-rwxr-xr-x 1 root root 31285631 11月 10 23:51 libphp5.so[root@web02 php-5.5.26]# grep libphp5.so /application/apache/conf/httpd.confLoadModule php5_module modules/libphp5.so[root@web02 php-5.5.26]# cp php.ini-production /application/php/lib/php.ini
3、配置httpd.conf
311行下增加:AddType application/x-httpd-php .php .phtmlAddType application/x-httpd-php-source .phps168行下增加:DirectoryIndex index.php index.html67行下增加User wwwGroup www
建立用户:
useradd -u 513 -s /sbin/nologin www id www/application/apache/bin/apachectl -t/application/apache/bin/apachectl graceful
检查PHP:
检查MySQL:
LAMP搭建完成。
搭建博客产品略,见图: