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

Linux Redhat 6.4 LAMP 平台搭建

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-7-23 08:50:56 | 显示全部楼层 |阅读模式
一. 搭建安装LAMP

[iyunv@localhost root]# rpm -qa|grep -i  httpd     
//查询系统中已安装的Apache相关软件包  
httpd-manual-2.0.40-21  
httpd-2.0.40-21  
redhat-config-httpd-1.0.1-18  
[iyunv@localhost root]# service httpd stop              
//如果Apache已开启,停止运行Apache服务器  
[iyunv@localhost root]# rpm -e httpd-manual-2.0.40-21
--nodeps       //卸载Apaceh服务器  
[iyunv@localhost root]# rpm -e httpd-2.0.40-21 --nodeps     
//卸载Apache服务器  
[iyunv@localhost root]# rpm -e redhat-config-httpd
-1.0.1-18 --nodeps     //卸载Apache服务器



[iyunv@localhost root]# rpm -qa|grep -i  mysql         
//查询系统中已安装的MySQL相关软件包  
mysql-devel-3.23.54a-11  
mysql-3.23.54a-11  
mysql-server-3.23.54a-11  
[iyunv@localhost root]#service mysqld stop            
//如果MySQL已开启,停止运行MySQL服务器  
[iyunv@localhost root]# rpm -e mysql-devel-3.
23.54a-11 --nodeps      //卸载MySQL服务器  
[iyunv@localhost root]# rpm -e mysql-3.23.54a-11 -nodeps
//卸载MySQL服务器  
[iyunv@localhost root]# rpm -e mysql-server-
3.23.54a-11 --nodeps         //卸载MySQL服务器
[iyunv@localhost root]# rpm -qa|grep -i php      
//查询系统中已安装的PHP相关软件包  
php-ldap-4.2.2-17  
php-imap-4.2.2-17  
php-4.2.2-17  
[iyunv@localhost root]# rpm -e php-ldap-4.2.2-17 --nodeps  
//卸载PHP应用服务器  
[iyunv@localhost root]# rpm -e php-imap-4.2.2-17 --nodeps
//卸载PHP应用服务器  
[iyunv@localhost root]# rpm -e php-4.2.2-17 --nodeps  
//卸载PHP应用服务器

---------------------------------------------


-------------------------------------------------------------------------
【编译安装httpd】
1)安装依赖包
[iyunv@svr5 ~]# yum -y install openssl-devel

2)解包、配置、编译、安装
[iyunv@svr5 ~]# cd /var/ftp/pub/
[iyunv@svr5 pub]# tar zxf httpd-2.2.25.tar.gz
[iyunv@svr5 pub]# cd httpd-2.2.25

[iyunv@svr5 httpd-2.2.25]# ./configure  --prefix=/usr/local/httpd  --enable-so  --enable-rewrite  --enable-cgi  --enable-ssl   --enable-charset-lite --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

常用配置参数用途:
--prefix=:指定安装目录
--enable-so:支持动态加载模块
--enable-rewrite :支持网站地址重写
--enable-cgi:支持CGI程序脚本
--enable-ssl:支持SSL加密
--enable-charset-lite:支持多语言编码

[iyunv@svr5 httpd-2.2.25]# make
[iyunv@svr5 httpd-2.2.25]# make install

出现问题和解决办法

1.解决apr not found问题
[iyunv@yahoo test]# tar -zxf apr-1.4.5.tar.gz
[iyunv@yahoo apr-1.4.5]# ./configure --prefix=/usr/local/apr
[iyunv@yahoo apr-1.4.5]# make
[iyunv@yahoo apr-1.4.5]# make install


2.解决APR-util not found问题
[iyunv@yahoo test]# tar -zxf apr-util-1.3.12.tar.gz
[iyunv@yahoo apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
[iyunv@yahoo apr-util-1.3.12]# make
[iyunv@yahoo apr-util-1.3.12]# make install

或 yum -y install apr-util-devel
3  ../configure仍提示APR-util not found,增加--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util后出现

4.configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
#./configure –help | grep pcre
--with-pcre=PATH        Use external PCRE library
或yum -y install pcre-devel





3)建立服务脚本
[iyunv@svr5 ~]# cp /usr/local/httpd/bin/apachectl  /etc/init.d/httpd
[iyunv@svr5 ~]# vim /etc/init.d/httpd
#!/bin/sh
# chkconfig: 35 85 15      35是在3 5 运行级别自动启动  启动优先级别85
# description: Apache is a World Wide Web Server       关闭优先级别 15
.. ..
[iyunv@svr5 ~]# chkconfig --add httpd
[iyunv@svr5 ~]# chkconfig --list httpd
myhttpd         0:关闭  1:关闭  2:关闭  3:启用  4: 关闭  5:启用  6:关闭

4)调整及启动服务
[iyunv@svr5 ~]# vim /usr/local/httpd/conf/httpd.conf
ServerName svr5.tarena.com
.. ..
[iyunv@svr5 ~]# service httpd start


【编译安装mysql】
1) 添加运行用户
[iyunv@svr5 ~]#groupadd mysql
[iyunv@svr5 ~]# useradd -M -u 49 -s /sbin/nologin -g mysql mysql

