阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

RHEL6.4 源码包编译安装LAMP环境

122次阅读
没有评论

共计 6797 个字符,预计需要花费 17 分钟才能阅读完成。

一,编译安装 httpd

1. 安装软件包

# tar zxf httpd-2.2.25.tar.gz

# cd httpd-2.2.25

# ./configure  –prefix=/usr/local/httpd  –enable-so  –enable-rewrite  –enable-cgi  –enable-ssl  –enable-charset-lite

————————————– 分割线 ————————————–

Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及设置 http://www.linuxidc.com/Linux/2013-06/86250.htm

CentOS 5.9 下编译安装 LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12) http://www.linuxidc.com/Linux/2013-03/80333p3.htm

RedHat 5.4 下 Web 服务器架构之源码构建 LAMP 环境及应用 PHPWind http://www.linuxidc.com/Linux/2012-10/72484p2.htm

LAMP 源码环境搭建 WEB 服务器 Linux+Apache+MySQL+PHP http://www.linuxidc.com/Linux/2013-05/84882.htm

LAMP+Xcache 环境搭建 http://www.linuxidc.com/Linux/2014-05/101087.htm

————————————– 分割线 ————————————–

配置参数用途:

–prefix=:指定安装目录

–enable-so:支持动态加载模块

–enable-rewrite:支持网站地址重写

–enable-cgi:支持 CGI 程序脚本

–enable-ssl:支持 SSL 加密

–enable-charset-lite:支持多语言编码

 

配置错误提示:

no SSL-C headers found

configure: error: …No recognized SSL/TLS toolkit detected

安装相应库文件

# yum -y install openssl-devel

# ./configure  –prefix=/usr/local/httpd  –enable-so  –enable-rewrite  –enable-cgi  –enable-ssl  –enable-charset-lite

# make && make install

 

2. 建立服务脚本

# cd /usr/local/httpd/bin/

# cp apachectl /etc/init.d/httpd

# vim /etc/init.d/httpd

#!/bin/sh

# chkconfig: 2345 85 35

# description:Apache is a world wide web server

……

# chkconfig –add httpd

# chkconfig –list httpd

httpd        0:off1:off2:on3:on4:on5:on6:off

 

3. 修改主配置文件及启动服务

# vim /usr/local/httpd/conf/httpd.conf

ServerName www.linuxidc.com:80

# service httpd start

[root@client bin]# netstat -ln | grep :80

tcp        0      0 :::80                      :::*                        LISTEN     

 

 

 

二. 编译安装 mysql

1. 添加运行用户

# useradd -M -u 49 -s /sbin/nologin mysql

 

2. 安装软件包

# tar zxf mysql-5.1.62.tar.gz

# cd mysql-5.1.62

# ./configure  –prefix=/usr/local/mysql –with-charset=utf8  –with-collation=utf8_general_ci  –with-extra-charsets=gbk,gb2312

 

配置参数用途:

–prefix=:指定安装目录

–with-charset=utf8:指定默认字符集

–with-collation=utf8_general_ci:指定默认的校对规则集

–with-extra-charsets=gbk,gb2312:设置支持的其他字符集

 

配置错误信息:

checking for termcap functions library… configure: error: No curses/termcap library found

安装库文件

# yum -y install ncurses-devel libtermcap-devel

 

# ./configure  –prefix=/usr/local/mysql –with-charset=utf8  –with-collation=utf8_general_ci  –with-extra-charsets=gbk,gb2312

# make && make install

编译错误信息:

../depcomp: line 571: exec: g++: not found

make[1]: *** [my_new.o] Error 127

