之所以转载这篇文章,是因为咱们如果一直使用军歌的编译安装包的话,那么时间上浪费不少(性能优秀的vps都至少需要17分钟安装lnmp.org的lnmp),因此阿福极力推荐使用yum安装。
YUM安装特点:
比编译安装速度快
安全,yum安装是官方版本,减少一键包带来的风险
缺点就是要自定义配置
方法:
1、导入第三方软件库
#32位
rpm -Uvh http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm
rpm -Uvh http://centos.alt.ru/repository/centos/5/i386/centalt-release-5-3.noarch.rpm
#64位
rpm -Uvh http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm
rpm -Uvh http://centos.alt.ru/repository/centos/5/x86_64/centalt-release-5-3.noarch.rpm
2、卸载系统自带的web server
yum remove httpd
yum update
3、安装nginx
yum install nginx
chkconfig –levels 235 nginx on #添加启动项
4、安装mysql
yum install mysql mysql-server
chkconfig –levels 235 mysqld on #加入启动项
/etc/init.d/mysqld start #启动mysql
mysql_secure_installation #mysql密码及相关设置
5、安装php
yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap php-tidy
#若提示:
Resolving Dependencies
–> Running transaction check
—> Package php-cli.i386 0:5.2.17-20.el5 set to be updated
–> Processing Dependency: php-common = 5.2.17-20.el5 for package: php-cli
–> Processing Dependency: libgmp.so.3 for package: php-cli
—> Package php-fpm.i386 0:5.2.17-20.el5 set to be updated
—> Package php-gd.i386 0:5.2.17-20.el5 set to be updated
–> Processing Dependency: libpng12.so.0 for package: php-gd
–> Processing Dependency: libpng12.so.0(PNG12_0) for package: php-gd
–> Processing Dependency: libfreetype.so.6 for package: php-gd
–> Processing Dependency: libt1.so.5 for package: php-gd
—> Package php-imap.i386 0:5.2.17-20.el5 set to be updated
–> Processing Dependency: libc-client.so.1 for package: php-imap
—> Package php-ldap.i386 0:5.2.17-20.el5 set to be updated
—> Package php-mbstring.i386 0:5.2.17-20.el5 set to be updated
—> Package php-mcrypt.i386 0:5.2.17-20.el5 set to be updated
–> Processing Dependency: libmcrypt.so.4 for package: php-mcrypt
—> Package php-mssql.i386 0:5.2.17-20.el5 set to be updated
–> Processing Dependency: php-pdo for package: php-mssql
–> Processing Dependency: libsybdb.so.5 for package: php-mssql
—> Package php-mysql.i386 0:5.2.17-20.el5 set to be updated
–> Processing Dependency: libmysqlclient.so.15(libmysqlclient_15) for package: php-mysql
–> Processing Dependency: libmysqlclient.so.15 for package: php-mysql
—> Package php-odbc.i386 0:5.2.17-20.el5 set to be updated
–> Processing Dependency: libodbc.so.1 for package: php-odbc
—> Package php-pear.noarch 1:1.9.1-1.el5 set to be updated
—> Package php-snmp.i386 0:5.2.17-20.el5 set to be updated
–> Processing Dependency: net-snmp for package: php-snmp
–> Processing Dependency: libnetsnmp.so.10 for package: php-snmp
—> Package php-soap.i386 0:5.2.17-20.el5 set to be updated
—> Package php-tidy.i386 0:5.2.17-20.el5 set to be updated
–> Processing Dependency: libtidy-0.99.so.0 for package: php-tidy
—> Package php-xml.i386 0:5.2.17-20.el5 set to be updated
–> Processing Dependency: libexslt.so.0 for package: php-xml
–> Processing Dependency: libxslt.so.1 for package: php-xml
—> Package php-xmlrpc.i386 0:5.2.17-20.el5 set to be updated
–> Running transaction check
—> Package freetds.i386 0:0.64-11.el5.centos set to be updated
—> Package freetype.i386 0:2.2.1-31.el5_8.1 set to be updated
—> Package gmp.i386 0:4.1.4-10.el5 set to be updated
—> Package libc-client.i386 0:2004g-2.2.1 set to be updated
—> Package libmcrypt.i386 0:2.5.8-4.el5.centos set to be updated
—> Package libpng.i386 2:1.2.10-17.el5_8 set to be updated
—> Package libtidy.i386 0:0.99.0-12.20070228.el5.centos set to be updated
—> Package libxslt.i386 0:1.1.17-2.el5_2.2 set to be updated
–> Processing Dependency: libgpg-error.so.0 for package: libxslt
–> Processing Dependency: libgcrypt.so.11 for package: libxslt
–> Processing Dependency: libgcrypt.so.11(GCRYPT_1.2) for package: libxslt
—> Package mysql.i386 0:5.0.95-1.el5_7.1 set to be updated
–> Processing Dependency: perl(DBI) for package: mysql
—> Package net-snmp.i386 1:5.3.2.2-17.el5_8.1 set to be updated
–> Processing Dependency: libsensors.so.3 for package: net-snmp
—> Package net-snmp-libs.i386 1:5.3.2.2-17.el5_8.1 set to be updated
—> Package php-common.i386 0:5.2.17-20.el5 set to be updated
—> Package php-gd.i386 0:5.2.17-20.el5 set to be updated
–> Processing Dependency: libt1.so.5 for package: php-gd
—> Package php-pdo.i386 0:5.2.17-20.el5 set to be updated
—> Package unixODBC-libs.i386 0:2.2.11-10.el5 set to be updated
–> Running transaction check
—> Package libgcrypt.i386 0:1.4.4-5.el5_8.2 set to be updated
—> Package libgpg-error.i386 0:1.4-2 set to be updated
—> Package lm_sensors.i386 0:2.10.7-9.el5 set to be updated
–> Processing Dependency: /usr/sbin/dmidecode for package: lm_sensors
—> Package perl-DBI.i386 0:1.52-2.el5 set to be updated
—> Package php-gd.i386 0:5.2.17-20.el5 set to be updated
–> Processing Dependency: libt1.so.5 for package: php-gd
–> Running transaction check
—> Package dmidecode.i386 1:2.11-1.el5 set to be updated
—> Package php-gd.i386 0:5.2.17-20.el5 set to be updated
–> Processing Dependency: libt1.so.5 for package: php-gd
–> Finished Dependency Resolution
php-gd-5.2.17-20.el5.i386 from CentALT has depsolving problems
–> Missing Dependency: libt1.so.5 is needed by package php-gd-5.2.17-20.el5.i386 (CentALT)
Error: Missing Dependency: libt1.so.5 is needed by package php-gd-5.2.17-20.el5.i386 (CentALT)
You could try using –skip-broken to work around the problem
You could try running: package-cleanup –problems
package-cleanup –dupes
rpm -Va –nofiles –nodigest
The program package-cleanup is found in the yum-utils package.
则执行yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap php-tidy –skip-broken
vi /etc/php.ini #在行末添加cgi.fix_pathinfo = 1
chkconfig –levels 235 php-fpm on #加入启动项
service php-fpm start #启动
6、修改nginx配置文件,添加fastcgi支持
vi /etc/nginx/nginx.conf
#添加以下
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
保存退出即可
7、启动nginx
/etc/init.d/nginx restart
8、运行探针
cd /usr/share/nginx/html
vi rffan.php
#添加以下代码
正常执行的话,LNMP就安装完了