LNMP 编译安装
Dec 08, 2013
首先安装PCRE 来支持rewrite
- 下载地址:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
- 解压缩:sudo tar -zxvf pcre-8.30.tar.gz -C /usr/local/src
- 建立安装目录:cd /usr/local && sudo mkdir pcre
- 安装:./configure –prefix=/usr/local/pcre
make&&sudo make install - 安装完成之后测试!!!
再安装Zlib
—-
1.下载地址:http://prdownloads.sourceforge.net/libpng/zlib-1.2.8.tar.gz?download
2.cd /usr/local/src然后:ln -s ~/Downloads Downloads 将Downloads目录做个软链接
3.tar -zxvf zlib-1.2.8.tar.gz -C /usr/local/src
4.安装:./configure –prefix=/usr/local/zlib
make&&sudo make install
5.用whereis zlib 检查安装成功(是函数库非可执行文件) 安装nginx — 1.解压缩这里就不废话了,直接放到src下
2.cd /usr/local/
sudo mkdir lnmp
sudo chown ray lnmp
sudo chgrp www-data lnmp
编译:./configure –prefix=/usr/local/lnmp/nginx –with-pcre=/usr/local/src/pcre-8.30 –with-zlib=/usr/local/src/zlib-1.2.8 –with-http_ssl_module
这里注意:pcre和zlib的路径是源文件路径,所以前面我做了两步都是无用功了ngnix自己编译,我遇的到啊~:–with-pcre=path — sets the path to the sources of the PCRE library.
3.安装: make&&make install 安装Mysql — 1.下载地址:http://dev.mysql.com/downloads/file.php?id=450353
2.解压到src目录
3.建立mysql用户: sudo /usr/sbin/groupadd mysql
sudo /usr/sbin/useradd -g mysql mysql
将自己当前帐号加入mysql 组:usermod -a -G mysql ray
4.cd /usr/local/
sudo mkdir mysql
cd mysql
sudo mkdir mysql_data
4.切换到源文件根目录:sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/lnmp/mysqldata
详细配置说明地址:http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html
5.sudo make && sudo make install
6.sudo cp my-default.cnf /usr/local/lnmp/mysqldata/my.cnf (注意:my-large.cnf适用于1G内存左右的服务器,可以根据自己配置情况选用my-large.cnf 或 my-huge.cnf 等不同配置)
sudo cp mysql.server /etc/init.d/mysqld
编辑mysqld,basedir=/usr/local/lnmp/mysql;datadir=/usr/local/lnmp/mysqldata - sudo ./mysql_install_db –defaults-file=/usr/local/lnmp/mysqldata/my.cnf –basedir=/usr/local/lnmp/mysql datadir=/usr/local/lnmp/mysqldata –user=mysql
- 将mysqld加入服务,直接重启也可以:sudo apt-get install sysv-rc-conf
sudo sysv-rc-conf mysqld on - 测试:service mysqld restart
10.缺省安装的mysql是没有密码的,所以我们要修改,以防万一。下面采用三种方式来修改root的口令。
cd /usr/local/lnmp/mysql/bin/mysqladmin -uroot password test · 更多安全参考](http://www.cnblogs.com/xh831213/archive/2011/10/13/2210194.html) PHP 安装 — 1.安装libxml 用于解析xml的:
下载完成后解压缩到/usr/local/libxml
2.jpeg安装,下载http://www.ijg.org/files/jpegsrc.v9.tar.gz
解压缩到/usr/local/src/目录
./configure –prefix=/usr/local/jpeg-9->make&&sudo make install
3.安装PNG支持下载:libpng
./configure –prefix=/usr/local/libpng->make&&sudo make install
4.Freetype安装,下载,安装:./configure –prefix=/usr/local/freetype->make&&sudo make install
5.libmcrypt安装,下载
安装:./configure –prefix=/usr/local/libmcrypt-2.5.8->make&&sudo make install
6.mhash 安装,下载
安装:./configure –prefix=/usr/local/libmcrypt-2.5.8->make&&sudo make install
7.mcrypt下载
注意第七条依赖于5,6
直接编译出错 然后执行以下操作:1.~/.profile 里面加入export LD_LIBRARY_PATH=/usr/local/libmcrypt-2.5.8/lib:/usr/local/mhash-0.9.9.9/lib 配置前面两个库的lib地址
2../configure –prefix=/usr/local/mcrypt-2.6.8 –with-libmcrypt-prefix=/usr/local/libmcrypt-2.5.8
可惜又报另一个错误
参考这里
export CFLAGS=”-I /usr/local/mhash-0.9.9.9/include/”
export LDFLAGS=”-L /usr/local/mhash-0.9.9.9/lib -I /usr/local/mhash-0.9.9.9/include/”
再次执行configure 通过,但是make&&sudo make install 却报错
结果再参考make file 选项
发现上面两条export 是不正确的
正确的应该是:
export LDFLAGS=”-L/usr/local/libmcrypt-2.5.8/lib -L/usr/local/mhash-0.9.9.9/lib”;
export CFLAGS=”-I/usr/local/libmcrypt-2.5.8/include -I/usr/local/mhash-0.9.9.9/include”
注:/etc/ld.so.conf,关于.so动态库的载入参考鸟哥(http://linux.vbird.org/linux_basic/0520source_code_and_tarball.php)
最终编译安装mcrypt 成功,以上PHP 依赖库安装完毕
####接下来正式PHP 安装
1.下载并加压后
export LIBS=”-lm -ltermcap -lresolv”(注:这句我不晓得是什么意思所以没用)
export LD_LIBRARY_PATH=”/usr/local/lnmp/mysql/lib:/lib:/usr/lib/:/usr/local/lib/:/usr/local/libmcrypt-2.5.8/lib/:/usr/local/mhash-0.9.9.9/lib/:/lib64/:/usr/lib64/:/usr/local/lib64/” (参考不同操作系统设置:http://blog.chinaunix.net/uid-14504139-id-3867128.html)
../configure
--prefix=/usr/local/lnmp/php
--with-config-file-path=/usr/local/lnmp/php/etc
--with-mysql=/usr/local/lnmp/mysql
--with-mysqli=/usr/local/lnmp/mysql/bin/mysql_config
--with-freetype-dir=/usr/local/freetype
--with-jpeg-dir=/usr/local/jpeg-9
--with-png-dir=/usr/local/libpng
--with-zlib
--with-libxml-dir=/usr/local/libxml2
--enable-xml
--disable-rpath
--enable-bcmath
--enable-shmop[消息队列](http://wizardmin.com/2012/08/php-ipc-sysvmsg/)
--enable-sysvsem
--enable-inline-optimization(使用更多内存加快程序结果)
--with-curl
--enable-mbregex
--enable-fpm
--enable-mbstring
--with-mcrypt=/usr/local/mcrypt
--with-gd
--enable-gd-native-ttf
--with-openssl
--with-mhash
--enable-pcntl(打开进程控制支持)
--enable-sockets
--with-xmlrpc
--enable-zip
--enable-soap
--enable-fpm(开始没有加这个NGINX 就没办法解析PHP 有些作者真是肯跌啊)
出错啦:
解决方法:sudo apt-get install libcurl4-gnutls-dev 就不编译安装啦
再次错错:error: mcrypt.h not found. Please reinstall libmcrypt
解决方法:sudo apt-get install libmcrypt-dev很纳闷
再次错误:找不到mysql_config 这次是打字错误,更郁闷
完整configure: ./configure
make&&make test&&make install
启动php-fpm,cd /usr/local/lnmp/php/sbin/php-fpm
--prefix=/usr/local/lnmp/php
--with-config-file-path=/usr/local/lnmp/php/etc
--with-mysql=/usr/local/lnmp/mysql
--with-mysqli=/usr/local/lnmp/mysql/bin/mysql_config
--with-pdo-mysql=/usr/local/lnmp/mysql
--with-mysql-sock=/usr/local/lnmp/mysql/mysql.sock
--with-freetype-dir=/usr/local/freetype
--enable-fpm
--with-fpm-user=ray
--with-fpm-group=www-data
--with-jpeg-dir=/usr/local/jpeg-9
--with-png-dir=/usr/local/libpng
--with-zlib
--with-libxml-dir=/usr/local/libxml2
--enable-xml
--enable-bcmath
--enable-shmop
--enable-sysvsem
--enable-inline-optimization
--with-curl
--enable-mbregex
--enable-mbstring
--with-mcrypt=/usr/local/mcrypt
--with-gd
--enable-gd-native-ttf
--with-openssl
--with-mhash
--enable-pcntl
--enable-sockets
--enable-zip
--enable-soap