首页 > 代码库 > Centos6部署lamp: httpd2.4+module模式
Centos6部署lamp: httpd2.4+module模式
系统: Centos6
httpd版本: 2.4 使用event工作模式
php版本: 5.4.26
mariadb版本: 5.5.46
xcache版本: 3.0.3
安装顺序: php最后安装
一、准备源码包:
二、安装httpd:
1.安装所需环境
yum groupinstall -y"Development tools" "Server Platform Development"
yum install -y pcre-devel
2. 安装apr
tar -xjvf apr-1.5.0.tar.bz2
cd apr-1.5.0
./configure--prefix=/usr/local/apr
make & make install
tar -xjvfapr-util-1.5.3.tar.bz2
cd apr-util-1.5.3
./configure--prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
3. 安装httpd
tar -xjvf httpd-2.4.9.tar.bz2
cd httpd-2.4.9
./configure --prefix=/usr/local/apache--sysconf=/etc/httpd24--enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util/--enable-modules=most--enable-mpms-shared=all --with-mpm=event
//默认使用event工作模式
make && make install
4. 后续工作
vim/etc/profile.d/http24.sh
./etc/profile.d/http24.sh
ln -s /usr/local/apache/include//usr/include/httpd24
echo"MANPATH /usr/local/apache/man/" >> /etc/man.config
cp/etc/rc.d/init.d/httpd /etc/rc.d/init.d/httpd24
vim/etc/rc.d/init.d/httpd24
vim/etc/httpd24/httpd.conf
chkconfig--add httpd24
chkconfig--level 35 httpd24 on
servicehttpd24 start
三、安装mariadb:
1.准备mysql组和用户
groupadd -r -g 306 mysql
useradd -r -g mysql -u 306 mysql
2. 部署mariadb
tar-xzvf mariadb-5.5.46-linux-x86_64.tar.gz -C /usr/local/
ln -s/usr/local/mariadb-5.5.46-linux-x86_64/ /usr/local/mysql
cd/usr/local/mysql/
chown-R root:mysql ./*
3. 初始化数据库
mkdir-p /mydata/data
chown mysql:mysql /mydata/data/ //准备数据库存放目录
/usr/local/mysql/scripts/mysql_install_db--user=mysql --basedir=/usr/local/mysql --datadir=/mydata/data/
//指定mariadb目录和数据库存放目录
4. 准备配置文件
mkdir/etc/mysql
cp/usr/local/mysql/support-files/my-large.cnf /etc/mysql/my.cnf
vim /etc/mysql/my.cnf
5. 后续工作
vim /etc/profile.d/mysqld.sh
. /etc/profile.d/mysqld.sh
echo ‘/usr/local/mysql/lib/‘> /etc/ld.so.conf.d/mysqld.conf
ldconfig
ln -s/usr/local/mysql/include/mysql/ /usr/include/mysqld
echo ‘MANPATH/usr/local/mysql/man/‘ >> /etc/man.config
cp/usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on //设置开机启动
service mysqld start
6. 安全初始化
/usr/local/mysql/bin/mysql_secure_installation
四、安装PHP:
1.解决依赖关系
yum install -y bzip2-devellibmcrypt-devel libxml2-devel
2. 安装PHP
tar -xjvf php-5.4.26.tar.bz2
cd php-5.4.26
./configure --prefix=/usr/local/php--with-mysql=/usr/local/mysql --with-openssl--with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring--with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib--with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc/php--with-config-file-scan-dir=/etc/php/php.d --with-bz2 --enable-maintainer-zts
//使php支持多线程
make && make install
mkdir /etc/php //用于存放php配置文件,要和编译时指定的一致
cp php.ini-production/etc/php/php.ini
3. 配置hpttd
vim /etc/httpd24/httpd.conf
service httpd24 reload //重载配置
测试
vim /usr/local/apache/htdocs/index.php //测试php页面
vim/usr/local/apache/htdocs/db.php //测试连接mariadb
五、整合xcache:
1.安装xcache
tar -xjvf xcache-3.0.3.tar.bz2cd xcache-3.0.3
/usr/local/php/bin/phpize //生成configure
./configure --enable-xcache--with-php-config=/usr/local/php/bin/php-config
make && make install
2.整合xcache
mkdir /etc/php/php.d //用于存放配置文件,要和编译php时指定的路径一致
cp xcache-3.0.3/xcache.ini/etc/php/php.d //复制配置文件
vim /etc/php/php.d/xcache.ini
service httpd24 reload //重载配置文件
Centos6部署lamp: httpd2.4+module模式