centos x64 yum搭建lnmp环境(CentOS6.4)

  1. 配置CentOS 6.0 第三方yum源(CentOS默认的标准源里没有nginx软件包)
    yum install wget
    wget http://www.atomicorp.com/installers/atomic
    sh ./atomic
    yum update
  2. 安装开发包和库文件
    yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng 
    libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel 
    gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 
    libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel
  3. 卸载已安装的apache、mysql、php
    yum remove httpd
    yum remove mysql
    yum remove php

  4. 安装nginx
    yum install nginx
    service nginx start
    chkconfig --levels 235 nginx on
  5. 安装mysql
    yum install mysql mysql-server mysql-devel
    service mysqld start
    chkconfig --levels 235 mysqld on
    mysqladmin -u root password "密码" service mysqld restart
  6. 安装php
    yum install php lighttpd-fastcgi 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 php-common php-devel php-fpm
    
    service php-fpm start
    
    chkconfig --levels 235 php-fpm on
  7. 配置nginx支持php
    mv /etc/nginx/nginx.conf /etc/nginx/nginx.confbak
    cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf
    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;
    }
  8. 重启nginx php-fpm
    service nginx restart
    service php-fpm restart

你可能感兴趣的:(nginx,PHP,mysql,centos,yum)