码迷,mamicode.com
首页 > 其他好文 > 详细

LAMP一体环境快速安装

时间:2015-11-27 20:11:05      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:..

(一)安装Apache

1、下载安装

yum installzlib-devel -y
wgethttp://mirror.bit.edu.cn/apache/httpd/httpd-2.2.31.tar.gz
tar xfhttpd-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-rewrite
make
make install
ln -s/application/apache2.2.31/ /application/apache
ls -l/application/

2、启动服务,检查

/application/apache/bin/apachectlstart
netstat-lntup|grep httpd

3、配置基于域名的虚拟主机

cd/application/apache/conf/
vim httpd.conf 修改98行
ServerName127.0.0.1:80
修改132
<Directory"/application/apache2.2.31/html">
修改378
Includeconf/extra/httpd-mpm.conf
修改396
Includeconf/extra/httpd-vhosts.conf

==============================

[root@web02 conf]# cd extra/
[root@web02extra]# vim httpd-vhosts.conf
<VirtualHost*:80>
    ServerAdmin 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
</VirtualHost>
<VirtualHost*:80>
    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
</VirtualHost>
<VirtualHost*:80>
    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
</VirtualHost>

创建站点目录及测试文件

mkdir -p/application/apache2.2.31/html/{www,bbs,blog}
echowww.etiantian.org >/application/apache2.2.31/html/www/index.html
echobbs.etiantian.org >/application/apache2.2.31/html/bbs/index.html
echoblog.etiantian.org >/application/apache2.2.31/html/blog/index.html
mkdir /app/logs-p
/application/apache/bin/apachectl-t
/application/apache/bin/apachectlgraceful

4、配置客户端host解析到如下域名商,检查

curlwww.etiantian.org                 
curl bbs.etiantian.org
curlblog.etiantian.org

apache基于域名的虚拟主机配置成功。

==============================================

(二)搭建PHP,本地不装MYSQL

1、安装依赖包并检查

wget -O/etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum installzlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-develcurl-devel libxslt-devel libmcrypt-devel mhash mhash-devel mcrypt openssl-devel-y
 
rpm -qazlib-devel libxml2-devel libjpeg-turbo-devel freetype-devel libpng-devel gd-devellibcurl-devel libxslt-devel libmcrypt-devel mhash mhash-devel mcryptopenssl-devel
 
mkdir -p/home/oldboy/tools
cd/home/oldboy/tools
 
wgethttp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zxflibiconv-1.14.tar.gz
cd libiconv-1.14
./configure--prefix=/usr/local/libiconv
make
make install
cd ..

2、安装php(无需安装MySQL)

cd/home/oldboy/tools
tar xfphp-5.5.26.tar.gz
cd 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
make
make install
ln -s /application/php5.5.26//application/php
:
[root@web02php-5.5.26]# ll /application/apache/modules/
总用量 30568
-rw-r--r-- 1root root     9194 11月 10 20:37httpd.exp
-rwxr-xr-x 1root root 31285631 11月 10 23:51 libphp5.so
[root@web02php-5.5.26]# grep libphp5.so /application/apache/conf/httpd.conf
LoadModulephp5_module        modules/libphp5.so
[root@web02php-5.5.26]# cp php.ini-production /application/php/lib/php.ini

3、配置httpd.conf

311行下增加:
AddTypeapplication/x-httpd-php .php .phtml
AddTypeapplication/x-httpd-php-source .phps
168行下增加:
DirectoryIndexindex.php index.html
67行下增加
User www
Group www

建立用户:

useradd -u 513-s /sbin/nologin www
id www

 

/application/apache/bin/apachectl-t
/application/apache/bin/apachectlgraceful

检查PHP:

<?php
phpinfo();
?>
检查MySQL:
<?php
 $link_id=mysql_connect(‘db01.etiantian.org‘,‘wordpress‘,‘123456‘) ormysql_error();
    if($link_id){
           echo "mysql successful by oldboytraining!";
     }
     else{
           echo mysql_error();
     }
?>

检查MySQL:

<?php
  $link_id=mysql_connect(‘db01.etiantian.org‘,‘wordpress‘,‘123456‘) or mysql_error();
    if($link_id){
           echo "mysql successful by oldboy training!";
     }
     else{
           echo mysql_error();
     }
?>

LAMP搭建完成。


本文出自 “有位青年后青春期的诗” 博客,转载请与作者联系!

LAMP一体环境快速安装

标签:..

原文地址:http://yunyouth.blog.51cto.com/10925807/1717542

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!