教程最新版本为:Centos下安装lnmp教程(最新版2012-02-05)http://blog.haohtml.com/archives/12473
1.对于ImageMagick,要使用 ftp://mirror.aarnet.edu.au/pub/imagemagick/ImageMagick-6.7.1-0.tar.gz 版本.2.对于imagick,要使用wget http://pecl.php.net/get/imagick-3.0.1.tgz 版本
yum -y install wget make zip unzipyum -y install patch
cd /etc/yum.repos.dmv CentOS-Base.repo CentOS-Base.repo.bakwget -O CentOS-Base.repo http://mirrors.sohu.com/help/CentOS-Base-sohu.repovi CentOS-Base.repo
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
cd /usr/srcwget http://blog.s135.com/soft/linux/nginx_php/php/php-5.2.14.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/phpfpm/php-5.2.14-fpm-0.5.14.diff.gzwget http://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.5.3-m3.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/pcre/pcre-8.10.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/nginx/nginx-0.8.46.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/libiconv/libiconv-1.13.1.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz//wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/memcache/memcache-2.2.5.tgzwget http://blog.s135.com/soft/linux/nginx_php/eaccelerator/eaccelerator-0.9.6.1.tar.bz2wget http://blog.s135.com/soft/linux/nginx_php/pdo/PDO_MYSQL-1.0.2.tgzwget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/imagick/imagick-2.3.0.tgz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
wget http://nginx.org/download/nginx-1.1.1.tar.gz
wget http://cn.php.net/distributions/php-5.2.17.tar.gzwget http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gzwget http://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.5.3-m3.tar.gzwget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgzwget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.12.tar.gz
wget http://cdnetworks-kr-2.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
wget “http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0”wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2wget http://pecl.php.net/get/memcache-2.2.5.tgzwget ftp://mirror.aarnet.edu.au/pub/imagemagick/ImageMagick-6.7.1-0.tar.gz
wget http://pecl.php.net/get/imagick-2.3.0.tgz
//wget http://pecl.php.net/get/imagick-3.0.1.tgz 最新的版本在Centos5下可能有问题,提示无法加载imagick.so库文件,在Centos6.0下正常.
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
tar zxvf mysql-5.5.3-m3.tar.gzcd mysql-5.5.3-m3/./configure –prefix=/usr/local/mysql/ –enable-assembler –with-extra-charsets=complex –enable-thread-safe-client –with-big-tables –with-readline –with-ssl –with-embedded-server –enable-local-infile –with-plugins=partition,innobase,myisammrgmake && make install
chmod +w /usr/local/mysqlchown -R mysql:mysql /usr/local/mysql
/usr/local/mysql/bin/mysql_install_db –basedir=/usr/local/mysql –user=mysqlcp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf/usr/local/mysql/bin/mysqld_safe &
/usr/local/mysql/bin/mysqladmin -u root password ‘123456’/usr/local/mysql/bin/mysql -u root -p
为了在下次重启服务器的时候可以自动重启相关服务,需要将MySQL加入到系统服务里面,这样就可以用service mysqld start|stop|restart进行操作
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
#把msql的脚本文件拷到系统的启动目录下
cd /etc/init.d/
chkconfig –add mysqld #将mysql加到启动服务列表里
chkconfig mysqld on #让系统启动时自动打开mysql服务,如果指定级别,用–level参数
ln -s /usr/local/mysql/bin/mysqldump /usr/sbin/mysqldump
ln -s /usr/local/mysql/bin/mysqld_safe /usr/sbin/mysqld_safe
ln -s /usr/local/mysql/bin/mysqlslap /usr/sbin/mysqlslap
ln -s /usr/local/mysql/bin/mysql /usr/sbin/mysql
ln -s /usr/local/mysql/bin/mysqladmin /usr/sbin/mysqladmin
=======================================
tar zxvf libiconv-1.13.1.tar.gzcd libiconv-1.13.1/./configure –prefix=/usr/localmakemake installcd ../
error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directorymake[1]: *** [install-pear-installer] 错误 127
make: *** [install-pear] Error 2
1.在/etc/ld.so.conf中加一行/usr/local/lib,
2.然后运行/sbin/ldconfig,文件解决,没有报错了~~
#########################################tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure –enable-ltdl-install
make
make install
cd ../../#########################################
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../
cd /usr/srctar zxvf php-5.2.14.tar.gzgzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1cd php-5.2.14/./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-iconv-dir=/usr/local –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-discard-path –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-fastcgi –enable-fpm –enable-force-cgi-redirect –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-ldap –with-ldap-sasl –with-xmlrpc –enable-zip –enable-soapmake ZEND_EXTRA_LIBS=’-liconv’make installcp php.ini-dist /usr/local/php/etc/php.ini
cd ../
cd /usr/srctar zxvf memcache-2.2.5.tgzcd memcache-2.2.5//usr/local/php/bin/phpize./configure –with-php-config=/usr/local/php/bin/php-configmakemake installcd ../
########################################
tar jxvf eaccelerator-0.9.6.1.tar.bz2cd eaccelerator-0.9.6.1//usr/local/php/bin/phpize./configure –enable-eaccelerator=shared –with-php-config=/usr/local/php/bin/php-configmakemake installcd ../
########################################
tar zxvf PDO_MYSQL-1.0.2.tgzcd PDO_MYSQL-1.0.2//usr/local/php/bin/phpize./configure –with-php-config=/usr/local/php/bin/php-config –with-pdo-mysql=/usr/local/mysqlmakemake installcd ../
########################################
tar zxvf ImageMagick.tar.gzcd ImageMagick-6.5.1-2/./configuremakemake installcd ../
########################################
tar zxvf imagick-2.3.0.tgzcd imagick-2.3.0//usr/local/php/bin/phpize./configure –with-php-config=/usr/local/php/bin/php-configmakemake installcd ../
#vi /usr/local/php/etc/php.ini
extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/”
extension = “memcache.so”extension = “pdo_mysql.so”extension = “imagick.so”
#mkdir -p /usr/local/eaccelerator_cache#vi /usr/local/php/etc/php.ini
[eaccelerator]zend_extension=”/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so”eaccelerator.shm_size=”64″eaccelerator.cache_dir=”/usr/local/eaccelerator_cache”eaccelerator.enable=”1″eaccelerator.optimizer=”1″eaccelerator.check_mtime=”1″eaccelerator.debug=”0″eaccelerator.filter=””eaccelerator.shm_max=”0″eaccelerator.shm_ttl=”3600″eaccelerator.shm_prune_period=”3600″eaccelerator.shm_only=”0″eaccelerator.compress=”1″eaccelerator.compress_level=”9″
/usr/sbin/groupadd www/usr/sbin/useradd -g www www
vi /usr/local/php/etc/php-fpm.conf
/usr/local/php/sbin/php-fpm start
#安装正则表达式库,支持rewite
tar zxvf pcre-8.10.tar.gzcd pcre-8.10/./configuremake && make installcd ../
########################################
tar zxvf nginx-0.8.46.tar.gzcd nginx-0.8.46/./configure –user=www –group=www –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_modulemake && make installcd ../
location ~ \.php$ {root html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;include fastcgi_params;}
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx
vi /etc/rc.local
ulimit -SHn 65535/usr/local/php/sbin/php-fpm start/usr/local/nginx/sbin/nginx
vi /usr/local/nginx/html/phpinfo.php
使用技巧:
/usr/local/nginx/sbin/nginx -t
the configuration file /usr/local/nginx/conf/nginx.conf syntax is okthe configuration file /usr/local/nginx/conf/nginx.conf was tested successfully
/usr/local/nginx/sbin/nginx -s reload
ps -ef | grep “nginx: master process” | grep -v “grep” | awk -F ‘ ‘ ‘{print $2}’
kill -HUP 6302
kill -HUP `cat /usr/local/nginx/nginx.pid`
convert -version
date.timezone = PRC
- Nginx优化配置(转)
- nginx配置支持php的pathinfo模式配置方法
- 网站压力测试工具webbench简介、安装、使用
- [教程]CentOS下安装 vsftpd 虚拟用户设置教程
- Linux下 XCache 编译安装方法
- linux下用phpize给PHP动态添加扩展
- ImageMagick及PHP的imagick扩展的安装及配置
- 在CentOS 5.5上安装MongoDB
- 安装Memcached
- centos下安装php-json
- nginx配置支持php的pathinfo模式配置方法
- nginx 目录自动加斜线 “/” 真正最佳
- CentOS配置SSH证书登录验证
- nginx 虚拟目录的配置
- nginx rewrite规则和参考
- Nginx虚拟主机配置
- nginx虚拟主机防webshell跨目录
- 管理员必看:20个Nginx Web服务器最佳安全实践
- Nginx无缝版本升级
注意:
如果用的是64位的系统.在安装过程中会出现一些找不到libjpeg之类的错误.原因是由于configure一般的搜索编译路径为/usr/lib/下,因为php默认就在/usr/lib/下找相关库文件,而x64机器上是在:/usr/lib64.这时你就可以直接把需要的库文件从/usr/lib64中拷贝到/usr/lib/中去就可以了.
参考李宴的Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器(第6版)[原创]而整理的.