首页 > 代码库 > lamp 环境安装

lamp 环境安装

mkdir /media/CentOS
mount /dev/cdrom /media/CentOS

依赖:
yum --disablerepo=\* --enablerepo=c6-media install gcc gcc-c++

安装apr
tar zxvf apr-1.5.2.tar.gz
cd apr-1.5.2
./configure --prefix=/usr/local/apr
make && make install

安装apr-util
tar zxvf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install

安装pcre
tar zxvf pcre-8.39.tar.gz
cd pcre-8.39
./configure --prefix=/usr/local/pcre
make && make install

安装Apache
tar zxvf httpd-2.4.20.tar.gz
cd httpd-2.4.20
./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
# 启动服务
/usr/local/apache/bin/apachectl -k start|stop|restart

#添加到守护进程
cp bin/apachectl /etc/init.d/apache
chkconfig --add apache #apache目录下

安装PHP(Apache模块)
yum --disablerepo=\* --enablerepo=c6-media install gcc gcc-c++ libxml2 libxml2-devel autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel
# 修改Apache的apxs
vi /usr/local/apache/bin/apxs
将第一行改为:#!/usr/bin/perl -w
保存退出
tar zxvf php-5.6.22.tar.gz
cd php-5.6.22
# 64位
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-zlib --with-pdo-mysql --enable-mbstring --with-gd --with-png-dir=/usr/lib64 --with-jpeg-dir=/usr/lib64 --with-freetype-dir=/usr/lib64

# 32位
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-zlib --with-pdo-mysql --enable-mbstring --with-gd

make && make install
# 配置PHP与Apache的关联
vi /usr/local/apache/conf/httpd.conf
# 加入 在 加载了PHP模块之后
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
# 保存,退出,重启
/usr/local/apache/bin/apachectl -k restart
# 添加PHP配置文件
cp ~/package/php/php.ini-development /usr/local/php/lib/php.ini
vi /usr/local/php/lib/php.ini
修改:date.timezone=PRC
# 重启apache
/usr/local/apache/bin/apachectl -k restart

#将php和Apache的bin目录设置到环境变量中
vi /etc/profile
最后一行添加export PATH="$PATH:/usr/local/php/bin:/usr/local/apache/bin"
source /etc/profile

//MySQL
# 依赖
yum --disablerepo=\* --enablerepo=c6-media install gcc gcc-c++ cmake ncurses-devel
# 安装
tar zxvf mysql-5.6.31.tar.gz
cd mysql-5.6.31
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data
make && make install
# 配置MySQL
cd /usr/local/mysql-5.6.31
groupadd mysql
useradd -r -g mysql mysql
chown -R mysql .
chgrp -R mysql .
# 删除可能的旧的/etc/my.cnf
rm -f /etc/my.cnf
./scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
cp support-files/my-default.cnf /etc/my.cnf

# 启动mysqld:
bin/mysqld_safe --user=mysql &
# 客户端登录
bin/mysql -uroot -p
# 初始无密码,登陆后可以重置root密码
update mysql.user set password=password(‘hellokang‘) where user=‘root‘;

守护进程
mysql 目录下
cp support-files/mysql.server /etc/init.d/mysqld
vi /etc/init.d/mysqld
添加
#chkconfig:2345 64 36
#description: A very fast and reliable SQL database engine

chkconfig --add mysqld

 

lamp 环境安装