设为首页 收藏本站
查看: 1037|回复: 0

[经验分享] 在centos6.5上编译安装LAMP

[复制链接]

尚未签到

发表于 2018-4-24 12:05:04 | 显示全部楼层 |阅读模式
  LAMP组合的编译安装
  基于centos6.5实现
httpd+php
  modules把php编译成httpdDSO对象
prefork:libphp5
event,worker:libphp5-zts
  cgi
  fastcgifpm:php作为独立的服务
httpd对fastcgi协议的支持
httpd-2.2需要额外安装fcgi模块
httpd-2.4自带fcgi模块

安装次序
httpdMariadbphp

安装开发环境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默认安装目录
DSC0000.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
DSC0001.png
将上如中的参数修改如下
DSC0002.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
解决办法
DSC0003.png
hash -r
service httpd start
ss -tnl
ps aux|grep httpd验证是否运行event进程
DSC0004.png
查看80端口是否被占用ss -tnl
关闭selinux
如果访问不了清空一下访问规则
iptables -L -n
iptables -F
setenforce 0
service httpd start
httpd -M 查看装载的模块
cd /etc/httpd24目录
vim httpd.conf下启用或禁用某一模块
DSC0005.png


DSC0006.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
DSC0007.png
#cp support-files/mysql.server /etc/rc.d/init.d/mysqld
#chkconfig --add mysqld
#service mysqld start
DSC0008.png
#ss -tnl
DSC0009.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
DSC00010.png
make && make install
用-z多启用几个线程
说明
这里为了支持apache的workerevent这两个MPM编译时使用了--enable-maintainer-zts选项。
如果视频PHP5.3以上版本为了连接MySQL数据库可以指定mysqlnd这样在本机就不需要先安装MySQLMySQL开发包了。mysqlndphp5.3开始可用可以编译时绑定到它而不用和具体的MySQL客户端绑定形成依赖但从PHP5.4开始它就是默认设置了。


为php提供配置文件
cp php.ini-production /etc/php.ini
DSC00011.png
问题service httpd24 reload
Reloadinghttpd:             [FAILED]
解决办法
修改httpd.pid的位置
DSC00012.png
vim /etc/rc.d/init.d/httpd24
DSC00013.png
改为
DSC00014.png


3.编辑apache配置文件httpd.conf,apache支持php
cd /etc/httpd24
cp httpd.conf{,.bak}
vim httpd.conf.bak
首先确保
DSC00015.png
其次添加如下两行
AddType application/x-httpd-php.php
AddType application/x-httpd-php-spurce.phps
定位至DirectoryIndex index.html
修改为:
DirectoryIndexindex.phpindex.html
而后重新启动httpd或让其重新载入配置文件即可测试php是否已经可以正常使用。
DSC00016.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();
?>
DSC00017.png








  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-451380-1-1.html 上篇帖子: CentOS6系列docker安装遇到的问题与解决 下篇帖子: 如何用U盘安装CentOS7系统?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表