一)LAMP架构
Linux Apache Mysql PHP/Perl/Python的简写。通常是Linux Apache Mysql PHp组合。 其实就是把Apache, MySQL以及PHP安装在Linux系统上,组成一个环境来运行php的脚本语言。
二)安装前提需要的开发包和包组。
通过yum安装,yum的配置参考http://shunzi.blog.51cto.com/8289655/1381676
yum -y install pcre-devel gcc* yum -y install bzip2-devel libmcrypt-devel yum -y groupinstall "Development tools" yum -y groupinstall "Server Platform Development" yum -y groupinstall "Desktop Platform Development"
三)安装apr和apr-util
http://apr.apache.org/download.cgi下载地址 tar xf apr-1.5.0.tar.bz2 cd /root/apr-1.5.0 ./configure --prefix=/usr/local/apr make && make install 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
四)安装httpd
先同步下时间clock -s让系统时间和硬件时间同步。不同步可能解httpd包的时候报错。
tar xf httpd-2.4.9.tar.bz2 cd /root/httpd-2.4.9 ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --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 make && make install
--prefix=/usr/local/apache 编译目录 --sysconfdir=/etc/httpd 安装目录 --enable-so 启用DSO --enable-ssl 启用ssl --enable-cgi 启用cgi版本的php --enable-rewrite 启用URL重写功能 --with-zlib 启用网络压缩功能 --with-pcre 为了支持rewrite重写功能 --enable-modules=most 启用常用的模块 --enable-mpms-shared=all 安装所有的工作模式 --with-mpm=event 启用event工作模式
1)导出头文件.
ln -sv /usr/local/apache/include /usr/include/httpd
2)配置man文档
vim /etc/man.config
3)配置二进制文件
echo "export PATH=/usr/local/apache/bin:$PATH" >> /etc/profile.d/httpd.sh source /etc/profile.d/httpd.sh
4)写个apache的启动脚本
cp /etc/rc.d/init.d/httpd /etc/rc.d/init.d/httpd24把yum安装的脚本copy一份。
vim /etc/httpd/httpd.conf 需要在主配置文件中添加个pid。
PS:
如果把yum安装的httpd卸载掉。PidFile "/var/run/httpd.pid"
修改脚本
PS:
pidfile /var/run/httpd.pid
脚本内容如下:
vim /etc/rc.d/init.d/httpd24
#!/bin/bash . /etc/rc.d/init.d/functions if [ -f /etc/sysconfig/httpd ]; then . /etc/sysconfig/httpd fi HTTPD_LANG=${HTTPD_LANG-"C"} INITLOG_ARGS="" apachectl=/usr/local/apache/bin/apachectl httpd=${HTTPD-/usr/local/apache/bin/httpd} prog=httpd pidfile=${PIDFILE-/var/run/httpd/httpd.pid} lockfile=${LOCKFILE-/var/lock/subsys/httpd} RETVAL=0 STOP_TIMEOUT=${STOP_TIMEOUT-10} 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 ${STOP_TIMEOUT} $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=6 echo $"not reloading due to configuration syntax error" failure $"not reloading $httpd due to configuration syntax error" else # Force LSB behaviour from killproc LSB=1 killproc -p ${pidfile} $httpd -HUP RETVAL=$? if [ $RETVAL -eq 7 ]; then failure $"httpd shutdown" fi fi echo } case "$1" in start) start ;; stop) stop ;; status) status -p ${pidfile} $httpd RETVAL=$? ;; restart) stop start ;; condrestart|try-restart) if status -p ${pidfile} $httpd >&/dev/null; then stop start fi ;; force-reload|reload) reload ;; graceful|help|configtest|fullstatus) $apachectl $@ RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}" RETVAL=2 esac exit $RETVAL
添加到服务中。并且启动apachetl
chmod +x /etc/init.d/httpd24 chkconfig --add httpd /etc/init.d/httpd24 start
apache安装完成。。。。。。。
——————————————————————————————————————
五)安装mysql
单独用一个磁盘。
pvcreate /dev/sda3
vgcreate vgmg /dev/sda3
lvcreate -L 8G -n lvmg vgmg
mke2fs -t ext4 /dev/vmgm/lvmg
mkdir /mydata/data -p
vim /etc/fstab
/dev/vgmg/lvmg /mydata/data ext4 defaults,noatime 0 0
mount -a
1)创建组名和用户名。
groupadd -r mysql
useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql
chown -R mysql:mysql /mydata/data/
tar xf mysql-5.5.33-linux2.6-x86_64.tar.gz -C /usr/local/
cd /usr/local/
ln -sv mysql-5.5.33-linux2.6-x86_64 mysql
cd mysql
chown -R mysql:mysql .
scripts/mysql_install_db --user=mysql --datadir=/mydata/data/ 初始化数据库
chown -R root .
cp support-files/my-large.cnf /etc/my.cnf
vim /etc/my.cnf
thread_concurrency = 2 物理cpu的两倍
datadir = /mydata/data
设置mysqld服务脚本
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start
定义man文件
vim /etc/man.config
MANPATH /usr/local/mysql/man
导出头文件
ln -sv /usr/local/mysql/include /usr/include/mysql
定义数据库
echo ‘/usr/local/mysql/lib‘ > /etc/ld.so.conf.d/mysql.conf
定义二进制
echo "export PATH=/usr/local/mysql/bin:$PATH" >> /etc/profile.d/mysqld.sh
source /etc/profile.d/mysqld.sh
六)安装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
cp php.ini-production /etc/php.ini
编辑apache配置文件httpd.conf支持php
vim /etc/httpd/httpd.conf
本文出自 “落叶飘远方” 博客,请务必保留此出处http://shunzi.blog.51cto.com/8289655/1381677
源码编译LAMP架构,phpMyadmin管理数据库,增加xcache加速功能,通过ab测试效果。,布布扣,bubuko.com