mysql用的二进制包安装。 Apache php 用的源码包

mysql版本5.5.46    Apache版本2.4.7  PHP版本:5.5

mysql安装部分参考了阿铭linux的内容。
这是第二次搭建lamp环境。Apache2.4的版本比2.2的关系依赖包要多几个,PHP那部分有几个包也是源包安装的。视频刚看到lamp环境搭建的前几节。写不好,请勿喷。
 

安装mysql
mysql下载地址:http://mirrors.sohu.com/mysql/MySQL-5.5/
初始化
[root@localhost lamp]# tar zxvf mysql-5.5.46-linux2.6-x86_64.tar.gz   #解压   
[root@localhost lamp]# mv mysql-5.5.46-linux2.6-x86_64  /usr/local/mysql   #移动位置,并去掉版本好
[root@localhost lamp]# useradd -s /sbin/nologin -M mysql    #增加mysql用户。 不能登录 不创建家目录
[root@localhost lamp]# mkdir -p /data/mysql    #创建datadir  数据库文件会放在这里
[root@localhost lamp]# chown -R mysql:mysql /data/mysql/    #更改属组 属主
[root@localhost lamp]# cd /usr/local/mysql/                #进入目录
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql    --user定义数据库的所属主,--datadir 定义安装目录

接下来会看到有两个OK.说明执行正确。

