转自http://www.zjmainstay.cn/lamp-config

本文记录了我自己配置LAMP的全过程,借此记录一下,同时希望能够帮助一下需要帮助的LINUX新人,跟我一起学习,一起进步。

MySQL安装全过程

  • 源码包来自:http://distfiles.macports.org/mysql5/
  • $cd ~/Download
  • $wget http://distfiles.macports.org/mysql5/mysql-5.1.60.tar.gz
  • $chmod +x mysql-5.1.60.tar.gz
  • $tar zxvf mysql-5.1.60.tar.gz
  • $cd mysql-5.1.60
  • $su
  • 输入密码:
  • #./configure --prefix=/usr/local/mysql --with-extra-charsets=all --with-unix-socket-path=/usr/local/mysql/var/mysql.sock --with-named-curses-libs=/usr/lib/libncursesw.so
  • #make
  • 提示错误:exec: g++: not found
  • 原因:缺少gcc-c++
  • 解决:yum install gcc-c++
  • #yum install gcc-c++
  • #./configure --prefix=/usr/local/mysql --with-extra-charsets=all --with-unix-socket-path=/usr/local/mysql/var/mysql.sock --with-named-curses-libs=/usr/lib/libncursesw.so
  • #make
  • 提示错误:configure: error: No curses/termcap library found
  • 原因:缺少ncurses-devel
  • 解决:yum install ncurses-devel
  • #yum install ncurses-devel
  • #./configure --prefix=/usr/local/mysql --with-extra-charsets=all --with-unix-socket-path=/usr/local/mysql/var/mysql.sock --with-named-curses-libs=/usr/lib/libncursesw.so
  • #make
  • #make install
  • `make install 假错`
  • make[4]: Entering directory /mysql-test 运行到这句会有不动几分钟,等待就好。
  • 安装成功结束
  • 复制my.cnf
  • #cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
  • 初始化数据库
  • #cd /usr/local/mysql/
  • #./bin/mysql_install_db
  • 添加mysql用户组
  • #groupadd mysql
  • 添加mysql用户,位于mysql用户组
  • #useradd -g mysql mysql
  • 给mysql用户一个密码
  • #passwd mysql
  • 把mysql目录的拥有者设置成mysql
  • #chown -R mysql:mysql *
  • 把mysql启动拷贝到系统默认的目录下
  • #cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
  • 启动mysql服务
  • #/etc/init.d/mysql start
  • 创建root用户
  • #/usr/local/mysql/bin/mysqladmin -u root password 123456
  • 登陆mysql管理
  • #./bin/mysql -uroot -p123456

