CentOS环境下配置 Linux操作系统下载地址:http://pan.baidu.com/share/link?shareid=3714523259&uk=436334585
Apache+MySQL+PHP及相关的组件 下载地址:http://pan.baidu.com/share/link?shareid=3634124468&uk=436334585
LAMP环境是一个开源的可以免费使用的PHP开发环境组合。
下载的安装包解压命令:
]#tar zxvf 压缩包文件位置
第一步.安装libxml2
]#cd /soft/libxml2-2.6.30 //进入安装目录
使用如下命令配置libxml2库文件
]#./configure --prefix=/usr/local/libxml2 //执行libxml2库的配置命令并指定安装目录(/usr/jsj/libxml2为指定安装目录可以自己指定需要安装到某个目录)
]#make && make install //使用此命令编译并安装libxml2
安装时若提示:make: *** No targets specified and no makefile found. Stop.错误,则说明该Linux操作系统没有安装GCC导致无法编译
安装GCC方法如下:
在命令行模式敲入如下命令:# yum install gcc gcc-c++ autoconf automake
Linux会自动下载安装GCC,此命令需要预安装yum
第二步.安装libmcrypt库文件
]#./configure --prefix=/usr/local/libmcrypt //执行libmcrypt库的配置命令并指定安装目录
]#make && make install //编译并安装libmcrypt
第三步.安装zlib库文件
]#./configure //执行zlib库的配置命令
]#make && make install //编译并安装zlib
第四步.安装libpng库文件
]#./configure --prefix=/usr/local/libpng //执行libpng库的配置命令并指定安装目录
]#make && make install //编译并安装libpng
第五步.安装jpeg6库文件
]#mkdir /usr/local/jpeg6 //为安装jpeg6建立安装目录
]#mkdir /usr/local/jpeg6/bin //为安装jpeg6建立命令存放目录
]#mkdir /usr/local/jpeg6/lib //为安装jpeg6建立库文件存放目录
]#mkdir /usr/local/jpeg6/include //为安装jpeg6建立头文件存放目录
]#mkdir /usr/local/jpeg6/man/man1 //为jpeg6建立手册存放目录
]#./configure \ //执行jpeg6库的配置命令
>--prefix=/usr/local/jpeg6 \ //指定jpeg6的安装目录
>--enable-shared \ //建立共享库使用的GNU的libtool
>--enable-static //建立静态库使用的GNU的libtool
]#make && make install //编译并安装jpeg6
第六步.安装freetype库文件
]#./configure --prefix=/usr/local/freetype //执行freetype库配置命令并指定安装目录
]#make && make install //编译并安装freetype
第七步.安装autoconf库文件
]#./configure //执行autoconf库的配置命令
]#make && make install //编译并安装autoconf
第八步.安装GD库文件
]#./configure \ //执行gd库配置命令
>--prefix=/usr/local/gd2 \ //指定dg2的安装目录
>--with-jpeg=/usr/local/jpeg6 \ //指定jpeg6的安装目录
>--with-png=/usr/local/libpng \ //指定libpng的安装目录
>--with-treetype=/usr/local/treetype //指定treetype的安装目录
此处编译时若出现如下错误:
gd_png.c:16:53: error: png.h: No such file or directory
gd_png.c:47: error: expected specifier-qualifier-list before ‘jmp_buf’
gd_png.c:54: error: expected ‘)’ before ‘png_ptr’
gd_png.c:82: error: expected ‘)’ before ‘png_ptr’
gd_png.c:92: error: expected ‘)’ before ‘png_ptr’
gd_png.c:98: error: expected ‘)’ before ‘png_ptr’
gd_png.c: In function ‘gdImageCreateFromPngCtx’:
gd_png.c:125: error: ‘png_byte’ undeclared (first use in this function)
gd_png.c:125: error: (Each undeclared identifier is reported only once
gd_png.c:125: error: for each function it appears in.)
gd_png.c:125: error: expected ‘;’ before ‘sig’
gd_png.c:126: error: ‘png_structp’ undeclared (first use in this function)
gd_png.c:126: error: expected ‘;’ before ‘png_ptr’
gd_png.c:127: error: ‘png_infop’ undeclared (first use in this function)
gd_png.c:127: error: expected ‘;’ before ‘info_ptr’
gd_png.c:128: error: ‘png_uint_32′ undeclared (first use in this function)
gd_png.c:128: error: expected ‘;’ before ‘width’
gd_png.c:131: error: ‘png_colorp’ undeclared (first use in this function)
gd_png.c:131: error: expected ‘;’ before ‘palette’
gd_png.c:132: error: ‘png_color_16p’ undeclared (first use in this function)
gd_png.c:132: error: expected ‘;’ before ‘trans_gray_rgb’
gd_png.c:133: error: expected ‘;’ before ‘trans_color_rgb’
gd_png.c:134: error: ‘png_bytep’ undeclared (first use in this function)
gd_png.c:134: error: expected ‘;’ before ‘trans’
gd_png.c:135: error: expected ‘;’ before ‘image_data’
gd_png.c:136: error: ‘png_bytepp’ undeclared (first use in this function)
gd_png.c:136: error: expected ‘;’ before ‘row_pointers’
gd_png.c:144: error: ‘sig’ undeclared (first use in this function)
gd_png.c:157: error: ‘png_ptr’ undeclared (first use in this function)
gd_png.c:157: error: ‘PNG_LIBPNG_VER_STRING’ undeclared (first use in this function)
gd_png.c:157: error: ‘gdPngErrorHandler’ undeclared (first use in this function)
gd_png.c:166: error: ‘info_ptr’ undeclared (first use in this function)
gd_png.c:182: error: ‘jmpbuf_wrapper’ has no member named ‘jmpbuf’
gd_png.c:192: error: ‘gdPngReadData’ undeclared (first use in this function)
gd_png.c:195: error: ‘width’ undeclared (first use in this function)
gd_png.c:195: error: ‘height’ undeclared (first use in this function)
gd_png.c:196: error: ‘PNG_COLOR_TYPE_RGB’ undeclared (first use in this function)
gd_png.c:196: error: ‘PNG_COLOR_TYPE_RGB_ALPHA’ undeclared (first use in this function)
gd_png.c:204: error: ‘image_data’ undeclared (first use in this function)
gd_png.c:205: error: ‘row_pointers’ undeclared (first use in this function)
gd_png.c:220: error: ‘jmpbuf_wrapper’ has no member named ‘jmpbuf’
gd_png.c:233: error: ‘PNG_COLOR_TYPE_PALETTE’ undeclared (first use in this function)
gd_png.c:234: error: ‘palette’ undeclared (first use in this function)
gd_png.c:238: error: ‘PNG_INFO_tRNS’ undeclared (first use in this function)
gd_png.c:246: error: ‘trans’ undeclared (first use in this function)
gd_png.c:258: error: ‘PNG_COLOR_TYPE_GRAY’ undeclared (first use in this function)
gd_png.c:259: error: ‘PNG_COLOR_TYPE_GRAY_ALPHA’ undeclared (first use in this function)
gd_png.c:261: error: expected ‘)’ before ‘gdMalloc’
gd_png.c:280: error: ‘trans_gray_rgb’ undeclared (first use in this function)
gd_png.c:305: error: ‘trans_color_rgb’ undeclared (first use in this function)
gd_png.c:322: error: ‘rowbytes’ undeclared (first use in this function)
gd_png.c:327: error: expected ‘;’ before ‘gdMalloc’
gd_png.c:345: error: expected ‘;’ before ‘gdMalloc’
gd_png.c:357: error: ‘h’ undeclared (first use in this function)
gd_png.c:381: error: ‘PNG_INTERLACE_ADAM7′ undeclared (first use in this function)
gd_png.c:389: error: ‘w’ undeclared (first use in this function)
gd_png.c:390: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘r’
gd_png.c:390: error: ‘r’ undeclared (first use in this function)
gd_png.c:391: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g’
gd_png.c:391: error: ‘g’ undeclared (first use in this function)
gd_png.c:392: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘b’
gd_png.c:392: error: ‘b’ undeclared (first use in this function)
gd_png.c:401: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘r’
gd_png.c:402: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g’
gd_png.c:403: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘b’
gd_png.c:410: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘a’
gd_png.c:410: error: ‘a’ undeclared (first use in this function)
gd_png.c:419: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘idx’
gd_png.c:419: error: ‘idx’ undeclared (first use in this function)
gd_png.c: In function ‘gdImagePngCtxEx’:
gd_png.c:499: error: ‘png_byte’ undeclared (first use in this function)
gd_png.c:499: error: expected ‘;’ before ‘trans_values’
gd_png.c:500: error: ‘png_color_16′ undeclared (first use in this function)
gd_png.c:500: error: expected ‘;’ before ‘trans_rgb_value’
gd_png.c:501: error: ‘png_color’ undeclared (first use in this function)
gd_png.c:501: error: expected ‘;’ before ‘palette’
gd_png.c:502: error: ‘png_structp’ undeclared (first use in this function)
gd_png.c:502: error: expected ‘;’ before ‘png_ptr’
gd_png.c:503: error: ‘png_infop’ undeclared (first use in this function)
gd_png.c:503: error: expected ‘;’ before ‘info_ptr’
gd_png.c:508: error: ‘png_ptr’ undeclared (first use in this function)
gd_png.c:508: error: ‘PNG_LIBPNG_VER_STRING’ undeclared (first use in this function)
gd_png.c:509: error: ‘gdPngErrorHandler’ undeclared (first use in this function)
gd_png.c:520: error: ‘info_ptr’ undeclared (first use in this function)
gd_png.c:524: error: ‘png_infopp’ undeclared (first use in this function)
gd_png.c:529: error: ‘jmpbuf_wrapper’ has no member named ‘jmpbuf’
gd_png.c:537: error: ‘gdPngWriteData’ undeclared (first use in this function)
gd_png.c:538: error: ‘gdPngFlushData’ undeclared (first use in this function)
gd_png.c:595: error: ‘PNG_INTERLACE_ADAM7′ undeclared (first use in this function)
gd_png.c:595: error: ‘PNG_INTERLACE_NONE’ undeclared (first use in this function)
gd_png.c:602: error: ‘PNG_COLOR_TYPE_RGB_ALPHA’ undeclared (first use in this function)
gd_png.c:603: error: ‘PNG_COMPRESSION_TYPE_DEFAULT’ undeclared (first use in this function)
gd_png.c:604: error: ‘PNG_FILTER_TYPE_DEFAULT’ undeclared (first use in this function)
gd_png.c:609: error: ‘PNG_COLOR_TYPE_RGB’ undeclared (first use in this function)
gd_png.c:617: error: ‘PNG_COLOR_TYPE_PALETTE’ undeclared (first use in this function)
gd_png.c:623: error: ‘trans_rgb_value’ undeclared (first use in this function)
gd_png.c:672: error: ‘trans_values’ undeclared (first use in this function)
gd_png.c:694: error: ‘palette’ undeclared (first use in this function)
gd_png.c:725: error: ‘png_bytep’ undeclared (first use in this function)
gd_png.c:725: error: ‘row_pointers’ undeclared (first use in this function)
gd_png.c:731: error: ‘prow_pointers’ undeclared (first use in this function)
gd_png.c:747: error: expected ‘)’ before ‘gdMalloc’
gd_png.c:804: error: expected ‘)’ before ‘gdMalloc’
make[2]: *** [gd_png.lo] 错误 1
make[2]:正在离开目录 `/usr/local/src/modules/gd-2.0.35′
make[1]: *** [all-recursive] 错误 1
make[1]:正在离开目录 `/usr/local/src/modules/gd-2.0.35′
make: *** [all] 错误 2
则是因为gd库源文件中的 gd_png.c 文件里面的第十六行代码 #include "png.h" /* includes zlib .h and setjmp.h */中的php.h路径错误,修改为 /usr/local/libpng/png.h 即可
具体修改方法如下:
]#vi gd_png.c //用vi编辑器编辑gd_png.c文件
进入文档编辑画面后按Shift+;键切换到输入vi命令模式 输入set number命令显示行号找到第十六行按i键进入文档编辑模式做上述相应的修改,按Esc键退出文档编辑模式,继续按Shift+;键切换到vi命令模式输入wq保存退出该文档即可
]#make && make install //编译并安装gd库
第九步.安装Apache服务器
]#./configure \ //执行Apache服务器配置命令
>--prefix=/usr/local/apache2 \ //指定Apache服务器的安装目录
>--sysconfdir=/etc/httpd \ //指定Apache服务器配置文件的存放位置
>--with-included-apr \ //使用捆绑APR/APR-Util的副本
>--enable-so \ //以动态共享对象(DSO)编译
>--enable-deflate=shared \ //添加缩小传输编码的支持
>--enable-expires=shared \ //期满头控制
>--enable-rewrite=shared \ //基于规则的URL控制
>--enable-static-support //建立静态链接版本的支持
]#make && make install //编译并安装
测试Apache服务器
启动Apache服务器命令:
]#/usr/local/apache2/bin/apachectl start
打开浏览器在地址栏输入:http://localhost/ 测试Apache服务器若显示 It works!则说明Apache服务器可以正常运行
停止Apache服务器命令:
]#/usr/local/apache2/bin/apachectl stop
添加Apache服务器到开机自动启动
]#echo "/usr/local/apache2/bin/apachectl start">>/etc/rc.d/rc.local
第十步.安装MySQL数据库服务器
]#groupadd mysql //创建mysql组
]#useradd -g mysql mysql //创建mysql用户并添加到mysql组
]#./configure \ //执行mysql的配置命令
>--prefix=/usr/local/mysql \ //指定mysql的安装目录
>--with-extra-charsets=all //使MySQL支持所有的字符集
]#make && make install //编译并安装mysql数据库
配置时提示如下信息:
checking for termcap functions library... configure: error: No curses/termcap library found
编译时提示如下错误:
make: *** No targets specified and no makefile found. Stop.
上述错误提示显示:Linux操作系统缺少curses/termcap库
使用如下命令查找curses安装包
]#yum list|grep ncurses
使用如下命令安装curses库
]#yum -y install ncurses-devel
安装完成后重新执行上述mysql的安装命令即可成功安装MySQL数据库
配置MySQL数据库
]#cp support-files/my-medium.cnf /etc/my.cnf //创建MySQL数据库配置文件,此处为拷贝安装包目录下的配置文件到/etc目录下面并更名为my.cnf
]#/usr/local/mysql/bin/mysql_install_db --user=mysql //创建授权表
]#cd /usr/local/mysql //进入到mysql安装目录
]#chown -R root . //将所有文件的属性修改为root用户
]#chown -R mysql var //将数据目录的属性修改为mysql用户
]#chgrp -R mysql . //将所有文件的组属性修改为mysql组
]#/usr/local/mysql/bin/mysqld_safe --user=mysql & //后台启动MySQL数据库
]#netstat -tnl|grep 3306 //查看3306端口是否打开
]#/usr/local/mysql/bin/mysqladmin version //查看版本信息
]#/usr/local/mysql/bin/mysqladmin variables //查看所有MySQL参数
]#/usr/local/mysql/bin/mysql -u root //登陆MySQL服务器(刚安装完无密码可以直接登陆服务器,需要设置MySQL服务器密码)
mysql> DELETE FROMmysql.user WHERE Host='localhost' AND User=''; --使用此SQL命令删除匿名用户信息 mysql> DELETE FROM mysql.user WHERE Host='127.0.0.1' OR Host='localhost.localdomain';--删除除了localhost以外的其他用户 mysql> FLUSH PRIVILEGES; --使用该命令刷新系统权限相关表mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');--为root用户设置密码mysql> EXIT --退出MySQL数据库 ]#/usr/local/mysql/bin/mysql -u root -p //进入MySQL客户端 password: //输入密码进入SQL 第十一步.安装PHP模块 ]# ./configure \ //执行PHP的配置命令> --prefix=/usr/local/php \ //设置PHP的安装路径> --with-config-file-path=/usr/local/php/etc \ //指定PHP配置文件的放置路径> --with-apxs2=/usr/local/apache2/bin/apxs \ //指定Apache 2的安装目录> --with-mysql=/usr/local/mysql/ \ //指定MySQL的安装目录> --with-libxml-dir=/usr/local/libxml2/ \ //指定libxml2库的安装目录> --with-png-dir=/usr/local/libpng/ \ //指定libpng库的安装目录> --with-jpeg-dir=/usr/local/jpeg6/ \ //指定jpeg库的安装目录> --with-freetype-dir=/usr/local/freetype/ \ //指定freetype库的安装目录> --with-gd=/usr/local/gd2/ \ //指定gd库的安装目录> --with-mcrypt=/usr/local/libmcrypt/ \ //指定libmcrypt库的安装目录> --with-mysqli=/usr/local/mysql/bin/mysql_config \ //变量激活新增加的MySQLi功能> --enable-soap \ //变量激活SOAP和Web services支持> --enable-mbstring=all \ //使PHP支持多字节字符串> --enable-sockets //变量激活socket通讯特性]#make && make install //编译并安装PHP模块PHP模块配置]#cp php.ini-dist /usr/local/php/etc/php.ini //创建PHP配置文件]#vi /etc/httpd/httpd.conf //编辑Apache配置文件在Apache配置文件的315行添加如下配置:AddType application/x-httpd-php .php .phtml #添加该配置,使Apache服务器支持.php、.phtml文件第十二步.安装Zend加速器]#./install.sh //安装Zend加速器安装过程中指定PHP配置文件的目录为:/usr/local/php第十三步.安装PHPMyAdmin]# cp -a phpMyAdmin-3.0.0-rc1-all-languages/ /usr/local/apache2/htdocs/phpmyadmin //拷贝phpMyAdmin目录到Apache服务器的htdocs目录下]# cd /usr/local/apache2/htdocs/phpmyadmin/ //进入phpmyadmin目录]# cp config.samplc.inc.php config.inc.php //重命名配置文件为config.inc.php配置phpMyAdmin]# vi /usr/local/apache2/htdocs/phpmyadmin/config.inc.php //打开phpmyadmin的配置文件?$cfg['blowfish_secret'] //查找到该属相写入一个属性值:wq! //退出VI文本编辑器 到此为止整个LAMP环境配置完成,之后会添加一些更详细的配置。