CentOS下用yum搭建LNMP服务器

CentOS下搭服务器也折腾好几次了, 每次都知道个大概, 具体repo的地址什么的还都要现找, 实在不效率, 干脆整理记录下来.

yum安装比较简单快捷, 但默认配置的安全和性能方面不如LNMP一键安装包. 推荐生产环境用一键安装包

如果你在国内的话, 先替换CentOS-Base.repo

 
 
  1. mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
  2. # 如果是CentOS 5.*
  3. wget http://mirrors.163.com/.help/CentOS5-Base-163.repo
  4. # 如果是CentOS 6.*
  5. wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
  6. yum makecache

如果之前有apache, 卸载

 
 
  1. yum remove httpd

更新软件到最新版本

 
 
  1. yum -y update

安装源

 
 
  1. # 如果是CentOS 5.*
  2. rpm -ivh http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm
  3. rpm -ivh http://mirrors.sohu.com/fedora-epel/5/i386/epel-release-5-4.noarch.rpm
  4. rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
  5. # 如果是CentOS 6.*
  6. rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
  7. rpm -ivh http://mirrors.sohu.com/fedora-epel/6/i386/epel-release-6-5.noarch.rpm
  8. rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

编辑启用remi源

 
 
  1. vi /etc/yum.repos.d/remi.repo
  2. # 将[remi]下的enabled=0改为enabled=1
  3. # 按esc
  4. # :x回车

执行安装, 根据需要增减要安装的php模块

 
 
  1. yum install nginx mysql mysql-server 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

启动nginx, php-fpm, mysqld

 
 
  1. service nginx restart
  2. service php-fpm restart
  3. service mysqld restart

设置自动启动

 
 
  1. chkconfig nginx on
  2. chkconfig php-fpm on
  3. chkconfig mysqld on

mysql密码设置

 
 
  1. mysql_secure_installation

至于目录权限管理什么的, 就不写了.

niginx配置文件在/etc/nginx/nginx.conf
php-fpm配置文件在/etc/php-fpm.conf
php配置文件/etc/php.ini
mysql配置文件/etc/my.cnf

参考文章:
http://www.ppkj.net/2011/11/18/centos6-yum-%E6%90%AD%E5%BB%BAlinux-nginx-php-mysql-lnmp/
http://www.centos.bz/2011/03/yum-install-nginx-mysql-php-fastcgi-lnmp/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值