在centos6.5上编译安装LAMP

前端之家收集整理的这篇文章主要介绍了在centos6.5上编译安装LAMP前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

LAMP组合的编译安装

@H_404_7@基于centos6.5实现

httpd+PHP

@H_404_7@module@H_404_7@sPHP编译成httpdDSO对象

@H_404_7@prefork:libPHP5

@H_404_7@event,worker:libPHP5-zts

cgi

fastcgi@H_404_7@fpm@H_404_7@:PHP作为独立的服务

@H_404_7@httpdfastcgi协议的支持

@H_404_7@httpd-2.2需要额外安装fcgi模块

@H_404_7@httpd-2.4自带fcgi模块

@H_404_7@

@H_404_7@安装次序

@H_404_7@httpdMariadbPHP

@H_404_7@

安装开发环境@H_404_7@httpd安装依赖pcre因此要安装pcre-devel

1.yum groupinstall "Development Tools" "Server Platform Development" -y

yum install pcre-devel -y

2.安装新版apr

#tar xf apr-1.5.0.tar.bz2

#cd apr-1.5.0

#ls

#./configure --prefix=/usr/local/apr为了防止覆盖系统已安装的版本

#make && make install

安装新版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

httpd的编译安装

#tar xf httpd-2.4.9.tar.bz2

#cd httpd-2.4.9

#groupadd -r apache添加系统组

#useradd -r -g apache apache添加系统用户

#id apache

注意首先安装pcre-devel

yum -y install pcre-devel

#./configure --help|less

#./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=event

注意--sysconfdir=/etc/httpd24默认配置文件目录

--prefix=/usr/local/apache默认安装目录

wKiom1gWBESyeM4fAATIgnoFefQ062.png

#make && make install

#cd /etc/rc.d/init.d/

发现/etc/rc.d/init.d/下没有httpd这个文件执行rpm -q httpd命令提示package httpd is not installed即需要安装httpd包执行yum install httpd* -y

#cp httpd httpd24

#vim httpd24

wKioL1gWBG_CtQ81AADbQcZgKF8284.png

将上如中的参数修改如下

wKioL1gWBHyyO3FpAADx6tCmTq8462.png

chkconfig --add httpd24

chkconfig --list httpd24

chkconfig httpd24 on

启动服务

/usr/local/apache/bin/apachectl

提示错误

AH00558: httpd: Could not reliably determine the server's fully qualified domain name,using ::1. Set the 'ServerName' directive globally to suppress this message

解决办法

如果想使用apachectl启动服务需要

vim /etc/profile.d/httpd.sh

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

./etc/profile.d/httpd.sh重读配置文件

echo $PATH

httpd -t

提示错误httpd: Could not reliably determine the server's fully qualified domain name,using ::1 for ServerName

Syntax OK

解决办法

wKiom1gWBIuDN2WBAAATdzfhgfY383.png

hash -r

service httpd start

ss -tnl

ps aux|grep httpd验证是否运行event进程

wKioL1gWBJ6QUIKdAAAXvp1G9iU597.png

查看80端口是否被占用ss -tnl

关闭selinux

如果访问不了清空一下访问规则

iptables -L -n

iptables -F

setenforce 0

service httpd start

httpd -M 查看装载的模块

cd /etc/httpd24目录

vim httpd.conf下启用或禁用某一模块

wKioL1gWBLDSGwckAAKV3zwOh-0332.png

wKiom1gWBLzSGjcAAABFvoypByk667.png

3.安装mariadbl

#tar xf mariadb-5.5.36-linux-i686.tar.gz -C /usr/local

#mkdir -pv /mydata/data

#useradd -r MysqL

#chown -R MysqL.MysqL /mydata/data/

#cd /usr/local

# ln -sv mariadb-5.5.36-linux-i686 MysqL

#cd MysqL

#chown -R root.MysqL ./*

#

#[root@localhost MysqL]#scripts/MysqL_install_db --datadir=/mydata/data/ --user=MysqL 初始化操作

提示错误-bash: scripts/MysqL_install_db: No such file or directory

解决办法

