标签:lamp
httpd 2.4.7 + mysql-5.5.23 + php-5.4.13编译安装过程:
一、编译安装apache
1、解决依赖关系
yum -y install gcc*
yum -y install pcre
yum -y install openssl-devel
httpd-2.4.7需要较新版本的apr-1.5.1和apr-util-1.5.4
(1) 编译安装apr
# tar -jxf apr-1.5.1.tar.bz2
# cd apr-1.5.1
# ./configure --prefix=/usr/local/apr
# make && make install
(2) 编译安装apr-util
# tar -jxf apr-util-1.5.4.tar.bz2
# cd apr-util-1.5.4
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
# make && make install
2、编译安装httpd-2.4.7
# tar -jxf httpd-2.4.7.tar.bz2
# cd httpd-2.4.7
# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-cgid --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、修改path环境变量,以能够识别此程序的二进制文件路径
vim /etc/profile.d/apache.sh
export PATH=$PATH:/usr/local/apache/bin
4、默认情况下,系统搜索库文件的路径/lib,/usr/lib;要增添额外搜寻路径
vim /etc/ld.so.conf.d/apache.conf
/usr/local/apache/modules
ldconfig -v
5、头文件:#include 把头文件连接到/usr/include下
ln -sv /usr/local/apache/include/* /usr/include/
6、man文件路径:安装在--prefix指定的路径下,不在标准路径,/usr/share/man如果想使用man就必须做如下操作
vim /etc/man.config
MANPATH /usr/local/apache/man
7、修改httpd的主配置文件,设置其Pid文件的路径
编辑/etc/httpd/httpd.conf,添加如下行即可:
PidFile "/var/run/httpd.pid"
8、提供SysV服务脚本/etc/rc.d/init.d/httpd,内容如下:
#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi
# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d 10 $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
fi
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
exit $RETVAL
而后为此脚本赋予执行权限:
# chmod +x /etc/rc.d/init.d/httpd
加入服务列表:
# chkconfig --add httpd
二、编译安装apache
1、安装编译工具
yum -y install cmake
yum -y install bison
2、安装ncurses-5.9
cd /lamp/ncurses-5.9
./configure --with-shared--without-debug --without-ada --enable-overwrite
make
make install
3、安装mysql-5.5.23
cd /lamp/mysql-5.5.23
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306
make && make install
cd /usr/local/mysql/
chown -R mysql .
chgrp-R mysql .
#修改mysql目录权限
/usr/local/mysql/scripts/mysql_install_db--user=mysql
#创建数据库授权表,初始化数据库
chown-R root .
chown -R mysql data
#修改mysql目录权限
cpsupport-files/my-medium.cnf /etc/my.cnf
#复制mysql配置文件
启动MySQL服务:
1.用原本源代码的方式去使用和启动mysql
/usr/local/mysql/bin/mysqld_safe--user=mysql &
2.重启以后还要生效:
vi/etc/rc.local
/usr/local/mysql/bin/mysqld_safe--user=mysql &
3.设定mysql密码
/usr/local/mysql/bin/mysqladmin-uroot password 123
清空历史命令 history -c
* 给mysql用户root加密码123
* 注意密码不能写成 “123”
/usr/local/mysql/bin/mysql -u root -p
mysql>showdatabases;
mysql>usetest;
mysql>showtables;
mysql>\s #查看字符集是否改为utf8
* 进入mysql以后用set来改密码
mysql> exit
* 登录MySQL客户端控制台设置指定root密码
标签:lamp
原文地址:http://learnlinux.blog.51cto.com/9320044/1612642