[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
#复制启动脚本文件
[root@localhost mysql]# chmod 755 /etc/init.d/mysqld
# 修改启动脚本权限
[root@localhost mysql]# vim /etc/init.d/mysqld
#修改启动脚本。 找到bashedir 增加下面的路径

basedir=/usr/local/mysql    # 安装位置
datadir=/data/mysql          # 数据库位置

然后把启动脚本加入系统服务项,设定开机启动
chkconfig --add mysqld

chkconfig mysqld on

service mysqld start
如果启动不了。请到/data/mysql 目录下查看错误日志。这个日志通常是主机名.err。

检查MYSQL石否启动的命令为:
ps aux |grep mysqld

netstat -an |grep 3306

安装Apache2.4.7版本。
下载地址为:http://mirrors.sohu.com/apache/
tar zxvf httpd-2.4.7.tar.gz     #解压文件

cd httpd-2.4.7               #进入目录

./configure --prefix=/usr/local/apache2/ --sysconfdir=/usr/local/apache2/etc --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared   #编译参数

错误

configure: error:Bundled APR requested but not found at./srclib/.

tar zxvf apr-1.4.6.tar.gz     #解压apr包
  tar -zxvf apr-util-1.4.1.tar.gz   #解压apr-util包
  cp -r /lamp/apr-1.4.6 /lamp/httpd-2.4.7/srclib/apr
  cp -r /lamp/apr-util-1.4.1 /lamp/httpd-2.4.7/srclib/apr-util    # 然后把两个包复制到httpd-2.4.7/srclib/ 里面并且取消版本号。

错误:
configure: error: in `/lamp/httpd-2.4.7/srclib/apr':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
configure failed for srclib/apr

yum -y install gcc-c++   #安装 gcc

错误:

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
tar zxvf pcre-8.34.tar.gz
[root@localhost lamp]# cd pcre-8.34
[root@localhost pcre-8.34]# ./configure && make && make install

错误
checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures

yum -y install openssl-devel

把上面4个错误解决后。重新 ./configure 参数编译 无问题就执行
make 
make install

/usr/local/apache2/bin/apachectl start         # 启动apache
启动完后用以下命令检查apache是否正常启动,
ps aux |grep httpd
netstat -an |grep :80

如果不能启动 请清空防火墙规格。关闭selinux
iptables -F
service iptables save

通过浏览器输入地址访问:http://192.168.137.30 (我服务器的地址)  。若能显示“It works”表明apache正常工作。
设置Apache系统开机是自动开启。
vim /etc/rc.d/rc.local
增加一行 把下面增加进去。
/usr/local/apache2/bin/apachectl start

安装php5.5版本。
tar zxvf php-5.5.9.tar.gz  #解压php安装包
cd php-5.5.9  #进入php文件

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc  --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6  --with-mcrypt=/usr/local/libmcrypt/    #编译参数

错误configure: error: xml2-config not found. Please check your libxml2 installation.yum install -y libxml2-devel错误configure: error: Please reinstall the BZip2 distribution

yum install -y bzip2 bzip2-devel错误
configure: error: jpeglib.h not found.

yum install libjpeg-devel -y

错误
configure: error: png.h not found.
yum install libpng-devel -y

错误
configure: error: freetype-config not found.
yum install -y freetype freetype-devel

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

tar zxvf mcrypt-2.6.8.tar.gz    #提示mcrypt包没有安装。安装mcrypt包 又依赖依赖 libmcrypt,  mhash 这两个包。

1.首先编译安装  libmcrypt,  mhash,  mcrypt  二进制源码包。

下载libmcrypt-2.5.8.tar.gz

tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/related/libmcrypt 
make  
make install

安装 libltdl,也在libmcrypt源码包里面
cd libmcrypt-2.5.8 /libltdl

./configure --enable-ltdl-install
make
make install

下载mhash-0.9.9.9.tar.gz
tar zxvf mhash-0.9.9.9 
cd mhash-0.9.9.9 
./configrue --prefix
make 
make install

这两个包安装完。然后在安装mcrypt包。

安装mcrypt
tar zxvf mcrypt-2.6.8.tar.gz
LD_LIBRARY_PATH=/usr/local/libmcrypt/lib:/usr/local/lib ./configure --with-libmcrypt-prefix=/usr/local/libmcrypt   #编译参数

make 
make install
#mcrypt 没有安装完成。这是php模块。需要等php安装完成之后。在继续安装。

把以上的依赖关系解决完了之后在继续安装PHP
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc  --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6  --with-mcrypt=/usr/local/libmcrypt/
make
make install

生成php.ini
cp /lamp/php-5.5.9/php.ini-production  /usr/local/php/etc/php.ini

apache结合php

Apache的主配置文件为 :/usr/local/apache2/etc/httpd.conf   #参数编译的时候指定到/usr/local/apache2/etc/ 这个目录下。

vim /usr/local/apache2/etc/httpd.conf

找到AddType application/x-gzip .gz .tgz 这一行在下面增加

AddType application/x-httpd-php .php

找到:<IfModule dir_module>

DirectoryIndex index.html

</IfModule>

将中间一样的内容改为:DirectoryIndex index.html index.htm index.php

修改完成后保存退出。

启动前检测apache的配置文件是否正常。

/usr/local/apache2/bin/apachectl -t

如果显示“Syntax OK” 表示正常。

启动apache

/usr/local/apache2/bin/apachectl start

检测是否启动成功。

netstart -lnp |grep httpd

/usr/local/apache2/bin/apachectl  graceful   加载apache配置文件   不用重启

/usr/local/apache2/bin/apachectl  -t  查看php配置文件是否正常

/usr/local/php/bin/php -i |more  能查看php安装信息。。./configure 内容 等等

cat /usr/local/apache2/build/config.nice   查看apache 安装的编译代码

cat /usr/local/mysql/bin/mysqlbug |grep -i confi     参看musql安装的编译参数

LAMP 环境搭建之源码包编译安装的更多相关文章

  1. redhat6.2 clang编译环境搭建(采用源码包编译安装)

    1. About clang++ office site:http://clang.llvm.org/ A major focus of our work on clang is to make it ...

  2. CentOS 7.2使用源码包编译安装MySQL 5.7.22及一些操作

    CentOS 7.2使用源码包编译安装MySQL 5.7.22及一些操作 2018年07月05日 00:28:38 String峰峰 阅读数:2614   使用yum安装的MySQL一般版本比较旧,但 ...

  3. MySQL源码包编译安装

    +++++++++++++++++++++++++++++++++++++++++++标题:MySQL数据库实力部署时间:2019年3月9日内容:MySQL源码包进行编译,然后部署MySQL单实例重点 ...

  4. CentOS 7.4 使用源码包编译安装MySQL 5.7.20

    使用yum安装的MySQL一般版本比较旧,但是运行稳定.如果想要尝试最新的功能或者需要指定特殊的功能的话,就需要手工进行编译安装了. 一.下载安装包 (一).先下载MySQL源码,网址为:https: ...

  5. PHP-5.6.8 源码包编译安装

    一.下载源码包后,进行解压 [root@www home]# .tar.bz2 gzip: stdin: not in gzip format tar: Error is not recoverabl ...

  6. MYSQL5.7源码包编译安装

    Centos下用cmake编译安装MySQL 5.7安装依赖包yum -y install gcc gcc-c++ ncurses ncurses-devel cmake下载相应源码包cd /usr/ ...

  7. MYSQL5.5源码包编译安装

    MYSQL5.5源码安装首先安装必要的库yum -y install gcc*###### 安装 MYSQL ######首先安装camke 一.支持YUM,则yum install -y cmake ...

  8. MYSQL5.6源码包编译安装

    linux下用cmake编译安装mysql-5.6.35cmake编译安装mysql的方法:#useradd -M mysql -s /sbin/nologin#yum install -y cmak ...

  9. tomcat7源码包编译安装

    tomcat/:作用解析jsp程序.先安装jdk容器.1.下载jdk, wget http://download.oracle.com/otn- pub/java/jdk/8u131- b11/d54 ...

随机推荐

  1. CCI_chapter 19 Moderate

    19 1  Write a function to swap a number in place without temporary variables void swap(int &a, i ...

  2. windows下使用批处理调用exe和服务

    手动调用exe或者启动服务很麻烦,可以使用.bat批处理文件,双击运行即可.步骤如下:创建一个新的txt文件但是保存成.bat结尾的文件(选择用记事本打开编写命令),输入代码内容格式如下: @echo ...

  3. Powershell 设置数值格式 1

    设置数值格式 1 6 6月, 2013  在 Powershell tagged 字符串 / 数字 / 文本 / 日期 / 格式化 by Mooser Lee 格式化操作符 -f 可以将数值插入到字符 ...

  4. 关于IoCallDriver

    通常我们所知IoCallDriver是把irp传递给下一层设备,传递到底是什么意思呢?IoCallDriver中实际调用了IopfCallDriver,其代码如下:NTSTATUSFORCEINLIN ...

  5. How to run Tomcat without root privileges? 常规用户使用tomcat的80端口

    How to run Tomcat without root privileges? 1. The best way is to use jsvc, available as part of the  ...

  6. c语言枚举型常量

    #include <stdio.h> //代表百度工程师的级别 enum level { //如果没有指定初始的值 那么c语言会自动分配一个编号 整数编号 T14=,T13=,T12=,T ...

  7. hdu 5159 Card (期望)

    Problem Description There are x cards on the desk, they are numbered from 1 to x. The score of the c ...

  8. C++ multimap 的插入,遍历,删除

    #include <iostream> #include <map> #include <string> using namespace std; int main ...

  9. Swift纯代码走进UICollectionView

    Swift对于一门新的iOS编程语言,他的崛起是必然的 我们这群老程序员们学习新的技能也是必然的 不接受新技能将被这大群体无情的淘汰 So 我欣然接受这门看似不成熟的语言 下面我们说说Swift中比较 ...

  10. Android状态栏颜色修改

    android状态栏颜色修改   状态栏颜色的修改在4.4和5.x环境下分别有不同的方式,低于4.4以下是不能修改的.   5.x环境下 方式一,状态栏将显示为纯净的颜色,没有渐变效果 /** * 状 ...