make[1]: Leaving directory `/root/Desktop/mysql-5.1.62/mysys’

make: *** [all-recursive] Error 1

 

# yum -y install gcc gcc-c++  // 需要安装软件

再重新配置编译安装

 

更多详情见请继续阅读下一页的精彩内容 :http://www.linuxidc.com/Linux/2014-05/101171p2.htm

3. 初始化设置

# cd MySQL-5.1.62/support-files/

# cp my-medium.cnf /etc/my.cnf // 复制样本配置文件

 

# cd /usr/local/mysql/bin/

# ./mysql_install_db –user=mysql // 初始化库表

 

4. 权限调整及执行优化

# chown -R root:mysql /usr/local/mysql/

# chown -R mysql /usr/local/mysql/var/ // 使用户 mysql 有权写库

 

# ln -s /usr/local/mysql/bin/* /usr/local/bin/ // 建程序快捷方式

# ln -s /usr/local/mysql/lib/mysql/* /usr/lib64/ // 链接库文件

# ln -s /usr/local/mysql/include/mysql/* /usr/include/ // 链接头文件

 

5. 添加为系统服务, 并启动服务

# cd mysql-5.1.62/support-files/

# cp mysql.server /etc/init.d/mysqld // 复 *** 务脚本

 

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

# chkconfig –add mysqld

 

# service mysqld start

// 如果启动失败,先 killall -9 mysqld,再 service mysqld restart

 

三. 编译安装 php

1. 安装软件包

# yum -y install libxml2-devel // 配置需要这个库文件

# tar zxf php-5.4.19.tar.gz

# cd /usr/src/php-5.4.19/

# ./configure \

–prefix=/usr/local/php –enable-mbstring –enable-sockets \

–with-apxs2=/usr/local/httpd/bin/apxs \

–with-mysql=/usr/local/mysql \

–with-config-file-path=/usr/local/php

 

关键配置参数

–prefix=:指定安装目录

–enable-mbstring:支持多字节字符

–with-apxs2:指定 httpd 的模块工具位置

–with-mysql:指定 mysql 的安装位置

–enable-sockets:启用套接字支持

–with-config-file-path=:指定配置路径

 

# make

# make install

 

2)调整配置文件(可选)

# cp php.ini-development /usr/local/php/php.ini

# vim /usr/local/php/php.ini

.. ..

default_charset = “UTF-8” // 默认字符集

file_uploads = On // 允许上传

upload_max_filesize = 4M // 可上传的最大文件

post_max_size = 8M // 最大 POST 提交的容量

 

3.LAMP 协作配置

# vim /usr/local/httpd/conf/httpd.conf

.. ..

LoadModule php5_module modules/libphp5.so

DirectoryIndex index.html index.php // 添加 PHP 首页

AddType application/x-httpd-php .php // 识别 PHP 网页类型

.. ..

# service httpd restart

# service mysqld restart

4. 制作测试网页,测试 LAMP 协作

测试 PHP 解析(访问 http://IP 地址 /test1.php)

# vim /usr/local/httpd/htdocs/test1.php //

<?php

phpinfo();

?>

 

测试数据库连接(访问 http://IP 地址 /test2.php)

# vim /usr/local/httpd/htdocs/test2.php

<?php

$link=mysql_connect(‘localhost’,’test’,”); // 连数据库

if($link) echo “ 恭喜你,数据库连接成功啦 !!”; // 成功时的提示

mysql_close(); // 关数据库

?>

更多 RedHat 相关信息见 RedHat 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=10

一,编译安装 httpd

1. 安装软件包

# tar zxf httpd-2.2.25.tar.gz

# cd httpd-2.2.25

# ./configure  –prefix=/usr/local/httpd  –enable-so  –enable-rewrite  –enable-cgi  –enable-ssl  –enable-charset-lite

————————————– 分割线 ————————————–

Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及设置 http://www.linuxidc.com/Linux/2013-06/86250.htm

CentOS 5.9 下编译安装 LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12) http://www.linuxidc.com/Linux/2013-03/80333p3.htm

RedHat 5.4 下 Web 服务器架构之源码构建 LAMP 环境及应用 PHPWind http://www.linuxidc.com/Linux/2012-10/72484p2.htm

LAMP 源码环境搭建 WEB 服务器 Linux+Apache+MySQL+PHP http://www.linuxidc.com/Linux/2013-05/84882.htm

LAMP+Xcache 环境搭建 http://www.linuxidc.com/Linux/2014-05/101087.htm

————————————– 分割线 ————————————–

配置参数用途:

–prefix=:指定安装目录

–enable-so:支持动态加载模块

–enable-rewrite:支持网站地址重写

–enable-cgi:支持 CGI 程序脚本

–enable-ssl:支持 SSL 加密

–enable-charset-lite:支持多语言编码

 

配置错误提示:

no SSL-C headers found

configure: error: …No recognized SSL/TLS toolkit detected

安装相应库文件

# yum -y install openssl-devel

# ./configure  –prefix=/usr/local/httpd  –enable-so  –enable-rewrite  –enable-cgi  –enable-ssl  –enable-charset-lite

# make && make install

 

2. 建立服务脚本

# cd /usr/local/httpd/bin/

# cp apachectl /etc/init.d/httpd

# vim /etc/init.d/httpd

#!/bin/sh

# chkconfig: 2345 85 35

# description:Apache is a world wide web server

……

# chkconfig –add httpd

# chkconfig –list httpd

httpd        0:off1:off2:on3:on4:on5:on6:off

 

3. 修改主配置文件及启动服务

# vim /usr/local/httpd/conf/httpd.conf

ServerName www.linuxidc.com:80

# service httpd start

[root@client bin]# netstat -ln | grep :80

tcp        0      0 :::80                      :::*                        LISTEN     

 

 

 

二. 编译安装 mysql

1. 添加运行用户

# useradd -M -u 49 -s /sbin/nologin mysql

 

2. 安装软件包

# tar zxf mysql-5.1.62.tar.gz

# cd mysql-5.1.62

# ./configure  –prefix=/usr/local/mysql –with-charset=utf8  –with-collation=utf8_general_ci  –with-extra-charsets=gbk,gb2312

 

配置参数用途:

–prefix=:指定安装目录

–with-charset=utf8:指定默认字符集

–with-collation=utf8_general_ci:指定默认的校对规则集

–with-extra-charsets=gbk,gb2312:设置支持的其他字符集

 

配置错误信息:

checking for termcap functions library… configure: error: No curses/termcap library found

安装库文件

# yum -y install ncurses-devel libtermcap-devel

 

# ./configure  –prefix=/usr/local/mysql –with-charset=utf8  –with-collation=utf8_general_ci  –with-extra-charsets=gbk,gb2312

# make && make install

编译错误信息:

../depcomp: line 571: exec: g++: not found

make[1]: *** [my_new.o] Error 127

make[1]: Leaving directory `/root/Desktop/mysql-5.1.62/mysys’

make: *** [all-recursive] Error 1

 

# yum -y install gcc gcc-c++  // 需要安装软件

再重新配置编译安装

 

更多详情见请继续阅读下一页的精彩内容 :http://www.linuxidc.com/Linux/2014-05/101171p2.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计6797字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中