centos6.8 yum 安装 lamp

安装 EPEL源

https://fedoraproject.org/wiki/EPEL

找到相应的centos版本

If you are running an EL6 version, please visit here to get the newest ‘epel-release’ package for EL6: The newest version of ‘epel-release’ for EL6

  1. rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

安装 remi 源

http://rpms.famillecollet.com/

找到相应的centos版本

Enterprise Linux 6 – repository auto-configuration package : remi-release-6.rpm

  1. rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

安装mysql

  1. yum --enablerepo=remi install mysql mysql-server

可能因为网络问题,连接不上remi源,先用vpn:https://www.flyvpn.com/cn/

配置mysql

  1. #配置 mysqld 开机自启动
  2. chkconfig mysqld on
  3. #启动 mysql
  4. service mysqld start
  5. #更改 root 密码
  6. mysql -uroot
  7. #进入 mysql,然后
  8. update mysql.user SET password=password('123456') WHERE user='root';
  9. # 让外网可以访问
  10. update mysql.user set host = '%' where user ='root';
  11. flush privileges;
  12. quit;

安装php

  1. yum --enablerepo=remi-php56 install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml php-soap php-fpm php-cli php-pdo

php可用源版本选择

http://rpms.famillecollet.com/enterprise/6/

设置php-fpm 开机启动

  1. chkconfig --add php-fpm
  2. chkconfig php-fpm on

安装nginx

http://nginx.org/en/linux_packages.html

创建nginx的yum 安装源
/etc/yum.repos.d/nginx.repo

  1. [nginx]
  2. name=nginx repo
  3. baseurl=http://nginx.org/packages/centos/6/$basearch/
  4. gpgcheck=0
  5. enabled=1
  1. #安装
  2. yum install --enablerepo=nginx nginx
  3. #启动
  4. service nginx start
  5. #设置为开机启动:
  6. chkconfig --add nginx
  7. chkconfig nginx on

nginx配置:/etc/nginx/conf.d/default.conf

  1. server {
  2. listen 80;
  3. server_name foo.com;
  4. root /www;
  5. index index.html index.htm index.php;
  6. location / {
  7. try_files $uri $uri/ /index.php;
  8. }
  9. location ~ \.php$ {
  10. try_files $uri =404;
  11. fastcgi_index index.php;
  12. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  13. include fastcgi_params;
  14. fastcgi_pass 127.0.0.1:9000;
  15. }
  16. }