Lamp源码安装参考教程

1、确认搭建LAMP所需的环境是否已经安装:

[[email protected] ~]#rpm -q make gcc gcc-c++ zlib-devel libtool libtool-ltdl libtool-ltdl-devel bisonncurses-devel

备注:安装libpng时需要zlib-devel

          安装php时需要libtoollibtool-ltdllibtool-ltdl-devel

          安装mysql时需要bisonncurses-devel

 

 

2、如果没安装则yum安装:

[[email protected]~]#yum -y install make gcc gcc-c++ zlib-devel libtool libtool-ltdllibtool-ltdl-devel bison ncurses-devel

3、由于要使用编译安装,所以查看httpdmysqlphp是否安装:

[[email protected] ~]#rpm -q httpd mysql php

如果安装则卸载:

[[email protected] ~]#rpm -e httpd --nodeps

[[email protected] ~]#rpm -e mysql --nodeps

[[email protected] ~]#rpm -e php --nodeps

 

 

编译安装过程介绍:

       1)解压tar.gz为后缀的压缩软件包:LAMP环境搭建所需要的每个软件的软代码文件,都是以tar.gz.tgz提供给我们的打包压缩文件,所以我们必须将其解压再解包。命令如下:

       tar–zxvf *.tar.gz

       2)在linux系统中源代码包安装过程:LAMP环境搭建所需要的软件都是使用C语言开发的,所以安装源代码文件最少需要配置、编译和安装三个步骤

       配置(configure)、编译(make)、安装(makeinstall

4、编译安装libxml2

[[email protected]]# tar -zxvf libxml2-2.6.30.tar.gz 

[[email protected]]# cd libxml2-2.6.30 

[[email protected]]# ./configure --prefix=/usr/local/libxml2

[[email protected]]# make

[[email protected]]# make install

 

 

5、编译安装libmcrypt

[[email protected]]# tar -zxvf libmcrypt-2.5.8.tar.gz

[[email protected]]# cd libmcrypt-2.5.8

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

[[email protected]]# make

[[email protected]]# make install

6、编译安装zlib

[[email protected]]# tar -zxvf zlib-1.2.3.tar.gz

[[email protected]]# cd zlib-1.2.3

[[email protected]]# CFLAGS="-O3 -fPIC" ./configure --prefix=/usr/local/zlib/

(用64位元的方法进行编译)

[[email protected]]# make

[[email protected]]# make install

 

 

7、编译安装libpng

[[email protected]]# tar -zxvf libpng-1.2.31.tar.gz

[[email protected]]# cd libpng-1.2.31

[[email protected]]# ./configure --prefix=/usr/local/libpng \

>--enable-shared (建立共享库使用的GNUlibtool

[[email protected]]# make

[[email protected]]# make install

8、编译安装jpeg

[[email protected]]# tar -zxvf jpegsrc.v6b.tar.gz

[[email protected]]# cd jpeg-6b

[[email protected]]# mkdir /usr/local/jpeg                    (创建jpeg软件的安装目录)

[[email protected]]# mkdir /usr/local/jpeg/bin            (创建存放命令的目录)

[[email protected]]# mkdir /usr/local/jpeg/lib             (创建jpeg库文件所在目录)

[[email protected]]# mkdir /usr/local/jpeg/include      (创建存放头文件目录)

[[email protected]]# mkdir -p /usr/local/jpeg/man/man1  (建立存放手册的目录)

[[email protected]]# ./configure --prefix=/usr/local/jpeg \

>--enable-shared \    (建立共享库使用的GUNlibtool

>--enable-static        (建立静态库使用的GUNlibtool

[[email protected]]# make

[[email protected]]# make install

执行make时如果出现如下错误:

./libtool --mode=compile gcc-O2  -I. -c ./jcapimin.c

make: ./libtool: Command notfound

make: *** [jcapimin.lo] Error 127

解决方法:

默认已安装libtoollibtool-ltdl-devel(如需帮助请看过程2

[[email protected]]# find / -name config.sub

/usr/share/libtool/config/config.sub

[[email protected]]# find / -name config.guess

/usr/share/libtool/config/config.guess

[[email protected]]# cp -vRp /usr/share/libtool/config/config.sub .

[[email protected]]# cp -vRp /usr/share/libtool/config/config.guess .

也就是把libtool里面的两个配置文件拿来覆盖掉jpeg-6b目录下的对应文件

make clean 再重新configure

9、编译安装freetype

[[email protected]]# tar -zxvf freetype-2.3.5.tar.gz

[[email protected]]# cd freetype-2.3.5

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

>--enable-shared    (建立共享库使用的GUNlibtool

[[email protected]]# make

[[email protected]]# make install

 

 

10、编译安装autoconf

[[email protected]]# tar -zxvf autoconf-2.61.tar.gz

[[email protected]]# cd autoconf-2.61

[[email protected]]# ./configure

[[email protected]]# make

[[email protected]]# make install

11、编译安装GD

[[email protected]]# tar -zxvf gd-2.0.35.tar.gz

[[email protected]]# cd gd-2.0.35

[[email protected]]# ./configure --prefix=/usr/local/gd \

>--with-zlib=/usr/local/zlib/ \      (指定zlib库文件的位置)

>--with-jpeg=/usr/local/jpeg/ \    (指定jpeg库文件的位置)

>--with-png=/usr/local/libpng/ \  (指定png库文件的位置)

>--with-freetype=/usr/local/freetype/     (指定freetype字体库的位置)

[[email protected]]# make

[[email protected]]# make install

 

执行make时如果出现如下错误:

make[2]: *** [gd_png.lo] Error 1

make[2]: Leaving directory`/usr/src/linux/gd-2.0.35‘

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

make[1]: Leaving directory`/usr/src/linux/gd-2.0.35‘

make: *** [all]  Error 2

解决方法:

[[email protected]]# find / -name gd_png.c

/usr/src/linux/gd-2.0.35/gd_png.c

[[email protected]]# find / -name png.h

/usr/local/libpng/include/png.h

[[email protected]]# vi /usr/src/linux/gd-2.0.35/gd_png.c

#include "png.h"    

改为#include "/usr/local/libpng/include/png.h"  

 

编译安装apr

[[email protected]]# tar -zxvf  apr-1.4.6.tar.gz

[[email protected]]# cd apr-1.4.6

[[email protected] apr-1.4.6]# ./configure --prefix=/usr/local/apr

[[email protected] apr-1.4.6]# make

[[email protected] apr-1.4.6]# make install

编译安装apr-utill

[[email protected]]# tar -zxvf  apr-utill-1.4.1.tar.gz

[[email protected]]# cd apr-utill-1.4.1

[[email protected] apr-utill-1.4.1]# ./configure --prefix=/usr/local/apr-utill

[[email protected] apr-utill-1.4.1]# make

[[email protected] apr-utill-1.4.1]# make install

 

编译安装pcre

[[email protected]]# tar -zxvf pcre-8.12.tar.gz

[[email protected]]# cd pcre-8.12

[[email protected] pcre-8.12]# ./configure --prefix=/usr/local/pcre

[[email protected] pcre-8.12]# make

[[email protected] pcre-8.12]# make install

注意以上三个是apache的依赖包,如果不在apache前安装,在编译apache时会报错。

12、编译安装apache

[[email protected]]# tar -zxvf httpd-2.2.9.tar.gz

[[email protected]]# cd httpd-2.2.9

[[email protected]]# ./configure --prefix=/usr/local/apache \

--with-sysconfdir=/etc/httpd/ \   指定apache配置文件的存放位置

--with-z=/usr/local/zlib/ \  指定zlib库文件存放位置

--with-apr=/usr/local/apr/ \  指定apr文件位置

--with-apr-util=/usr/local/apr-util/ \ 指定apr-util文件位置

--with-pcre=/usr/local/pcre/ \指定pcre文件位置 

apr,apr-util,pcre配置项也可简略写成--with-included-apr

--enable-deflate=shared \ 缩小传输码的支持

--enable-expires=shared \ 期满头控制

--enable-static-support \ 建立一个静态链接版本的支持

> --enable-so \       (以动态共享对象编译)注意:这个必须配置,否则apache运行异常

>--enable-rewrite  (基于规则的URL操控)

[[email protected]]# make

[[email protected]]# make install

apache加入开机启动↓

[[email protected]]# cp -vRp /usr/local/apache/bin/apachectl /etc/init.d/httpd

[[email protected]]# chmod +x /etc/init.d/httpd 

添加apache服务↓

[[email protected]]# chkconfig --add httpd

[[email protected]]# chkconfig --level 2345 httpd on

[[email protected]]# service httpd start

启动服务时,如果出现如下错误:

httpd: Could not reliablydetermine the server‘s fully qualified domain name, using localhost.localdomainfor ServerName

解决方法:

[[email protected]]# vi /usr/local/apache/conf/httpd.conf

添加上:ServerName localhost:80

 

执行chkconfig,如果出现如下错误:

service httpd does not supportchkconfig

解决方法:

[[email protected]]# vi /etc/rc.d/init.d/httpd

在文件第二行加入

#chkconfig:2345 10 90

#description:Activates/DeactivatesApache Web Server

保存后再执行chkconfig

13、编译安装mysql(最新版本都需要cmake编译安装)

 

编译安装 cmake

[[email protected]]# tar -zxvf cmake-2.8.7.tar.gz

[[email protected]]# cd cmake-2.8.7

[[email protected]]# ./bootstrap

[[email protected]]# gmake

[[email protected]]# gmake install

 

编译安装 MySQL5.5.20

[[email protected]]# groupadd mysql

[[email protected]]# useradd -g mysql mysql

[[email protected]]# tar -zxvf mysql-5.5.15.tar.gz

[[email protected]]# cd mysql-5.5.15

[[email protected]]#

cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \           (安装根目录)

> -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock \   UNIX socket文件)

>-DDEFAULT_CHARSET=utf8 \     (默认字符集)

>-DDEFAULT_COLLATION=utf8_general_ci \  (默认编码)

>-DWITH_EXTRA_CHARSETS=utf8,gbk \         (额外的编码)

>-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \(启用PERFSCHEMA引擎支持)

>-DWITH_FEDERATED_STORAGE_ENGINE=1 \   (启用FEDERATED引擎支持)

> -DWITH_PARTITION_STORAGE_ENGINE=1\     (启用PARTITION引擎支持)

>-DWITH_ARCHIVE_STORAGE_ENGINE=1 \         (启用ARCHIVE引擎支持)

>-DWITH_READLINE=1 \(使用readline功能)

>-DMYSQL_DATADIR=/usr/local/mysql/data \  (数据库数据目录)

>-DMYSQL_TCP_PORT=3306                              TCP/IP端口)

[[email protected]]# make

[[email protected]]# make install

[[email protected]]# cp -vRp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf

修改配置文件↓

[[email protected]]# vi /etc/my.cnf

     basedir=/usr/local/mysql

     datadir=/usr/local/mysql/data

     log-error=/usr/local/mysql/data/error.log

     pid-file=/usr/local/mysql/data/mysql.pid

初始化数据库文件↓

[[email protected]]# /usr/local/mysql/scripts/mysql_install_db \

>--defaults-flie=/etc/my.cnf \

> --basedir=/usr/local/mysql/\

>--datadir=/usr/local/mysql/data \

>--pid-file=/usr/local/mysql/data/mysql.pid \

> --user=mysql

权限设置↓

[[email protected]]# chown -R root .

[[email protected]]# chown -R mysql data

[[email protected]]# chgrp -R mysql .

mysql加入开机启动↓

[[email protected]]# cp -vRp support-files/mysql.server /etc/init.d/mysqld

[[email protected]]# chmod +x /etc/init.d/mysqld

添加mysql服务↓

[[email protected]]# chkconfig --add mysqld

[[email protected]]# chkconfig --level 345 mysqld on

[[email protected]]# service mysqld start

配置mysql

[[email protected]]# bin/mysql

mysql> deletefrom mysql.user where Host!=‘localhost‘; (只留允许本机登录的帐号)

mysql> flushprivileges;  (刷新授权表)

mysql> setpassword for ‘root‘@‘localhost‘=password(‘123456‘);  (设置用户密码)

mysql> exit

[[email protected]]# bin/mysql -h localhost -u root -p123456 (登录mysql

编译安装mysql低于mysql5.5版本的方法.以下是mysql5.1.6编译安装的一个实例

[[email protected]]# tar -zxvf mysql-5.1.6.tar.gz

[[email protected]]# cd mysql-5.1.6

[[email protected] mysql-5.1.6]# groupadd mysql #添加一个mysql标准组

[[email protected] mysql-5.1.6]#useradd mysql mysql # 添加一个mysql用户并且加入到mysql组中

[[email protected] mysql-5.1.6]# ./configure  --prefix=/usr/local/mysql \

--with-extra-charsets=all  #mysql 支持所有字符集

[[email protected] mysql-5.1.6] # make

[[email protected] mysql-5.1.6] # make install

权限设置↓

[[email protected] mysql-5.1.6] # cd /usr/local/mysql

[[email protected]]# chown -R root . 注意:这一行root 后面的’.’一定要加上,表示当前目录的所有文件,否则会报错

[[email protected]]# chown -R mysql data #这个是数据库库文件存放目录

[[email protected]]# chgrp -R mysql . 注意:这一行mysql 后面的’.’一定要加上,表示当前目录的所有文件,否则会报错

[[email protected]]# netstat –tnl #查看3306端口是否开启

[[email protected]]# ./bin/mysqld_safe  --user=mysql &   启动mysql

[[email protected]]# ./bin/mysqladmin version  查看mysql的版本信息

[[email protected]]# ./bin/mysql  进入mysql

[[email protected]]# select * from mysql.user \G   查看mysql的用户

[[email protected]]# delete from mysql.user where host!=’localhost’;  把不是localhost用户删除以确保mysql的安全性。

[[email protected]]# flush privileges  刷新mysql用户表

[[email protected]]# set password for ‘root’@’localhost’=password(‘123456’);  设置mysql登录密码

[[email protected]]# exit; 退出再登录测试是否设置密码成功。

[[email protected]]# ./bin/mysqladmin –u root –p 123456  shutdown 关闭mysql

mysqlapache的启动追加到开机文件中,避免每次登录进来都要启动mysqlapache

[[email protected]]# echo “/usr/local/apache2/bin/apachectl start”  >> /etc/rc.local

[[email protected]]# echo “/usr/local/mysql/bin/mysqld_safe  --user=mysql &” >> /etc/rc.local

14、编译安装php

[[email protected]]# tar -zxvf php-5.3.19.tar.gz

[[email protected]]# cd php-5.3.19

[[email protected]]# ./configure --prefix=/usr/local/php \

>--with-apxs2=/usr/local/apache/bin/apxs \

>--with-config-file-path=/usr/local/php/etc/ \

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

>--with-libxml-dir=/usr/local/libxml2/ \

>--with-png-dir=/usr/local/libpng/ \

>--with-jpeg-dir=/usr/local/jpeg/ \

>--with-freetype-dir=/usr/local/freetype/ \

> --with-gd=/usr/local/gd/\

>--with-mcrypt=/usr/local/libmcrypt/ \

>--with-mysqli=/usr/local/mysql/bin/mysql_config \

> --enable-soap\                  (变量激活SOAPweb services支持)

>--enable-mbstring=all \    (使多字节字符串支持)

>--enable-sockets                (变量激活socket通讯特性)

[[email protected]]# make

[[email protected]]# make install

[[email protected]]# cp -vRp php.ini-development /etc/php.ini

[[email protected]]# vi /usr/local/apache/conf/httpd.conf

添加上:

    AddType application/x-httpd-php .php

[[email protected]]# service httpd stop

[[email protected]]# service httpd start

[[email protected]]# vi /usr/local/apache/htdocs/phpinfo.php

整合lamp

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

注意:有些版本的源码包php下的配置可能是php.ini-development或者php.ini-product什么的,你可以根据实际复制一个到phpetc下就ok了。

[[email protected]] # vi /usr/local/apache2/conf/httpd.conf

AddType-application/x-httpd-php .php  把这一行添加到apache的配置文件里,然后重启apache;

/apache2/htdos下创建test.php

添加内容为:

<?php

       phpinfo();

?>

另外提醒一点就是在apache的配置文件里找到<dir_module>

</dir_module>在里面添加index.php index.html 会默认读取项目根目录的这两个文件,这样可以避免没输入index.phpindex.html时出现一个文件列表的情况。

打开浏览器进行访问,如果出现PHP版本界面,及安装成功。

时间: 2024-08-12 06:13:05

Lamp源码安装参考教程的相关文章

centos下lamp源码安装

LAMP指的Linux(操作系统).ApacheHTTP 服务器,MySQL(有时也指MariaDB,数据库软件) 和PHP(有时也是指Perl或Python) 的第一个字母,一般用来建立web 服务器. 安装mysql这里我们用的是mysql-5.6.15-linux-glibc2.5-x86_64.tar.gz的绿色软件包 解压mysql绿色软件包 [[email protected] lamp]# tar -zxvf mysql-5.6.15-linux-glibc2.5-x86_64.t

linux下使用qq————pidgin-lwqq 源码安装详细教程

今天费了不少功夫终于安装了pidgin——lwqq,可以在linux上使用qq了lwqq是在linux下通讯工具pidgin上使之支持webqq协议的组件下面来详细介绍一下安装方法,共介绍两种,通过apt-get工具和通过源码安装(针对ubuntu和debian用户) 要安装pidgin-lwqq首先要安装lwqq,这两个组件已经被分开 首先我们来安装lwqq 先是lwqq依赖的库的安装使用apt-get命令可以 $ sudo apt-get install build-essential cm

h5牛牛棋牌源码安装服务器教程

h5牛牛棋牌源码安装服务器 材料下载:h5.hubawl.com 1.系统:windows2008独立服务器,8核处理器,内存8G,带宽10M以上,php5.6以上版本+MYSQL 5.5的运行环境/或者Linux均可 2.备案域名+微信公众号+认证服务号 3.特别说明:Php环境要求ssl,需要一个cacert.pem证书文件 架设步骤: 1,导入程序根目录下的db.sql,到你的数据库 2,修改数据库配置文件/application/database.php里的数据库连接信息(请勿使用记事本

生产环境下:LAMP源码安装,搭建zabbix监控

1.系统环境检查,版本说明 1)版本说明 #httpd-2.4.25#mysql-5.7.17-linux-glibc2.5-x86_64 二进制压缩版#php5.6.30 #zabbix-3.0.8 2)关闭selinux.iptables,检查系统版本信息 sed -i 's/SELINUX=enabled/SELINUX=disabled/g' /etc/selinux/configgetenforce 0/etc/init.d/iptables stopcat /etc/redhat-r

LAMP源码安装,搭建zabbix监控

#LAMP#httpd-2.2.32#mysql-5.7.17-linux-glibc2.5-x86_64 二进制压缩版#php5.3.271.系统环境优化检查sed -i 's/SELINUX=enabled/SELINUX=disabled/g' /etc/selinux/configgetenforce 0/etc/init.d/iptables stopcat /etc/redhat-release CentOS release 6.7 (Final)uname -r2.6.32-431

lamp源码安装之二进制MySQL5.6.25安装

111 下载解压源码,由于是二进制文件,所以需要解压到/usr/local/目录下 先把自带的mysql移除 [[email protected] lib]# rpm -qa|grep mysql mysql-devel-5.1.73-3.el6_5.x86_64 mysql-libs-5.1.73-3.el6_5.x86_64 mysql-5.1.73-3.el6_5.x86_64 [[email protected] ~]# yum remove mysql 由于源码编译时间太长,所以这里的

lamp 源码安装之 centos6.5源码安装之php5.6.9

下载php5.6.9包并解压 [[email protected] ~]# wget http://cn2.php.net/distributions/php-5.6.9.tar.bz2 [[email protected] ~]# tar xf php-5.6.9.tar.bz2 编译安装 我的编译选项如下 --prefix=/usr/local/php:定义安装的路径 --with-mysql=/usr/local/mysql :指定mysql安装目录 --with-mysqli=/usr/

LAMP源码安装Discuz论坛

一.Mysql安装 http://mirrors.sohu.com/mysql/MySQL-5.1/   Mysql下载网站 cd /usr/local/src/ wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.72-linux-i686-glibc23.tar.gz tar zxvf mysql-5.1.72-linux-i686-glibc23.tar.gz  mv mysql-5.1.72-linux-i686-glibc23 

lamp源码安装出错及解决方案

一. 安装zlib时代码 cd /lamp/zlib-1.2.3 ./configure make make install 之后安装png,代码 cd /lamp/libpng-1.2.31 ./configure --prefix=/usr/local/libpng make make install 在make时 便报错,如下 /lib/libz.a(crc32.o): relocation R_X86_64_32 against `.rodata' can not be used whe