1.5编译方式搭建LAMP环境httpd-2.2.31+mysql-5.6.27+php-5.6.14

一、安装编译工具和依赖包

[[email protected] src]# yum -y install gc gcc-c++ pcre-devel ncurses-devel openssl-devel libpng-devel libtool libxslt-devel libxml2-devel libXpm-devel curl-devel

二、安装PHP和MySQL所需要的软件

1、安装cmake

[[email protected] cmake-2.8.10.2]# ./bootstrap
[[email protected] cmake-2.8.10.2]# make && make

2、安装freetype

[[email protected] freetype-2.4.0]# ./configure --prefix=/usr/local/freetype
[[email protected] freetype-2.4.0]# make

3、安装libmcrypt

[[email protected] libmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt
[[email protected] libmcrypt-2.5.8]# make

4、安装libiconv

[[email protected] libiconv-1.14]# ./configure --prefix=/usr/local/libiconv
[[email protected] libiconv-1.14]# make install

5、安装jpeg-6b

[[email protected] src]# cd jpeg-6b/
[[email protected] jpeg-6b]# mkdir /usr/local/jpeg6
[[email protected] jpeg-6b]# mkdir /usr/local/jpeg6/bin
[[email protected] jpeg-6b]# mkdir /usr/local/jpeg6/lib
[[email protected] jpeg-6b]# mkdir /usr/local/jpeg6/include
[[email protected] jpeg-6b]# mkdir /usr/local/jpeg6/man/man1 -p

[[email protected] jpeg-6b]# cp /usr/share/libtool/config/config.sub .
cp: overwrite `./config.sub‘? y
[[email protected] jpeg-6b]# cp /usr/share/libtool/config/config.guess .
cp: overwrite `./config.guess‘? y
[[email protected] jpeg-6b]# ./configure --prefix=/usr/local/jpeg6 --enable-shared --enable-static
[[email protected] jpeg-6b]# make

6、安装gd2

[[email protected] libgd-2.1.1]# ./configure --prefix=/usr/local/libgd2 --with-zlib --with-jpeg=/usr/local/jpeg6 --with-png --with-freetype=/usr/local/freetype

三、安装mysql

1、创建mysql用户

[[email protected] mysql-5.6.27]# groupadd mysql
[[email protected] mysql-5.6.27]# useradd -r -g mysql mysql

2、编译安装mysql

[[email protected] mysql-5.6.27]# cmake . \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DMYSQL_DATADIR=/var/lib/mysql \
> -DSYSCONFDIR=/etc \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_MYISAM_STORAGE_ENGINE=1 \
> -DWITH_MEMORY_STORAGE_ENGINE=1 \
> -DWITH_READLINE=1 \
> -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
> -DMYSQL_TCP_PORT=3306 \
> -DENABLED_LOCAL_INFILE=1 \
> -DWITH_PARTITION_STORAGE_ENGINE=1 \
> -DEXTRA_CHARSETS=all \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci

-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

WITH_MEMORY_STORAGE_ENGINE
    WITH_READLINE

-- Build files have been written to: /usr/local/src/mysql-5.6.27

[[email protected] mysql-5.6.27]# gmake
[[email protected] mysql-5.6.27]# gmake install

3、修改/usr/local/mysql文件权限

[[email protected] mysql-5.6.27]# chown -R mysql:mysql /usr/local/mysql
[[email protected] mysql-5.6.27]# ll -d /usr/local/mysql
drwxr-xr-x 13 mysql mysql 4096 Dec 14 12:08 /usr/local/mysql

4、创建数据库存储目录

[[email protected] mysql-5.6.27]# mkdir /var/lib/mysql
[[email protected] mysql-5.6.27]# chown mysql. /var/lib/mysql

5、安装系统数据库

[[email protected] scripts]# ./mysql_install_db --basedir=/usr/local/mysql --datadir=/var/lib/mysql --no-defaults --user=mysql

[[email protected] scripts]# ls /var/lib/mysql/
ibdata1  ib_logfile0  ib_logfile1  mysql  performance_schema  test

6、复制配置文件

[[email protected] scripts]# cd /usr/local/mysql/support-files/
[[email protected] support-files]# ls
binary-configure  magic  my-default.cnf  mysqld_multi.server  mysql-log-rotate  mysql.server

[[email protected] support-files]# cp my-default.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf‘? y

[[email protected] support-files]# vim /etc/my.cnf    //修改配置
basedir = /usr/local/mysql
datadir = /var/lib/mysql
port = 3306
# server_id = .....
socket = /var/lib/mysql/mysql.sock

7、添加启动脚本并设置开机启动

[[email protected] support-files]# cp mysql.server /etc/rc.d/init.d/mysqld
[[email protected] support-files]# chmod +x /etc/rc.d/init.d/mysqld

[[email protected] support-files]# service mysqld start
Starting MySQL.. SUCCESS!
[[email protected] support-files]# chkconfig --add mysqld
[[email protected] support-files]# chkconfig mysqld on

8、登录mysql

[[email protected] support-files]# /usr/local/mysql/bin/mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.27 Source distribution

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql>

四、安装apache2

1、安装apr和apr-util

[[email protected] apr-1.5.2]# ./configure --prefix=/usr/local/apr
[[email protected] apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

2、编译安装apache2

[[email protected] httpd-2.2.31]# ./configure \

--prefix=/usr/local/apache2 \
--sysconfdir=/etc/httpd \
--with-included-apr \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--enable-so \
--enable-deflate=shared \
--enable-expires=shared \
--enable-rewrite=shared \
--with-pcre \
--enable-mem-cache \
--enable-cache \
--enable-static-support \
--with-z

[[email protected] httpd-2.2.31]# make

[[email protected] httpd-2.2.31]# make install
make[1]: Leaving directory `/usr/local/src/httpd-2.2.31‘
[[email protected] httpd-2.2.31]# echo $?
0

[[email protected] ~]# ls /usr/local/apache2/
bin  build  cgi-bin  error  htdocs  icons  include  lib  logs  man  manual  modules

[[email protected] httpd-2.2.31]# /usr/local/apache2/bin/apachectl start
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

[[email protected] httpd-2.2.31]# netstat -tnlp | grep 80
tcp        0      0 :::80                       :::*                        LISTEN      2112/httpd

[[email protected] ~]# rm -rf /usr/local/apache2
[[email protected] src]# rm -rf httpd-2.2.31

[[email protected] src]# rm -rf /etc/httpd

reboot

[[email protected] ~]# netstat -tnlp | grep 80

[[email protected] httpd-2.2.31]# ./configure --prefix=/usr/local/apache2 --sysconfdir=/etc/httpd --with-included-apr --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre --enable-mem-cache --enable-cache --enable-static-support --with-z

[[email protected] httpd-2.2.31]# /usr/local/apache2/bin/apachectl start
[[email protected] httpd-2.2.31]# netstat -tnlp | grep 80
tcp        0      0 :::80                       :::*                        LISTEN      50223/httpd

[[email protected] httpd-2.2.31]# /usr/local/apache2/bin/apachectl -t
Syntax OK

3、创建启动脚本

[[email protected] src]# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd

五、安装PHP

1、编译安装php

[[email protected] php-5.6.14]# ./configure \
> --prefix=/usr/local/php \
> --with-config-file-path=/usr/local/php/etc \
> --with-apxs2=/usr/local/apache2/bin/apxs \
> --with-mysql=/usr/local/mysql \
> --with-gd=/usr/local/libgd2 \
> --with-jpeg-dir=/usr/local/jpeg6 \
> --with-freetype-dir=/usr/local/freetype \
> --with-mcrypt=/usr/local/libmcrypt \
> --with-mysqli=/usr/local/mysql/bin/mysql_config \
> --with-libxml-dir \
> --with-zlib-dir \
> --with-png-dir \
> --with-iconv-dir=/usr/local/libiconv \
> --with-openssl \
> --with-curl \
> --enable-soap \
> --enable-gd-native-ttf \
> --enable-mbstring \
> --enable-sockets \
> --enable-exif \
> --disable-ipv6 \
> --enable-ftp \
> --with-mhash \
> --with-pcre-dir=/usr/bin/pcre-config \
> --enable-zip \
> --with-bz2

报错:

configure: error: Please reinstall the BZip2 distribution

[[email protected] php-5.6.14]# yum install -y bzip2 bzip2-devel

Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/usr/local/src/php-5.6.14/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers:          /usr/local/php/include/php/ext/pdo/

[[email protected] php-5.6.14]# echo $?
0
[[email protected] php-5.6.14]# ls /usr/local/php/
bin  etc  include  lib  php

2、测试php

[[email protected] php-5.6.14]# ls /usr/local/apache2/htdocs/index.html
/usr/local/apache2/htdocs/index.html
[[email protected] php-5.6.14]# cat !$
cat /usr/local/apache2/htdocs/index.html
<html><body><h1>It works!</h1></body></html>[[email protected] php-5.6.14]#

[[email protected] php-5.6.14]# vim /etc/httpd/httpd.conf  //修改配置

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php .phtml

创建测试页面

[[email protected] php-5.6.14]# vim /usr/local/apache2/htdocs/index.php

<?php
phpinfo();
?>

[[email protected] php-5.6.14]# cp php.ini-production /usr/local/php/etc/php.ini

重新加载php配置:
[[email protected] php-5.6.14]# /usr/local/apache2/bin/apachectl graceful

时间: 2024-11-08 23:18:57

1.5编译方式搭建LAMP环境httpd-2.2.31+mysql-5.6.27+php-5.6.14的相关文章

php以模块方式、和fpm方式 搭建LAMP环境详解

CentOS6.6上编译安装LAMP apache版本:2.4.12 php版本: mysql版本:mariadb-5.5.43-linux-x86_64.tar.gz 要求: 提供2个虚拟主机, web1:phpMyAdmin, 同时提供SSL web2:wordpress; 其中php与其它软件的结合,要求分2种情况实现(1.php模块;2.php是fpm方式) 详细配置过程如下: 1.编译安装httpd(构建 MPM 为动态模块) # httpd-2.4.9编译过程依赖于pcre-deve

CentOS 6.9编译方式搭建LTMP环境,并部署phpMyAdmin数据库管理工具

一.演示环境: IP 安装的程序包 版本 下载地址 192.168.199.7 Tengine tengine-2.2.2.tar.gz http://tengine.taobao.org/download_cn.html PHP php-7.0.29.tar.gz http://www.php.net/downloads.php phpMyAdmin phpMyAdmin-4.8.0.1-all-languages.zip https://www.phpmyadmin.net/download

CentOS6.5下搭建LAMP环境(源码编译方式)

CentOS 6.5安装配置LAMP服务器(Apache+PHP5+MySQL) 学习PHP脚本编程语言之前,必须先搭建并熟悉开发环境,开发环境有很多种,例如LAMP ,WAMP,MAMP等.这里我介绍一下LAMP环境的搭建,即Linux. Apache. MySQL .PHP环境. 一.首先安装操作系统 操作系统:centos6.5 操作系统安装步骤,此处不再详述. 备注:服务器系统采用最小化安装,安装一下GCC编译工具和一个桌面即可.如下图所示: 由于安装系统的时候我是最小化安装,只安装了一

源码编译搭建LAMP环境&#160;

源码编译搭建LAMP环境  一.将 LAMP 相关软件包上传刡 linux 上 [[email protected] ~]# ls anaconda-ks.cfg      install.log         mysql-5.5.30.tar.gz  公共的  视频  文档  音乐 httpd-2.2.25.tar.gz  install.log.syslog  php-5.4.14.tar.bz2   模板    图片  下载  桌面 1. 安装apache [[email protect

源码搭建LAMP环境

源码搭建LAMP环境 一,LAMP环境概述: LAMP指的Linux(操作系统).ApacheHTTP 服务器,MySQL(有时也指MariaDB,数据库软件)和PHP(有时也是指Perl或Python) 的第一个字母,一般用来建立web 服务器.是一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台.随着开源潮流的蓬勃发展,开放源代码的LAMP已经与J2EE和.Net商业软件形成三足鼎立之势

Linux运维 第三阶段 (六) 搭建LAMP环境

Linux运维 第三阶段(六) 搭建LAMP环境 环境:RHEL6 X386或X86_64,其中64位在此文中已用()标明注意事项. 一.准备工作 1.安装编译工具gcc.gcc-c++ 注意解决依赖关系,推荐使用yum安装,若不能联网可使用安装光盘做为yum源-- # yum -y install gcc # yum -y install gcc-c++ 2.关闭系统RPM安装包的Apache.MySQL的服务 关闭启动的服务httpd.mysqld #service httpd stop #

Centos7+Apache2.4+php5.6+mysql5.5搭建Lamp环境——为了wordPress

最近想搭建个人博客玩玩,挑来挑去发现口碑不错的博客程序是wordpress,简称wp.虽然是学java路线的程序员,但因入行时间太短,至今没有发现较为称手开源的博客程序,如果各位大神有好的推荐,也希望能在评论中告知. 先上一张效果图: WordPress WordPress是一种使用PHP语言开发的博客平台,用户可以在支持PHP和MySQL数据库的服务器上架设属于自己的网站.也可以把 WordPress当作一个内容管理系统(CMS)来使用. 它的原版是英文的,不过也支持中文版的,据用过的哥们说,

?搭建LAMP环境及快速部署双网站并实现基于域名的虚拟主机

本节所讲内容: 实战:搭建LAMP环境及快速部署双网站并实现基于域名的虚拟主机 LAMP架构:??? Linux+Apache+Mysql+PHP Linux+Apache+Mysql/MariaDB+Perl/PHP/Python一组常用来搭建动态网站或者服务器的开源软件,共同组成了一个强大的Web应用程序平台. 一.安装需要的软件包 [[email protected] ~]# yum install httpd mysql-server mysql php php-mysql  -y ht

Linux手动搭建LAMP环境

当你看到标题里的“手动搭建”,你是不是会想,难不成还有“自动搭建”?当然......不是,这里的“手动搭建”是指按部就班的搭建Apache.MySQL.PHP环境,是相对于集成软件包而言的.所以你是不是能够猜到,我后续还会整理一篇通过集成软件包搭建LAMP环境的文章呢? 其实关于LAMP环境,我到现在都没有用过,好多东西也都不懂为什么要这么做,当初只是心血来潮,想自己搭建一个wiki,所以才着手研究的.我不是搞PHP的,也不是搞后端的,额......是不是暴露的太多了,仅仅是为了搭建环境而搭建环