centos原代码搭建LNMP.docx
- 文档编号:17839847
- 上传时间:2023-08-04
- 格式:DOCX
- 页数:17
- 大小:21.22KB
centos原代码搭建LNMP.docx
《centos原代码搭建LNMP.docx》由会员分享,可在线阅读,更多相关《centos原代码搭建LNMP.docx(17页珍藏版)》请在冰点文库上搜索。
centos原代码搭建LNMP
一、安装rpm包
libjpeg-devel、libpng-devel、libtiff-devel、fontconfig-devel、freetype-devel
libXpm-devel、gettext-devel、openssl-devel、libtool-ltdl-devel(libjpeg-devel,libpng-devel,libtiff-devel,fontconfig-devel,freetype-devel,libXpm-devel这些都是图片与字体相关的开发包,为了使php可以对其做更好的支持。
gettext是语言相关的一个函数库。
openssl-devel是一套工具,用于生成X.509协议中所使用的密钥,公钥等文件。
libtool是一个通用库支持脚本,在php编译过程中会需要使用到。
)
二、安装Nginx
安装pcre,系统自带的pcre版本过低,不能满足我们的需求。
pcre是一个正则表达式相关的包,要想Nginx使用Rewrite,那么就需要正则的支持。
[root@serverlnmp]#tarxfpcre-8.10.tar.bz2
[root@serverlnmp]#cdpcre-8.10
[root@serverpcre-8.10]#./configure(安装C语言编辑器包:
gcc*)
[root@serverpcre-8.10]#make&&makeinstall
编译安装Nginx
[root@serverlnmp]#useraddnginx
[root@serverlnmp]#tarxfnginx-0.8.46.tar.gz
[root@serverlnmp]#cdnginx-0.8.46
[root@servernginx-0.8.46]#./configure\
--user=nginx\
--group=nginx\
--prefix=/usr/local/nginx/\
--with-http_stub_status_module\
--with-http_ssl_module\
--with-sha1=/usr/lib
(会提示安装某些包。
eg:
*pcre*,openssl*)
(./configure后常几个常用参数:
--prefix=
--user=
--group=
--with-http_ssl_module启用https支持
--with-sha1指定希哈函数库位置)
[root@servernginx-0.8.46]#make&&makeinstall
[root@examplenginx-0.8.39]#/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf(-c是用来指定Nginx的主配置文件,如果没有指定则默认为/usr/local/nginx/conf/nginx.conf)
三、编译安装Mysql(此实验中只需安装mysql客户端,参照mysqp-proxy读写分离文件中安装mysql客户端代码)
[root@serverlnmp]#tarxfmysql-5.1.49.tar.gz
[root@serverlnmp]#cdmysql-5.1.49
[root@servermysql-5.1.49]#autoreconf--force--install
[root@servermysql-5.1.49]#./configure\
"--prefix=/usr/local/mysql"\
"--localstatedir=/var/lib/mysql/"\
"--enable-assembler"\c
"--with-extra-charsets=all"\
"--enable-thread-safe-client"\
"--with-client-ldflags=-all-static"\
"--with-mysqld-ldflags=-all-static"\
"--with-pthread"\
"--with-big-tables"\
"--without-debug"\
"--with-ssl"
[root@servermysql-5.1.49]#make&&makeinstall
[root@servermysql-5.1.49]#useraddmysql
[root@servermysql-5.1.49]#/usr/local/mysql/bin/mysql_install_db--user=mysql
[root@server~]#cd/usr/local/mysql
[root@servermysql]#chown-Rroot:
mysql.
[root@servermysql]#chownmysql./var/lib/mysql-R
[root@servermysql]#cpshare/mysql/my-f/etc/f
[root@servermysql]#cpshare/mysql/mysql.server/etc/init.d/mysqld
[root@servermysql]#chmod755/etc/init.d/mysqld
[root@servermysql]#chkconfig--addmysqld
[root@servermysql]#servicemysqldstart
[root@servermysql]#echo'exportPATH=$PATH:
/usr/local/mysql/bin'>>~/.bashrc
[root@servermysql]#.~/.bashrc
(yum-yinstallgccgcc-c++ncurses-devel
#tarzxvfmysql-5.1.35.tar.gz
#cdmysql-5.1.35
#./configure—prefix=/usr/local/mysql—without-server(根据提示安装包。
eg:
*termcap*)
#make&&makeinstall)
四、编译安装php
1.编译安装gd2。
(gd2是一个用以生成图形图片的库,RHEL自带gd2的开发包,但是版本比较低,生成的图片是黑白的,非常不美观,因此这边单独编译一个高版本。
)
[root@serverlnmp]#tarxfgd-2.0.34.tar.bz2
[root@serverlnmp]#cdgd-2.0.34
[root@servergd-2.0.34]#./configure–prefix=/usr/local/gd2
[root@servergd-2.0.34]#make&&makeinstall
2.编译安装libiconv。
(libiconv用于实现一个字符编码到另一个字符编码的转换。
)
[root@serverlnmp]#tarxflibiconv-1.13.1.tar.gz
[root@serverlnmp]#cdlibiconv-1.13.1
[root@serverlibiconv-1.13.1]#./configure--prefix=/usr
[root@serverlibiconv-1.13.1]#make&&makeinstall
3.编译安装libmcrypt。
(libmcrypt可以使php支持更多加密算法。
)
[root@serverlnmp]#tarxflibmcrypt-2.5.7.tar.gz
[root@serverlnmp]#cdlibmcrypt-2.5.7
[root@serverlibmcrypt-2.5.7]#./configure--prefix=/usr
[root@serverlibmcrypt-2.5.7]#make&&makeinstall
4.编译安装mhash。
(mhash是一个哈稀演函数库,它可以支持多种哈稀演算法,例如最出名的MD5、SHA1或GOST,还有其它多种的哈稀演算法。
)
[root@serverlnmp]#tarxfmhash-0.9.9.9.tar.bz2
[root@serverlnmp]#cdmhash-0.9.9.9
[root@servermhash-0.9.9.9]#./configure--prefix=/usr
[root@servermhash-0.9.9.9]#make&&makeinstall
5.[root@serverlnmp]#vim/etc/ld.so.conf添加/usr/lib
includeld.so.conf.d/*.conf
/usr/lib
[root@serverlnmp]#ldconfig(ldconfig命令的用途,主要是在默认搜寻目录(/lib和/usr/lib)以及动态库配置文件/etc/ld.so.conf内所列的目录,而当用户安装了一个新的动态链接库时,就需要手工运行这个命令。
)
6.编译安装spawn-fcgi。
(spawn-fcgi spawn-fcgi原本是lighttpd的一个用来控制php-cgi的工具,现在已从lighttpd中独立出来成为一个开源项目。
我们可以用它来启动,控制,管理php-cgi的进程。
使用它有诸多好处,比如我们可以将运行php-cgi的主机与Nginx分离开来,以减轻Nginx服务器的负担,或者用来扩展架构,做更多的负载分担。
减少进程的重复创建所带来的性能消耗等等。
)
[root@serverlnmp]#tarxfspawn-fcgi-1.6.3.tar.gz
[root@serverlnmp]#cdspawn-fcgi-1.6.3
[root@serverspawn-fcgi-1.6.3]#./configure--prefix=/usr/local/spawn-fcgi
[root@serverspawn-fcgi-1.6.3]#make&&makeinstall
7.编译安装libevent。
(libevent是一个事件触发的网络库,适用于windows、linux、bsd等多种平台,内部使用select、epoll、kqueue等系统调用管理事件机制。
)
[root@serverlnmp]#tarxflibevent-1.4.14b-stable.tar.gz
[root@serverlnmp]#cdlibevent-1.4.14b-stable
[root@serverlibevent-1.4.14b-stable]#./configure
[root@serverlibevent-1.4.14b-stable]#make&&makeinstall
8.编译安装mcrypt
[root@serverlnmp]#tarzxvfmcrypt-2.6.7.tar.gz
[root@serverlnmp]#cdmcrypt-2.6.7
[root@servermcrypt-2.6.7]#./configure--prefix=/usr&&make&&makeinstall
9.编译安装php
[root@serverlnmp]#tarxfphp-5.2.13.tar.bz2
[root@serverlnmp]#gzip-cdphp-5.2.8-fpm-0.5.10.diff.gz|patch-dphp-5.2.8-p1
[root@serverlnmp]#cdphp-5.2.13
[root@serverlnmp]#CHOST="i686-pc-linux-gnu"
[root@serverlnmp]#CFLAGS="-march=prescott-O3-pipe-fomit-frame-pointer"
[root@serverlnmp]#CXXFLAGS="${CFLAGS}"
[root@serverphp-5.2.13]#./configure\
"--prefix=/usr/local/php"\
"--enable-fastcgi"\
"--enable-discard-path"\
"--enable-force-cgi-redirect"\
"--with-config-file-path=/usr/local/php/etc"\
"--with-mysql=/usr/local/mysql"\
"--with-mysqli=/usr/local/mysql/bin/mysql_config"\
"--with-iconv-dir"\
"--with-freetype-dir"\
"--with-jpeg-dir"\
"--with-png-dir"\
"--with-gd=/usr/local/gd2/"\
"--with-zlib"\
"--with-libxml-dir"\
"--with-curl"\
"--with-curlwrappers"\
"--with-openssl"\
"--with-mhash"\
"--with-xmlrpc"\
"--with-mcrypt"\
"--enable-xml"\
"--enable-bcmath"\
"--enable-shmop"\
"--enable-sysvsem"\
"--enable-inline-optimization"\
"--enable-mbregex"\
"--enable-mbstring"\
"--enable-gd-native-ttf"\
"--enable-ftp"\
"--enable-pcntl"\
"--enable-sockets"\
"--enable-zip"\
"--disable-debug"\
"--disable-ipv6"(提示安装:
*libxml2*、*curl*)
(--enable-fastcgi启动fast-cgi
其中"--enable-discard-path"打开这个选项,用户就不能透过浏览器读取类似
.htaccess的系统安全相关的文件。
"--enable-force-cgi-redirect"若使用CGIVERSION模式来执行PHP的设,打开
本选项会增加安全性。
例如用户读http:
//my.host/cgi-bin/php/secret/doc.html遇到比较了解PHP系统的黑客级用户可能会自已输入以下网址http:
//my.host/secret/doc.html来读取相关信息。
若PHP和Apache编译在一起,让PHP变成Apache的一部份,则不需要加入本选项。
--with-config-file-path在指定php主配置文件的路径
--with-mysql和--with-mysqli在指定你的mysql的位置和它的相关工具
--with-iconv-dir,—with-freetype-dir,-with-jpeg-dir,—with-png-dir,--with-gd,--with-zlib,--with-libxml-dir这些都是在启用对某种文件的支持
--with-curl和--with-curlwrappers是用于支持curl函数,此函数允许你用不同的协议连接和沟通不同的服务器
--with-openssl,--with-mhash,--with-mcrypt这都是和加密有关的参数,启用它们是为了让php可以更好的支持各种加密。
"--enable-bcmath"高精度数学运算组件。
"--enable-shmop"和"--enable-sysvsem"使得你的PHP系统可以处理相关的IPC函数。
IPC是一个Unix标准通讯机制,它提供了使得在同一台主机不同进程之间可以互相通讯的方法。
"--enable-inline-optimization"栈堆指针和优化线程。
"--enable-pcntl"多线程优化。
)
[root@serverphp-5.2.13]##sed-i's#-lz-lm-lxml2-lz-lm-lxml2-lz-lm-lcrypt#&-liconv#'Makefile
[root@serverphp-5.2.13]#makeZEND_EXTRA_LIBS='-liconv'
(makeZEND_EXTRA_LIBS='-liconv'手工指定将iconv加到php额外库中,一般
来说这些库的增加php可以自动完成,只是iconv貌似不太合群,需要手工操作。
make完了之后,如果没有错误,你也可以执行一下maketest看看是否有错误,不过时间会比较长。
)
[root@serverphp-5.2.13]#maketest
[root@serverphp-5.2.13]#makeinstall
[root@serverphp-5.2.13]#cpphp.ini-dist/usr/local/php/etc/php.ini
五、安装php扩展模块工具
1.编译安装memcache。
(memcache是一个高性能的分布式的内存对象缓存系统,通过在内存里维护一个统一的巨大的hash表,它能够用来存储各种格式的数据,包括图像、视频、文件以及数据库检索的结果等。
)
[root@servertmp]#tar-zxfmemcache-3.0.4.tgz
[root@servertmp]#cdmemcache-3.0.4
[root@servermemcache-3.0.4]#/usr/local/php/bin/phpize(不成功,需装:
autoconf包)
[root@servermemcache-3.0.4]#./configure--with-php-config=/usr/local/php/bin/php-config
[root@servermemcache-3.0.4]#make&&makeinstall
2.编译安装eaccelerator。
(eAccelerator加速引擎是基于mmcache开发的PHP加速优化软件。
通过编译和缓存来增加PHP脚本的性能,使得PHP脚本在编译的状态下降低服务器负载,对服务器的开销几乎完全消除。
它还对脚本起优化作用,能加快其执行效率,提高PHP应用执行速度最高达10倍。
)
[root@serverlnmp]#tarxfeaccelerator-0.9.6.1.tar.bz2
[root@serverlnmp]#cdeaccelerator-0.9.6.1
[root@servereaccelerator-0.9.6.1]#/usr/local/php/bin/phpize
[root@servereaccelerator-0.9.6.1]#./configure--enable-eaccelerator=shared--with-php-config=/usr/local/php/bin/php-config
[root@servereaccelerator-0.9.6.1]#make
[root@servereaccelerator-0.9.6.1]#maketest
[root@servereaccelerator-0.9.6.1]#makeinstall
3.编译安装PDO_MYSQL。
(PDO_MYSQL是一个php的扩展模块,可以让php更好调用mysql。
)
[root@serverlnmp]#tarxfPDO_MYSQL-1.0.2.tgz
[root@serverlnmp]#cdPDO_MYSQL-1.0.2
[root@serverPDO_MYSQL-1.0.2]#/usr/local/php/bin/phpize
[root@serverPDO_MYSQL-1.0.2]#./configure--prefix=/usr/local/pdo-mysql--with-php-config=/usr/local/php/bin/php-config--with-pdo-mysql=/usr/local/mysql
[root@serverPDO_MYSQL-1.0.2]#make&&makeinstall
4.编译安装ImageMagick。
(ImageMagick是一个用于查看、编辑位图文件以及进行图像格式转换的开放源代码软件套装。
)
[root@serverlnmp]#tarxfImageMagick-6.5.9-10.tar.bz2
[root@serverlnmp]#cdImageMagick-6.5.9-10
[root@serverImageMagick-6.5.9-10]#./configure\
--enable-shared\
--with-modules\
--without-x\
--with-gs-font-dir=default\
--with-perl=yes\
--with-zlib=yes\
--with-jpeg=yes
[root@serverImageMagick-6.5.9-10]#make&&makeinstall
5.编译安装imagick。
[root@serverlnmp]#tarxfimagick-3.0.0.tgz
[root@serverlnmp]#cdimagick-3.0.0
[root@serverimagick-3.0.0]#/usr/local/php/bin/phpize
[root@serverimagick-3.0.0]#./configure--with-php-config=/usr/local/php/bin/php-config(--with-php-config在指定php的配置工具,/usr/l
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- centos 原代码 搭建 LNMP