超详细LAMP安装.docx
《超详细LAMP安装.docx》由会员分享,可在线阅读,更多相关《超详细LAMP安装.docx(18页珍藏版)》请在冰点文库上搜索。
![超详细LAMP安装.docx](https://file1.bingdoc.com/fileroot1/2023-5/28/2b872671-8d47-48f6-ad39-2f6bd2019f6a/2b872671-8d47-48f6-ad39-2f6bd2019f6a1.gif)
超详细LAMP安装
超详细LAMP安装
以下文献给那些被网上X人发的文章给误导的朋友
1、安装mysql(mysql-standard-5.0.27-linux-i686-glibc23.tar.gz)
安装文件放到了/usr/local/src目录
1)#tar-zxvfmysql-standard-5.0.27-linux-i686-glibc23.tar.gz-C/usr/local/mysql
2)#groupaddmysql建mysql组
3)#useradd-gmysqlmysql新增mysql用户,并添加到mysql组
4)#cd/usr/local/mysql
5)#scripts/mysql/mysql_install_db--user=mysql创建mysql授权表,如果是mysql用户登录可省--user=mysql
6)#chown-Rroot. 当前目录下的文件的所有属性改为root用户
7)#chown-Rmysqldata 将data数据目录的所有属性改为mysql用户
8)#chgrp-Rmysql. 将组属性改为mysql组
9)#bin/mysqld_safe--user=mysql&
10)#bin/mysqladmin-urootpassword'123456' 设置密码
11)#cpsupport-files/my-f/etc/f
数据库目录默认(/usr/local/var)LAMP
13)#vi/etc/rc.d/rc.local添加/usr/local/mysql/bin/mysqld_safe--user=mysql&//自动启动mysql服务
附:
mysql.server和mysqld_safe脚本和MacOSXStartupItem可以用来手动启动服务器,或自动启动系统。
mysql.server和StartupItem还可以用来停止服务器。
mysql.server脚本可以被用来启动或停止服务器,通过用start或stop参数调用它:
shell>mysql.serverstart
shell>mysql.serverstop
mysql.serverstop通过向服务器发出一个信号停止它。
你可手动执行mysqladminshutdown关闭服务器。
要想在服务器上自动启动和停止MySQL,应在“/etc/rc*文件中适当的地方增加启动、停止命令。
要想手动安装mysql.server(/usr/local/mysql/support-files),用名称mysql将它复制到/etc/init.d目录,然后将它变为可执行文件。
只需要将位置更改为mysql.serveris所在并执行这些命令的相应目录:
shell>cpmysql.server/etc/init.d/mysql
shell>chmod+x/etc/init.d/mysql
shell>chkconfig--level345MySQLon
也可以在一个全局“/etc/f”文件中增加mysql.server的选项。
一个典型的“/etc/f”文件可能看起来像这样:
[mysql.server]
basedir=/usr/local/mysql
2.安装OpenSSL
#tar-zxvfopenssl-0.9.8e.tar.gz-C/usr/local/src/
#cdopenssl-0.9.8e
#./config--prefix=/usr/local/opensslshared
#make
#makeinstall
修改(此步骤非常重要,至少对于现有的软件版本)
#vi/etc/ld.so.conf添加一行/usr/local/openssl/lib/
#/sbin/ldconfig
3、安装curl库
#tar-zxfcurl-7.15.0.tar.gz-C/usr/local/src/
#cdcurl-7.15.0
# mkdir/usr/local/curl
#./configure--prefix=/usr/local/curl
#make;makeinstall
安装PCRE(目的是让所装的软件支持perl正则表达式)
#rpm-qa|greppcre //查询系统中有没有安装PCRE,一般装系统是默认装有,所以我们要删掉系统自带的
#cp/lib/libpcre.so.0/ //在删除系统自带的PCRE之前,要先备份一下libpcre.so.0这个文件,因为RPM包的关联性太强,在删除后没libpcre.so.0这个文件时我们装PCRE是装不上的
#rpm-e--nodepspcre-6.6-1.1 //删除系统自带的PCRE
#tar-zxvfpcre-8.00.tar.gz-C/usr/local/src/
#cd/usr/local/src/pcre-8.00
#cp/libpcre.so.0/lib/ //把我们删除系统自带的PCRE之前备份的libpcre.so.0拷贝到/lib目录下。
#./configure //配置PCRE,因为PCRE是一个库,而不是像pache、php、postfix等这样的程序,所以我们安装时选择默认路径即可。
#make&&makeinstall
4、安装expat
#tar-zxvfexpat-2.0.0.tar.gz-C/usr/local/src/
#cdexpat-2.0.0
#mkdik/usr/local/expat
#./configure--prefix=/usr/local/expat
#make;makeinstall
5、gzip安装LAMP
#tar-zxvfgzip-1.3.5.tar.gz-C/usr/local/src/
#cdgzip-1.3.5
#mkdir/usr/local/gzip
#./configure--prefix=/usr/local/gzip
#make;makeinstall
6、安装ncurses(安装gd库会用到的)
#tarzxvfncurses-5.6.tar.gz-C/usr/local/src
#cd/usr/local/src/ncurses-5.6/
#./configure--prefix=/usr--with-shared--without-debug
#make;makeinstall
1. zlib(默认安装,请勿自作主张修改)
#tarzxvfzlib-1.2.3.tar.gz-C/usr/local/src/
#cd/usr/local/src/zlib-1.2.3/
#./configure--shared生成zlib的共享库文件
#make;makeinstall
2.libpng
#tarzxvflibpng-1.2.26.tar.gz-C/usr/local/src/
#cd/usr/local/src/libpng-1.2.26/
#cpscripts/makefile.linux./makefile//注意,这里的makefile不是用./configure生成,而是直接从scripts/里拷一个
#make;makeinstall
3.freetype(ttf)
#tarzxvffreetype-2.3.5.tar.gz-C/usr/local/src
#cd/usr/local/src/freetype-2.3.5/
#./configure--prefix=/usr/local/freetype
#make;makeinstall
4.jpegsrc
#tar-zxvfjpegsrc.v6b.tar.gz-C/usr/local/src/
#cd/usr/local/src/jpeg-6b/
#mkdir-pv/usr/local/libjpeg/{,bin,lib,include,man/man1,man1}
上面的命令是要手动创建一些目录,否则configure时候会说找不到目录
#./configure--prefix=/usr/local/libjpeg--enable-shared--enable-static
注意,这里configure一定要带--enable-shared参数,不然,不会生成共享库
#make;makeinstall
#makeinstall-lib //以前因为没有执行这一步安装导致在编译php时报错
5.安装libxml2
#tar-zxvflibxml2-2.6.31.tar.gz-C/usr/local/src/
#cd/usr/local/src/libxml2-2.6.31/
#./configure--prefix=/usr/local/libxml2(xml默认安装就可以,不要指定路径了,因为安装时php可能找不到它,PHP5只支持libxml2-2.5.10以上版本)
#make;makeinstall
#cpxml2-config/usr/bin/
6.libmcrypt
#tar-zxvflibmcrypt-2.5.7.tar.gz-C/usr/local/src/
#cd/usr/local/src/libmcrypt-2.5.7/
#./configure
#make;makeinstall
#cdlibmcrypt-2.5.8/libltdl
#./configure--enable-ltdl-install
#make
#makeinstall
注意:
不安装libltdl会导致php编译通不过
7.安装fontconfig
#tar-zxvffontconfig-2.4.2.tar.gz-C/usr/local/src/
#cd/usr/local/src/fontconfig-2.4.2/
#./configure--prefix=/usr/local/fontconfig--with-freetype-config=/usr/local/freetype/bin/freetype-config
如果报错:
LAMP
checkingforLIBXML2...configure:
error:
Packagerequirements(libxml-2.0>=2.6)werenotmet:
Nopackage'libxml-2.0'found
ConsideradjustingthePKG_CONFIG_PATHenvironmentvariableifyou
installedsoftwareinanon-standardprefix.
Alternatively,youmaysettheenvironmentvariablesLIBXML2_CFLAGS
andLIBXML2_LIBStoavoidtheneedtocallpkg-config.
Seethepkg-configmanpageformoredetails.
但是我们在上面其实已经安装上libxml2了的,这里只是一个环境变量没有设置好而已。
解决办法:
确定/usr/local/libxml2/lib/pkgconfig目录下有libxml-2.0.pc
#exportPKG_CONFIG_PATH=/usr/local/libxml2/lib/pkgconfig:
$PKG_CONFIG_PATH
然后
#./configure--prefix=/usr/local/fontconfig--with-freetype-config=/usr/local/freetype/bin/freetype-config
好了吧,没有出现那个错误了。
#make;makeinstall
8.安装xpm
[root@ddlhtdocs]#rpm-qa|grepxpm
libxpm-devel-3.5.5-3
libxpm-3.5.5-3
安装xpm
#tar-zxfxpm-3.4k.tar.gz-C/usr/local/src/
#cd/usr/local/src/xpm-3.4k
#xmkmf–a
如果上一句不行则执行:
xmkmf
makeMakefiles
makeincludes
makedepend
接下来执行:
#make
whichwillbuildtheXPMlibraryandthesxpmapplication.Thendo:
makeinstall
makeinstall.man
whichwillinstallthelibraryandthesxpmprogramandmanpage.
12、安装libxslt
#tar-zxflibxslt-1.1.15.tar.gz
#cdlibxslt-1.1.15
#mkdir/usr/local/libxslt
#./configure--prefix=/usr/local/libxslt--with-libxml-prefix=/usr/local/libxml2
#make;makeinstall
9.安装GD库,我们把这一步放在最后面
#tar-zxvfgd-2.0.35.tar.gz-C/usr/local/src/
#cd/usr/local/src/gd-2.0.35/
#./configure--prefix=/usr/local/libgd--with-png--with-zlib--with-freetype=/usr/local/freetype--with-jpeg=/usr/local/libjpeg--with-fontconfig=/usr/local/fontconfig--enable-m4_pattern_allow
下面出现:
表示都支持了
**Configurationsummaryforgd2.0.34:
SupportforPNGlibrary:
yes
SupportforJPEGlibrary:
yes
SupportforFreetype2.xlibrary:
yes
SupportforFontconfiglibrary:
yes
SupportforXpmlibrary:
yes
Supportforpthreads:
yes
#cpgd.h/usr/local/lib//编译PHP的时候缺少这个文件会出错
#cp/usr/local/libpng/include/png.h./
#cp/usr/local/libpng/include/pngconf.h./
#make;makeinstall
编辑/etc/ld.so.conf,添加以下几行到此文件中:
/usr/local/zlib/lib
/usr/local/freetype/lib
/usr/local/libjpeg/lib
/usr/local/libgd/lib
并执行ldconfig命令,使用动态装入器装载找到共享库
14、Apache安装
1、解压,mkdir/usr/local/apache2
2、进入解压后的目录(菜鸟请严格按下面的参考)
#./configure--prefix=/usr/local/apache2--with-mysql=/usr/local/mysql --enable-cgi--enable-ssl--with-ssl=/usr/local/openssl(--enable-so)这个参数适应的进行添加--enable-rewrite--enable-modules=all--enable-mods-shared=all
#make
#makeinstall
在/etc/rc.d/rc.local文件中加入一行
/usr/local/apache/bin/apachectlstart
这样每次重新启动系统以后,apache也会随系统一起启动.
(注解:
./configure//配置源代码树
--prefix=/usr/local/apache2//Apache的安装目录。
--enable-module=so//打开so模块,so模块是用来提DSO支持的apache核心模块
--enable-deflate=shared//支持网页压缩
--enable-expires=shared//支持HTTP控制
--enable-rewrite=shared//支持URL重写LAMP
--enable-cache//支持缓存
--enable-file-cache//支持文件缓存
--enable-mem-cache//支持记忆缓存
--enable-disk-cache//支持磁盘缓存
--enable-static-support//支持静态连接(默认为动态连接)
--enable-static-htpasswd//使用静态连接编译htpasswd-管理用于基本认证的用户文件
--enable-static-htdigest//使用静态连接编译htdigest-管理用于摘要认证的用户文件
--enable-static-rotatelogs//使用静态连接编译rotatelogs-滚动Apache日志的管道日志程序
--enable-static-logresolve//使用静态连接编译logresolve-解析Apache日志中的IP地址为主机名
--enable-static-htdbm//使用静态连接编译htdbm-操作DBM密码数据库
--enable-static-ab//使用静态连接编译ab-ApacheHTTP服务器性能测试工具
--enable-static-checkgid//使用静态连接编译checkgid
--disable-cgid//禁止用一个外部CGI守护进程执行CGI脚本
--disable-cgi//禁止编译CGI版本的PHP
--disable-userdir//禁止用户从自己的主目录中提供页面
--with-mpm=worker//让apache以worker方式运行
--enable-authn-dbm=shared//对动态数据库进行操作。
Rewrite时需要。
)
15、安装php
#tar-zxvfphp-5.2.6.tar.gz
#cdphp-5.2.6
#mkdir/usr/local/php5
#./configure--prefix=/usr/local/php5\
--with-apxs2=/usr/local/apache2/bin/apxs\
--with-freetype-dir=/usr/local/freetype\
--with-mysql=/usr/local/mysql\
--with-zlib-dir\
--with-libxml-dir=/usr/local/libxml2\
--enable-shared\
--with-curl=/usr/local/curl\
--with-iconv\
--enable-mbstring\
--with-gd=/usr/local/libgd\
--enable-gd-native-ttf\
--enable-gd-jis-conv\
--with-jpeg-dir=/usr/local/libjpeg\
--with-png-dir\
--enable-ftp\
--enable-soap\
--with-mcrypt=/usr/local/libmcrypt\
--enable-sockets \
--enable-force-cgi-redirect\
--enable-inline-optimization\
--disable-debug\
--with-libexpat-dir=/usr/local/expat\
--with-xsl=/usr/local/libxslt\
--with-openssl=/usr/local/openssl\
--enable-calendar\
--with-config-file-path=/usr/local/php5/etc\
#make;makeinstall
#cpphp.ini-dist /usr/local/php5/etc/php.ini
#vi/usr/local/php5/etc/php.ini
查找safe_mode=Off,更改为safe_mode=On
(1)查找max_execution_time=30,更改为max_execution_time=600
(2)查找max_input_time=60,更改为max_input_time=600
(3)查找memory_limit=8M,更改为memory_limit=20M
(4)查找display_errors=On,更改为display_errors=Off
(5)查找register_globals=Off,更改为register_globals=On
(6)查找post_max_size=8M,更改为post_max_size=20M
(7)查找upload_max_filesize=2M,更改为upload_max_filesize=20M
(8