日期:2014-05-16  浏览次数:20644 次

linux > linux 完整 搭建 LAMP 环境

http://zhaoyun.blog.51cto.com/2090116/389770

文件目录
wget http://demo.muuqi.com/lamp/httpd-2.4.1.tar.bz2
wget http://demo.muuqi.com/lamp/mysql-5.6.4-m7.tar.gz
wget http://demo.muuqi.com/lamp/php-5.4.7.tar.bz2

解压后移动到/usr/local/src/目录中

安装apache-------------------------------------
cd httpd-2.4.1
./configure --prefix=/usr/local/apache --enable-so --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr_util/ --with-pcre=/usr/local/pcre/;make;make install

安装apache 提示APR 错误
wget http://apache.dataguru.cn//apr/apr-1.4.6.tar.bz2
./configure --prefix=/usr/local/apr;make;make install

安装apache 提示APR-util 错误
wget http://mirrors.cnnic.cn/apache//apr/apr-util-1.5.1.tar.gz
./configure -prefix=/usr/local/apr_util/ -with-apr=/usr/local/apr/;make;make install?? /* /usr/local/apr/? 检测apr 安装所在目录 */

安装pcre
wget http://demo.muuqi.com/lamp/pcre-8.10.tar.gz
./configure --prefix=/usr/local/pcre;make;make install

vim /usr/local/apache/conf/httpd.conf
修改 ServerName 199.71.213.85:80

cd /usr/local/apache/bin
./apachectl restart

目录所在
/usr/local/apache/htdocs


安装mysql -------------------------------------------
按下所需系统库文件,创建mysql安装目录和数据目录,创建用户和用户组与赋予数据存放目录权限
yum –y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml*
mkdir -p /usr/local/mysql
mkdir -p /data/mysql
groupadd mysql
useradd -g mysql mysql
chown mysql.mysql -R /data/mysql

安装cmake(mysql5.5需要通过cmake编译)
wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
./configure --prefix=/usr/local/cmake;make;make install
/*提示 cmake command not found */
export PATH=/usr/local/cmake/bin:$PATH
/*提示 Could NOT find Curses 错 */
yum install ncurses-devel??
yum install bison

cd /usr/local/src/mysql-5.6.4-m7
rm CMakeCache.txt
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql && make && make install
cd /usr/local/mysql
初始化mysql数据库
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
复制配置文件
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld

启动mysql服务
/etc/init.d/mysqld start

使用root 初始登陆
/usr/local/mysql/bin/mysql -u root -p

修改root密码
use mysql;
update user set password=PASSWORD("123456") where user='root';
FLUSH PRIVILEGES;

退出MYSQL命令: exit (回车)。

安装PHP -----------------------------
安装libxml2
wget http://bungeni-portal.googlecode.com/files/libxml2-2.6.32.tar.gz
./configure --prefix=/usr/local/libxml2;make;make install

php:
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs --with-libxml-dir=/usr/local/libxml2;make;make install

copy 配置文件
cp /usr/local/src/php-5.4.7/php.ini-production /usr/local/php/lib/php.ini


进入apache 配置文件httpd.conf
在有AddType附近添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps



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

编辑apache 配置文件
vim /usr/local/apache/conf/httpd.conf
重启apache
/usr/local/apache/bin/apachectl restart
进入网站跟目录
cd /usr/local/apache/htdocs
php的配置文件
vim /usr/local/php/lib/php.ini