Apache安装全过程

  1. CentOS会自带apache服务,自带apache可以使用service httpd start启动,
  2. 程序目录位于/var/www/html/下面,这里移除系统自带Apache
  3. #rpm -e httpd
  4. 提示gnome-user-share依赖
  5. 下面忽略依赖删除Apache
  6. #rpm -e --nodeps httpd
  7. 源码包来自:
  8. http://www.apache.org/底部
  9. HTTP Server (http://httpd.apache.org/)
  10. #exit
  11. $cd ~/Download
  12. $wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.2.25.tar.gz
  13. $tar zxvf httpd-2.2.25.tar.gz
  14. $cd httpd-2.2.25
  15. $su
  16. 输入密码:
  17. #./configure --prefix=/usr/local/apache --enable-track-vars --enable-cgi --with-config-file-path=/usr/local/apache/conf --enable-so --enable-rewrite --enable-proxy --enable-ssl
  18. 提示错误:configure: error: ...No recognized SSL/TLS toolkit detected
  19. 原因:确实SSL
  20. 解决:yum -y install openssl openssl-devel
  21. #yum -y install openssl openssl-devel
  22. #./configure --prefix=/usr/local/apache --enable-track-vars --enable-cgi --with-config-file-path=/usr/local/apache/conf --enable-so --enable-rewrite --enable-proxy --enable-ssl
  23. #make
  24. #make install
  25. 安装完成
  26. 启动Apache服务器
  27. #/usr/local/apache/bin/apachectl start
  28. 浏览器访问http://localhost可以看到“It Works!”
  29. 程序目录为:/usr/local/apache/htdocs/
  30. 创建service httpd start启动
  31. #cp /usr/local/apache/bin/apachectl /etc/init.d/httpd

PHP安装全过程

  • 源码包来自http://php.net/downloads.php
  • $cd ~/Download
  • $wget http://us1.php.net/get/php-5.3.27.tar.gz/from/cn2.php.net/mirror
  • $tar zxvf php-5.3.27.tar.gz
  • $cd php-5.3.27
  • $su
  • 输入密码:
  • #./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-apxs2=/usr/local/apache/bin/apxs --enable-track-vars --enable-force-cgi-redirect --with-config-file-path=/usr/local/php/etc --with-curl --with-mcrypt=/usr/local/libmcrypt/ --with-mbstring --with-incov --with-gd --with-jpeg-dir=/usr/local/lib --enable-pdo --enable-ssl
  • 提示错误:configure: error: xml2-config not found. Please check your libxml2 installation.
  • 原因:缺少libxml2-devel
  • 解决:yum install libxml2-devel
  • #yum install libxml2-devel
  • #./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-apxs2=/usr/local/apache/bin/apxs --enable-track-vars --enable-force-cgi-redirect --with-config-file-path=/usr/local/php/etc --with-curl --with-mcrypt=/usr/local/libmcrypt/ --with-mbstring --with-incov --with-gd --with-jpeg-dir=/usr/local/lib --enable-pdo --enable-ssl
  • 提示错误:configure: error: Please reinstall the libcurl distribution -
  • easy.h should be in /include/curl/
  • 原因:curl-devel没安装
  • 解决:yum install curl-devel
  • #yum install curl-devel
  • #./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-apxs2=/usr/local/apache/bin/apxs --enable-track-vars --enable-force-cgi-redirect --with-config-file-path=/usr/local/php/etc --with-curl --with-mcrypt=/usr/local/libmcrypt/ --with-mbstring --with-incov --with-gd --with-jpeg-dir=/usr/local/lib --enable-pdo --enable-ssl
  • 错误:configure: error: jpeglib.h not found.
  • 解决:yum install libjpeg-devel libpng-devel
  • #yum install libjpeg-devel libpng-devel
  • #./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-apxs2=/usr/local/apache/bin/apxs --enable-track-vars --enable-force-cgi-redirect --with-config-file-path=/usr/local/php/etc --with-curl --with-mcrypt=/usr/local/libmcrypt/ --with-mbstring --with-incov --with-gd --with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/local/lib --enable-pdo --enable-ssl
  • 错误:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
  • 解决:CentOS使用yun install libmcrypt安装提示没包,因此需要下载libmcrypt源码包,手动安装
  • 项目地址:http://sourceforge.net/projects/mcrypt/files/Libmcrypt/
  • 回到Download目录
  • #cd ..
  • #wget http://jaist.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
  • #tar zxvf libmcrypt-2.5.8.tar.gz
  • #cd libmcrypt-2.5.8
  • #./configure --prefix=/usr/local/libmcrypt
  • #make
  • #make install
  • 重新进入php目录
  • #cd ../php-5.3.27
  • #./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-apxs2=/usr/local/apache/bin/apxs --enable-track-vars --enable-force-cgi-redirect --with-config-file-path=/usr/local/php/etc --with-curl --with-mcrypt=/usr/local/libmcrypt/ --with-mbstring --with-incov --with-gd --with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/local/lib --enable-pdo --enable-ssl
  • #make
  • #make install
  • #cp php.ini-development /usr/local/php/lib/php.ini
  • #vi /usr/local/apache/conf/httpd.conf
  • 1、在最后加入(:$(冒号$)可以跳到文件最后一行):
  • AddType application/x-httpd-php .php
  • 2、修改文件访问顺序(Line 168):
  • DirectoryIndex index.php index.html
  • 提示:vi +168 /usr/local/apache/conf/httpd.conf 可以打开文件,并且指针停留在168行,:set nu(冒号set nu)可以显示行号。
  • 安装成功Apache已经启动了服务器,现在关闭,然后重新启动,使用restart我遇见了php依然没识别的问题,所以最好用stop停止再启动
  • #/usr/local/apache/bin/apachectl stop
  • #/usr/local/apache/bin/apachectl start
  • 创建第一PHP文件
  • #vi /usr/local/apache/htdocs/index.php
  • <?php
  • phpinfo();
  • ?>
  • 在浏览器访问http://localhost 会看到phpinfo输出的信息,证明php成功解析。
  • PHP解析成功后还需要测试PHP和MySQL数据库连通情况
  • 前面没有启动mysql则使用 /etc/init.d/mysql start启动服务器
  • #/etc/init.d/mysql start
  • #/usr/local/mysql/bin/mysql -uroot -p123456
  • mysql>show databases;
  • mysql>use test;
  • mysql>CREATE TABLE tb_test(
  • >id int(11) auto_increment not null,
  • >name varchar(255) not null,
  • >PRIMARY KEY(id)
  • >);
  • mysql>INSERT INTO tb_test(name) VALUES('hzg'),('Zjmainstay');
  • mysql>SELECT * FROM tb_test;
  • 确认数据库表tb_test有两行数据即可。
  • 创建PHP测试程序db_test.php
  • #vi /usr/local/apache/htdocs/db_test.php
  • <?php
  • $db = mysql_connect("localhost","root","123456") or die("Can not connect database!");
  • mysql_select_db("test", $db) or die("Can not select database!");
  • mysql_query("set names utf8", $db) or die("Can not set names!");
  • $sql = "SELECT * FROM tb_test";
  • $res = mysql_query($sql, $db);
  • if(!$res){
  • die("Query error" . mysql_error($db));
  • }else {
  • $format = 'Id=%s, Name=%s<br />';
  • while($row = mysql_fetch_assoc($res)){
  • echo sprintf($format, $row['id'], $row['name']);
  • }
  • }
  • ?>
  • 保存,并在浏览器端执行http://localhost/db_test.php
  • 提示错误:Can not connect to local MySQL server through socket '/usr/local/mysql/var/mysql.sock'
  • 将localhost改成127.0.0.1后运行正常
  • 原因:var目录没权限,无法写入mysql.sock
  • 解决:chmod 0755 /usr/local/mysql/var/
  • #ls /usr/local/mysql/var/
  • 打印结果为空
  • 授权0755
  • #chmod 0755 /usr/local/mysql/var/
  • 授权成功重启服务
  • #/etc/init.d/mysql restart
  • 再次查看var目录
  • #ls /usr/local/mysql/var/
  • 可以看到此时有数据了,而且有mysql.sock
  • 再次运行localhost为服务器的db_test.php程序,执行成功。
												

Linux下MySQL、Apache、PHP源码安装全程实录(CentOS 6.4)的更多相关文章

  1. linux下MySQL 5.6源码安装

    linux下MySQL 5.6源码安装 1.下载:当前mysql版本到了5.6.20 http://dev.mysql.com/downloads/mysql 选择Source Code 2.必要软件 ...

  2. linux应用之apache的源码安装(centos)

    第一部分:前期准备 需要下载的东西 下载 Apache 源码包  下载地址: http://httpd.apache.org/download.cgi                          ...

  3. linux下PostgreSQL数据库的源码安装

    实验环境>>>>>>>>>>>>>>>>>>操作系统:CentOS release 6.3 ...

  4. CentOS 6.3下MySQL 5.6源码安装

    Linux操作系统:CentOS 6.3 1:下载:当前mysql版本到了5.6.10 下载地址:http://dev.mysql.com/downloads/mysql/5.6.html#downl ...

  5. linux下hadoop2.6.1源码64位的编译

    linux下hadoop2.6.1源码64位的编译 一. 前言 Apache官网上提供的hadoop本地库是32位的,如果我们的Linux服务器是64位的话,就会现问题.我们在64位服务器执行Hado ...

  6. Linux下USB suspend/resume源码分析【转】

    转自:http://blog.csdn.net/aaronychen/article/details/3928479 Linux下USB suspend/resume源码分析 Author:aaron ...

  7. Linux 系统安装配置PHP服务(源码安装)

    简介: PHP(外文名:PHP: Hypertext Preprocessor,中文名:“超文本预处理器”)是一种通用开源脚本语言.语法吸收了C语言.Java和Perl的特点,利于学习,使用广泛,主要 ...

  8. linux下Mysql 8.0.19 编译安装

    1 前言 linux下安装MySQL的方式有很多种,包括以仓库的方式安装(yum,apt,zypper),以包的方式安装(rpm,deb),以docker方式安装,从压缩包解压安装,从源码编译安装,这 ...

  9. RHEL Server 6.3下MySQL5.5.25a源码安装

    OS:RHEL Server 6.3 MySQL:mysql-5.5.25a.tar.gz 相关依赖包: ncurses-5.9.tar.gz bison-2.5.tar.gz 安装MySQL 一.安 ...

随机推荐

  1. 小程序 之登录 wx.login()

    小程序的登录关键在于使用wx.login()方法后,要到取到code值传到后台, 再用小程序平台本帐号生成的appid+addsecret+code去微信接口服务取得用户唯一标识后即可登录[注意:此步 ...

  2. 两种const函数

    有两种const函数,声明如下:1.const T func();2.T func() const;第一种表示返回的是const的类型,也即返回的值不能作为左值,楼主懂的.第二种表示该成员函数不能修改 ...

  3. 常见编码bug

    1.result.replace("abc","bcd");错误 改成result= result.relace("abc","b ...

  4. OAuth相关备注

    引用大神的资料,备注一下 http://www.cnblogs.com/dudu/tag/OAuth/

  5. Engine中如何实现鼠标滚轮缩放反置?

    来自:http://zhihu.esrichina.com.cn/?/question/6666 [解决办法]:1,禁用IMapControl的默认鼠标滚轮事件.即设置IMapControl4.Aut ...

  6. android ListView详解(转)

    在android开发中ListView是比较常用的组件,它以列表的形式展示具体内容,并且能够根据数据的长度自适应显示.抽空把对ListView的使用做了整理,并写了个小例子,如下图. 列表的显示需要三 ...

  7. Attempt to invoke virtual method 'void android.app.ActionBar.setTitle的解决方法

    在安卓4.4.2的关于蓝牙开发的一个sample BluetoothChat中,调试时,老是出错:Attempt to invoke virtual method 'void android.app. ...

  8. scrapy 启动失败,scrapy startproject test 出错 'module' object has no attribute 'OP_NO_TLSv1_1

    你先看看 pip install scrapy需要的 pyopenssl  twisted  等和你安装的版本一样么  我的就是因为TWist 版本高于  需要的 用pip install twist ...

  9. 【Todo】Java学习路线(方向指导)

    在网上搜了下Java学习路线(关键词:学习,因为众所周知,实践出牛人,在平时工作不怎么深入的情况下,才强调学习的方向的重要性 ^_^) 发现下面知乎这个回答写的真好.mark如下: https://w ...

  10. Git学习0基础篇(下)

    server上的 Git - 协议 Git能够使用四种基本的协议传输资料:本地协议(Local).HTTP 协议.SSH(Secure Shell) 协议以及 Git 协议.眼下使用最普及的是 SSH ...