2) 解包、配置、编译、安装
[iyunv@svr5 ~]# yum -y install  gcc gcc-c++ gcc-g77 autoconf automake  fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake

[iyunv@svr5 ~]# cd /var/ftp/pub/
[iyunv@svr5 pub]# tar zxf mysql-5.6.23.tar.gz
[iyunv@svr5 pub]# cd mysql-5.6.23
[iyunv@svr5 mysql-5.1.62]# cmake  . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1


参数说明:
CMAKE_INSTALL_PREFIX : MySQL安装目录
SYSCONFDIR : 配置文件目录
MYSQL_DATADIR :数据库目录
MYSQL_TCP_PORT :数据库端口
MYSQL_UNIX_ADDR :安排个目录放mysql.sock文件把,可以设置为日志存放,data存放目录等位置
WITH_EXTRA_CHARSETS : 字符
WITH_SSL       :the type of SSL
WITH_EMBEDDED_SERVER :Whether to build embedded server (默认:OFF)
ENABLED_LOCAL_INFILE :Whether to enable LOCAL for LOAD DATA INFILE(默认:OFF)  允许从本地导入数据
WITH_INNOBASE_STORAGE_ENGINE:  1

[iyunv@svr5 mysql-5.1.62]# make
[iyunv@svr5 mysql-5.1.62]# make install

3) 初始化设置
[iyunv@svr5 ~]# cd  /var/ftp/pub/mysql- 5.1.62/support-files/
[iyunv@svr5 support-files]# cp  my-default.cnf   /etc/my.cnf        //复制样本配置文件

[iyunv@svr5 support-files]# cd /usr/local/mysql/scripts/
# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/                 //初始化库表

4) 权限调整及执行优化
#mkdir etc log
[iyunv@svr5 bin]# chown -R mysql:mysql  /usr/local/mysql/
[iyunv@svr5 bin]# chown -R mysql  /usr/local/mysql/var/        //使用户mysql有权写库

[iyunv@svr5 bin]# ln -s /usr/local/mysql/bin/*   /usr/local/bin/                  //建程序快捷方式
[iyunv@svr5 bin]# ln -s /usr/local/mysql/lib/mysql/*   /usr/lib64/          //链接库文件
[iyunv@svr5 bin]# ln -s  /usr/local/mysql/include/mysql/*  /usr/include/           //链接头文件

5) 添加为系统服务
[iyunv@svr5 bin]# cd  /var/ftp/pub/mysql- 5.1.62/support-files/
[iyunv@svr5 support-files]# cp  mysql.server   /etc/init.d/mysqld          //复制服务脚本

[iyunv@svr5 support-files]# chmod  +x   /etc/rc.d/init.d/mysqld
[iyunv@svr5 support-files]# chkconfig  --add  mysqld

[iyunv@svr5 support-files]# service mysqld restart
                //如果启动失败,先killall -9 mysqld ,再service mysqld restart
6)修改密码
/usr/local/mysql//bin/mysqladmin -u root password '123456'               


【编译安装php】

1)解包、配置、编译、安装
yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y


[iyunv@svr5 ~]# cd /var/ftp/pub
[iyunv@svr5 pub]# tar zxf php-5.4.19.tar.gz
[iyunv@svr5 pub]# cd /usr/src/php-5.4.19/
[iyunv@svr5 php-5.4.19]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/httpd/bin/apxs --with-config-file-path=/usr/local/php/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local/freetype --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib  --with-mysqli=mysqlnd --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath

关键配置参数
--prefix=:指定安装目录
--enable-mbstring:支持多字节字符
--with-apxs2:指定httpd的模块工具位置
--with-mysql:指定mysql的安装位置
--enable-sockets:启用套接字支持
--with-config-file-path=:指定配置路径

[iyunv@svr5 php-5.4.19]# make
[iyunv@svr5 php-5.4.19]# make install

[iyunv@svr5 php-5.4.19]# cp php.ini-development  /usr/local/php/etc/php.ini


2)调整配置文件(可选)
[iyunv@svr5 ~]# vim  /usr/local/php/etc/php.ini
.. ..
= "UTF-8"                  //默认字符 集
file_uploads = On                                  // 允许上传
upload_max_filesize = 4M                  //可上传的 最大文件
post_max_size = 8M                          //最大POST 提交的容量

3)LAMP协作配置
[iyunv@svr5 ~]# 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网页类型
.. ..
[iyunv@svr5 ~]# service  myhttpd  restart


4)LAMP协作测试

测试PHP解析(访问http://your_server/test1.php)
[iyunv@svr5 ~]# cat/usr/local/httpd/htdocs/test2.php
<?php
phpinfo();          //输出PHP环境相关信息
?>

测试数据库连接(访问http://your_server/test2.php)
[iyunv@svr5 ~]# cat/usr/local/httpd/htdocs/test2.php
<?php
$link=mysql_connect('localhost','test','');     // 连数据库
if($link) echo "恭喜你,数据库连接成功啦 !!";   //成 功时的提示
mysql_close();      //关数据库
?>


运维网声明 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-89671-1-1.html 上篇帖子: LAMP环境搭建 下篇帖子: 一键安装lamp脚本--初级版 Linux
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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