php 5.4.26.tar.bz2,LAMP平台编译安装

LAMP编译安装

一,编译安装httpd-2.4.9

二,给编译安装的httpd提供SysV服务启动脚本三, 编译安装mysql-5.5.33四,编译安装php-5.4.26五, 配置LAMP

一:编译安装httpd-2.4.9

需要的包组:apr-1.5.0.tar.bz2;apr-util-1.5.3.tar.bz2;httpd-2.4.9.tar.bz2

1)解决依赖关系编译安装apr-1.5.0.tar.bz2,apr-utiltar xf apr-1.5.0.tar.bz2

cd 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之前由于要用到pcre,所以在编译之前要把pcre-devel装上。有时遇到openssl版本过低不能编译成功时解决方法把openssl-devel装上。

3) 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-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=ev

ent

make && make install

4)修改httpd的主配置文件,设置其Pid文件的路径

pid文件的作用:防止进程启动多个副本。只有获得pid文件(固定路径固定文件名)写入权限(F_WRLCK)的进程才能正常启动并把自身的PID写入该文件中。其它同一个程序的多余进程则自动退出。编辑/etc/httpd/httpd24.conf,添加:PidFile  "/var/run/httpd.pid"

5)提供SysV服务脚本/etc/rc.d/init.d/httpd24,内容如下:#!/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|h

elp|configtest}"

exit 1

esac

exit $RETVAL

而后为此脚本赋予执行权限:chmod +x /etc/rc.d/init.d/httpd24

加入服务列表:chkconfig --add httpd24

接下来就可以启动服务进行测试了。

2b907de466bf97e573077f9978fc2aaa.png

二:二进制安装mysql-5.5.33

1)解压下载来的mysql软件到 /usr/local下tar xf mariadb-5.5.36-linux-x86_64.tar.gz -C /usr/local

2)创建RAID 挂载逻辑卷/mydata 创建存放数据的目录data;编辑/etc/fstab设置分区开机挂载。

3)创建mysql用户及修改存放数据目录的属主属组groupadd -r mysql ;useradd -g mysql -r mysql

chown -R mysql.mysql /mydata/data/

4)为解压的文件创建连接文件mysql;修改解压出的文件的属组,属主。cd /usr/local ;  ln -sv mariadb-5.5.36-linux-x86_64 mysql

cd mysql ; chown -R root.mysql ./*

5)mysql数据的初始化cd /usr/local/mysql ;

scripts/mysql_install_db --user=mysql --datadir=/mydata/data

5)创建mysql的主配置文件;并修改此文件中thread_concurrency的值为你的CPU个数乘以2,比如这里使用如下行:另外还需要添加如下行指定mysql数据文件的存放位置:datadir = /mydata/datamkdir /etc/mysql

cp support-files/my-large.cnf /etc/mysql/my.cnf

vim /etc/mysql/my.cnf

thread_concurrency = 2

datadir = /mydata/data

7)创建mysqld,启动脚本cd /usr/local/mysql

cp support-files/mysql.server  /etc/rc.d/init.d/mysqld

chmod +x /etc/rc.d/init.d/mysqld

chkconfig --add mysqld

chkconfig --list mysqld

service mysqld start

8)读取mysql客户端的配置文件vim /etc/profile.d/mysql.sh

export PATH=/usr/local/mysql/bin:$PATH

source /etc/profile.d/mysql.sh

9)连接mysql的头文件ln -sv /usr/local/mysql/include/ /usr/include/mysql

10)读取mysql的库文件vim /etc/ld.so.conf.d/mysql.conf

写入/usr/local/mysql/lib

11)测试能否进入mysql

77037846247eebbab82d113106dfcae4.png

三:编译安装php-5.4.26

1)解决依赖关系yum -y groupinstall "Desktop Platform Development"

yum -y install bzip2-devel libmcrypt-devel

2)编译安装php-5.4.26

编译这一部时可能会遇到一些包组没安装的问题按照提示安装上相应的包组就行了如我这里检查时出现了

130db16fec3e38d4b593b5488fac135c.png

意思说没有安装libxml2包,通过检测查处系统有

851e4d53286341d716c6243826e3549f.png

通过yum install libxml2-devel 就可以解决问题。

83747dfff6f7754b4d525cbed99fc946.pngtar 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-jpe

g-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 test

make intall

3)为php提供配置文件cp php.ini-production /etc/php.ini

4)编辑apache配置文件:httpd.conf,以apache支持phpvim /etc/httpd/httpd.conf

1、添加如下二行

AddType application/x-httpd-php  .php

AddType application/x-httpd-php-source  .phps

2、定位至DirectoryIndex index.html

修改为:

DirectoryIndex  index.php  index.html

5)在数据库内创建数据库用户.并给此数据库用户授权。create database wpdata

create user 'wp'@127.0.0.1 #创建用户。

grant all on wpdata.* to 'wp'@'127.0.0.1' identified by '123';#给wp用户在wpdata数据库下的所有表授所有的权限

6)提供测试页面编辑,在/usr/local/apache/htdocs创建index.php测试页面index.php示例如下:

$link = mysql_connect('127.0.0.1','wp','123');

if ($link)

echo "Success...";

else

echo "Failure...";

mysql_close();

?>

52fe861376ee2951c512847cc4e285c4.png

四:安装phpMyAdmin

1)把phpMyAdmin解压到/usr/local/apache/htdocs 下重命名为phpadm

2)把里面的config.sample.inc.php 重命名为 config.inc.php

3)

ef29d56ad5c1df3e85c6f0dd16bca585.png

五:安装Wordpress

1)解压wordpress到/usr/local/apache/htdocs 下

2)打开Wordpress提示

34f47ee6018a6e151f191763913e3a63.png

3)把wordpress下的wp-config-simple.php 修改为wp-config.php  并配置此文件。

3a7b279f7bf36b4d66c0eb2b25591edb.png

4)再次打开worepress

e1b4b8b0b41074c5b365d94d8150b2f0.png

六:安装xcache

xcache 是通过缓存来提高php的响应速度

1)先对phpadm/index.php进行压力测试

ab -n 200 -c 20 http://172.16.16.5/phpadm/index.php

2ccfe0f09058a10bff96c5572d7e4913.png

经过多次测试网页在20次并发200次访问时响应的速度为25左右

2)添加xcache模块编译安装xczchetar xf xcache-3.0.3.tar.gz

cd xcache-3.0.3

/usr/local/php/bin/phpize

./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config

make && make install

安装结束时,会出现类似如下行:

Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20100525/

mkdir /etc/php.d

cp xcache.ini /etc/php.d

接下来编辑/etc/php.d/xcache.ini,找到extension开头的行,修改为如下行:

extension = /usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so

3)重新测试下看能否显示xcache

0f1d96c1a6d88b7925849ab98d2d8dbd.png

5)测试访问速度是否增加

efc98159f47a1aa24208ccfd2293b238.png

多次测试求得平均值为95左右访问速度明显提高。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值