首页 > 代码库 > LAMP的简单编译安装
LAMP的简单编译安装
【二进制安装MariaDB】
1.展开程序
#tar xf mariadb-5.5.32-linux-x86_64.tar.gz -C /usr/local/
2.进入解压后的文件夹
# cd /usr/local/mariadb-5.5.32-linux-x86_64/
3.创建数据存放目录
#mkdir -pv /mydata/data
4.创建安全登陆的用户和组
#groupadd -r mysql
#useradd -g mysql -r mysql
5.改变数据目录的属主属组
#chown -R mysql:mysql /mydata/data/
6.给解压目录创建软链接
#cd /usr/local
# ln -sv mariadb-5.5.32-linux-x86_64/ mysql
7.进入mysql目录下,并修改所有文件的属主属组
#cd mysql/
#chown -R root:mysql *
8.复制并修改mysql的配置文件
#mkdir /etc/mysql
# cp support-files/my-large.cnf /etc/mysql/my.cnf
#vim /etc/mysql/my.cnf//在[mysqld]下修改并填写
[mysqld]
thread_concurrency = 2
datadir = /mydata/data
9.初始化数据库
#scripts/mysql_install_db --user=mysql --datadir=/mydata/data
10.复制启动脚本文件到/etc/rc.d/init.d下
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
11.添加服务
# chkconfig --add mysqld
12.简单启动服务
# service mysqld start
13.填写命令所在的PATH路径,并查看man文档
# vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH
# source /etc/profile.d/mysql.sh
#man mysqld
===============================================
【HTTPD编译安装】
1、解决依赖关系
(1) 编译安装apr
# tar xf apr-1.5.0.tar.bz2
# cd apr-1.5.0
#vim configure
把RM=‘$RM‘改为RM=‘$RM -f‘
# ./configure --prefix=/usr/local/apr
# make && make install
# cd ..
(2) 编译安装apr-util
# tar xf apr-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
# cd ..
(3) httpd-2.4.9编译过程也要依赖于pcre-devel软件包,需要事先安装。此软件包系统光盘自带,因此,找到并安装即可。
#yum -y install pcre-devel
2、编译安装httpd-2.4.9
# tar xf httpd-2.4.9.tar.bz2
# cd httpd-2.4.9
# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --enable-so --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
# make && make install
3.修改httpd的主配置文件,设置其Pid文件的路径
#cd /etc/httpd24
#cp httpd.conf httpd.conf.bak
#vim /etc/httpd24/httpd.conf
PidFile "/var/run/httpd.pid"
4、提供SysV服务脚本/etc/rc.d/init.d/httpd24
#vim /etc/rc.d/init.d/httpd24
详细内容请参考/etc/rc.d/init.d/httpd脚本
5、赋予权限,添加服务,启动服务
# chmod +x /etc/rc.d/init.d/httpd24
# chkconfig --add httpd24
# service httpd24 start
-------------------------------------------------------------------------------------------
================================================================================
【PHP编译安装】
解决依赖关系
#yum -y groupinstall "Desktop Platform Development"
#yum -y install bzip2-devel libmcrypt-devel
#yum install openssl-devel
2.编译安装php
#tar xf 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 --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts
#make & make install
3.为php提供配置文件
#cp php.ini-production /etc/php.ini
4.编辑apache的主配置文件,以使apache支持php
#cd /etc/httpd24
#vim httpd.conf
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.html
5.重启httpd服务
#service httpd24 restart
6.测试是否支持php
#cd /usr/local/apache/htdocs/
#vim index.html
<?php
phpinfo();
?>
#mv index.html index.php
#service httpd24 restart
-------------------------------------------------------------------------------------------
===========================================================================================
本文出自 “riaair小筑” 博客,请务必保留此出处http://riaair.blog.51cto.com/9177337/1542803