1 centos升级(最新版本,目前6.4):
首先替换默认源为163源:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
mv CentOS6-Base-163.repo /etc/yum.repos.d/
#源包地址:http://tel.mirrors.163.com/centos/6.4/os/x86_64/Packages/
升级系统:
yum makecache
yum update
升级过程中报了一个key相关的错误,具体记不清了,重新执行yum update确定导入key即可。
重启,确认更新成功:
[root@localhost ~]# uname -r
2.6.32-220.7.1.el6.x86_64
[root@localhost ~]# cat /etc/centos-release
CentOS release 6.2 (Final)
2 nginx安装(6.3以上可以yum安装nginx):
第一步在/etc/yum.repos.d/目录下建立一个nginx.repo软件源配置文件。命令如下:
# cd /etc/yum.repos.d/
# vim nginx.repo
然后填写如下文件内容
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
执行vim命令保存文件为nginx.repo完整路径是/etc/yum.repos.d/nginx.repo
:w nginx.repo
执行yum命令安装nginx:
yum install nginx
在安装完成nginx后,需要设置防火墙设置允许80端口,操作如下:
# vim /etc/sysconfig/iptables
添加一行
-A INPUT –m state –state NEW –m tcp –p tcp –dport 80 –j ACCEPT
在修改完防火墙后需要执行如下命令重启防火
# /etc/init.d/iptables restart
紧接着启动nginx
# /etc/init.d/nginx start
安装顺利完成!
附:nginx命令
停止nginx服务:# /etc/init.d/nginx stop
启动nginx服务:# /etc/init.d/nginx start
编辑nginx配置文件:# vim /etc/nginx/nginx.conf
参考:http://www.cnblogs.com/highend/archive/2013/03/06/centos6_3_install_nginx_1_2_7.html
nginx.conf主配置文件
worker_processes 10;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events { worker_connections 1024; }
3 mysql 安装:
yum -y install mysql-server
mysql utf8 配置:
[mysqld]
datadir=/var/lib/mysql
#default-character-set=utf8
character-set-server = utf8
init_connect='SET NAMES utf8'
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
port = 3316
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
port=3316
default-character-set=utf8
mysql修改端口:(可能会报错,需要关闭selinux)
而关掉selinux,使用以下命令
/usr/sbin/setenforce 0
启动:service mysqld start
3 php安装(php-fpm启动 或spawn-fcgi 启动):
yum -y install php-fpm php-cli php-pdo php-mysql php-mcrypt php-mbstring php-gd php-tidy php-xml php-xmlrpc php-pear php-pecl-memcache php-eaccelerator
php-fpm 启动直接: /etc/rc.d/init.d/php-fpm start
spawn-fcgi 启动见: php5.3-spawn-fcgi启动