发现先前安装的mariadb版本为mariadb-10.0.13.tar换包。

#mkdir /etc/MysqL

#cp support-files/my-large.cnf /etc/MysqL/my.cnf

#vim /etc/MysqL/my.cnf

wKiom1gWBMnh8GErAADwsZjmyhY800.png

#cp support-files/MysqL.server /etc/rc.d/init.d/MysqLd

#chkconfig --add MysqLd

#service MysqLd start

wKioL1gWBNeRVfenAAAJJB9NvhA688.png

#ss -tnl

wKioL1gWBOTwzYxsAAAd6XNuCdI060.png

#/usr/local/MysqL/bin/MysqL

# MysqL_secure_installation安全初始化(方法)

提示-bash: MysqL_secure_installation: command not found

解决办法

#yum install MysqL* -y

再次执行MysqL_secure_installation

4.安装PHPl

#cd /mnt

#tar xf PHP-5.4.26.tar.bz2

# cd PHP-5.4.26

解决依赖关系

请配置好yum源系统安装源及epel后执行如下命令

yum -y groupinstall Desktop Platform Development

yum -y install bzip2-devel libmcrypt-devel libxml2-devel

编译安装PHP-5.4.26

首先下载源码包至本地目录

tar xf PHP-5.4.26

cd PHP-5.4.26

./configure --prefix=/usr/local/PHP --with-MysqL=/usr/local/MysqL --with-openssl --with-MysqL=/usr/local/MysqL/bin/MysqL_config --enable-mbstring --with-freeytpe-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

报错

configure: error: xml2-config not found. Please check your libxml2 installation.

解决办法yum install libxml2-devel -y

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

解决办法yum install libmcrypt libmcrypt-devel mcrypt mhash -y

configure: error: Cannot find MysqL header files under /usr/local/MysqL/bin/MysqL_config

Note that the MysqL client library is not bundled anymore!

解决办法

--with-MysqL=/usr/local/MysqL/bin/MysqL_config改为--with-MysqL

wKiom1gWBQrwEvRdAABGlOfF-rE635.png

make && make install

-z多启用几个线程

说明

这里为了支持apacheworkerevent这两个MPM编译时使用了--enable-maintainer-zts选项。

如果视频PHP5.3以上版本为了连接MysqL数据库可以指定MysqLnd这样在本机就不需要先安装MysqLMysqL开发包了。MysqLndPHP5.3开始可用可以编译时绑定到它而不用和具体的MysqL客户端绑定形成依赖但从PHP5.4开始它就是默认设置了。

PHP提供配置文件

cp PHP.ini-production /etc/PHP.ini

wKiom1gWBRii3aRqAABbjWkYD0Y337.png

问题service httpd24 reload

Reloadinghttpd: [Failed]

解决办法

修改httpd.pid的位置

wKioL1gWBSzwddpoAAAMSCZ1LH0857.png

vim /etc/rc.d/init.d/httpd24

wKioL1gWBTjx49xCAAAey9EsofE888.png

改为

wKiom1gWBULxvu09AAAfUNF5nj8790.png

3.编辑apache配置文件httpd.conf,apache支持PHP

cd /etc/httpd24

cp httpd.conf{,.bak}

vim httpd.conf.bak

首先确保

wKioL1gWBUvh8iNCAAArVX_YQUA893.png

其次添加如下两行

AddType application/x-httpd-PHP.PHP

AddType application/x-httpd-PHP-spurce.PHPs

定位至DirectoryIndex index.html

修改:

DirectoryIndexindex.PHPindex.html

而后重新启动httpd或让其重新载入配置文件即可测试PHP是否已经可以正常使用。

wKioL1gWBVbw6ArRAAAldo_If8o726.png

cd /usr/local/apache/

cd htdocs/

mv index.html index.PHP

vim index.PHP

测试页面index.PHP示例如下

<?PHP

$conn = MysqL_connect('127.0.0.1','root','beijing');

if($conn)

echo "ok";

else

echo "Failure";

MysqL_close();

PHPinfo();

?>

wKiom1gWBWTCwUGCAACcKxjRAkM139.png

猜你在找的CentOS相关文章