LNMP(即nginx-mysql-php)服务器一直是被认为性能高,内存占用少的服务器,下面我们来介绍怎么通过简单的YUM命令安装。
YUM安装特点:
1 2 |
比编译安装速度快 安全,yum安装是官方版本,减少一键包带来的风险 |
缺点就是要自定义配置
1、导入第三方软件库
#32位
1 2 |
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位
1 2 |
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
1 2 |
yum remove httpd yum update |
3、安装nginx
1 2 |
yum install nginx chkconfig --levels 235 nginx on #添加启动项 |
4、安装mysql
1 2 3 4 |
yum install mysql mysql-server chkconfig --levels 235 mysqld on #加入启动项 /etc/init.d/mysqld start #启动mysql mysql_secure_installation #mysql密码及相关设置 |
5、安装php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
. 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 |
1 2 3 |
vi /etc/php.ini #在行末添加cgi.fix_pathinfo = 1 chkconfig --levels 235 php-fpm on #加入启动项 service php-fpm start #启动 |
6、修改nginx配置文件,添加fastcgi支持
1 2 3 4 5 6 7 8 |
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
1 |
/etc/init.d/nginx restart |
8、运行探针
1 2 3 4 5 |
cd /usr/share/nginx/html vi mjj.php #添加以下代码 <!--?php phpinfo(); ?--> |
正常执行的话,LNMP就安装完了
果然MJJ连phpinfo都起名MJJ。。。。。
学习了,Beautyleg http://www.meiwall.com