Centos6.5下yum安装lnmp

  • 安装环境

    • Centos6.5
      # vi /etc/resolv.conf
         nameserver 8.8.8.8
         nameserver 114.114.114.114
      
  • 安装nginx

    1.安装nginx源
    #rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
    
    2.yum安装
    #yum -y install nginx
    
    3.设置开机启动
    #chkconfig nginx on
    
    4.启动nginx
    #service nginx start
    
    • 备注
    • 查看端口占用
      netstat -lntp | grep nginx
      
    • 查看进程
      ps -ef | grep nginx
      
  • 安装php

1.检查是否安装php

yum list installed | grep php

2.追加CentOS 6.5的epel及remi源。

# rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

3.安装php

# yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-gd php-bcmath -y

4.安装fpm

#yum install --enablerepo=remi --enablerepo=remi-php56 php-fpm -y

5.设置开机启动

#chkconfig php-fpm on

6.启动fpm

#/etc/init.d/php-fpm start
  • 安装mysql

1.安装mysql

#wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
#rpm -ivh mysql-community-release-el6-5.noarch.rpm
#yum repolist all | grep mysql
#yum install mysql-community-server -y

2.设置开机启动

#chkconfig mysqld on

3.启动

#/etc/init.d/mysqld start

4.拷贝配置文件

#cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

5.设置密码

#mysql_secure_installation
  • 配置

1.先关闭防火墙

#service iptables stop

2.修改nginx配置文件

#vi /etc/nginx/conf.d/default.conf

在最底部添加

    location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /$document_root$fastcgi_script_name;
    include        fastcgi_params;
    }

将root放到server下

root   /usr/share/nginx/html;

3.编写phpinfo放到root目录下


4.查看效果

你可能感兴趣的:(Centos6.5下yum安装lnmp)