让history加上时间,加在/etc/bashrc文件上

vi /etc/bashrc

加入下面语句,然后重新登录就可生效

# add history time
export HISTTIMEFORMAT="%F %T "
Tags: ,

linux系统版本检查

[不指定 2010/04/03 19:35 | by birdsky ]
linux系统的版本检查命令有:

cat /etc/issue

cat /etc/redhat-release

uname -a

uname -a 还可以看出系统是32位的还是64位的

64位的系统有x86_64字样,如下:
Linux qy 2.6.18-128.el5 #1 SMP Wed Jan 21 10:41:14 EST 2009 x86_64 x86_64 x86_64 GNU/Linux

32位的系统有i686 i386字样
Linux localhost.localdomain 2.6.18-128.el5 #1 SMP Wed Jan 21 10:44:23 EST 2009 i686 i686 i386 GNU/Linux
Tags: ,
     在 64位版本的 CentOS 5.4 上使用 yum 安装软件包的时候如果不小心的话会同时安装 i386 和 x86_64 版本的软件。同时安装32位和64位版本的软件虽然不是什么错,也不会对系统造成什么问题,但是这样会浪费硬盘空间,而且显得系统臃肿、不干净。如果想要保持一个纯的64位系统、在64位 CentOS 上避免安装32位软件包的话很容易,只需要在 yum.conf 加上一行过滤掉 i386, i686 的软件包就可以了:

# vi /etc/yum.conf

[main]
...
exclude=*.i386 *.i686
Tags: , ,
一、更改yum源为网易的源加快速度
cd /etc/yum.repos.d/

cp CentOS-Base.repo CentOS-Base.repo.bak

wget http://mirrors.163.com/.help/CentOS-Base-163.repo

mv CentOS-Base-163.repo CentOS-Base.repo


更新缓存
yum makecache

或者直接修改CentOS-Base.repo文件
vi /etc/yum.repos.d/CentOS-Base.repo

更改内容如下
# CentOS-Base.repo
#
# This file uses a new mirrorlist system developed by Lance Davis for CentOS.
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
baseurl=http://mirrors.163.com/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

二、update yum

rpm --import /etc/pki/rpm-gpg/RPM*   #这可以解决由于yum安装了旧版本的GPG keys造成的错误

如果是64位系统,为避免32位老版本冲突,可以先删除32位版本软件包
yum erase *.i686

yum erase *.i386

然后再升级
yum -y update


三、利用CentOS Linux系统自带的yum命令安装、升级所需的程序库

如果是64位系统,为避免32位老版本冲突,可以先删除32位版本,然后再执行以下操作
LANG=C

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-common glibc-headers glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers


四、安装php和mysql

yum -y install php mysql mysql-server mysql-devel php-mysql php-cgi php-mbstring php-gd php-fastcgi libmcrypt php-mhash php-mcrypt php-snmp

五、安装nginx
由于centos没有默认的nginx软件包,需要启用REHL的附件包
32位系统
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
64位系统
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-3.noarch.rpm

安装nginx
yum -y install nginx

设置开机启动

chkconfig nginx on

六、安装spawn-fcgi来运行php-cgi

yum -y install spawn-fcgi


七、下载spawn-fcgi 的启动脚本

wget http://bash.cyberciti.biz/dl/419.sh.zip

unzip 419.sh.zip

mv 419.sh /etc/init.d/php_cgi

chmod +x /etc/init.d/php_cgi


启动php_cgi
/etc/init.d/php_cgi start

查看进程
netstat -tulpn | grep :9000

若出现如下代表一切正常
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 4352/php-cgi

八、配置nginx(详细配置见nginx.conf详细说明)

vi /etc/nginx/nginx.conf

#######################################################################
#
# This is the main Nginx configuration file.  
#
# More information about the configuration options is available on
#   * the English wiki - http://wiki.codemongers.com/Main
#   * the Russian documentation - http://sysoev.ru/nginx/
#
#######################################################################

#----------------------------------------------------------------------
# Main Module - directives that cover basic functionality
#
#   http://wiki.codemongers.com/NginxMainModule
#
#----------------------------------------------------------------------

user              nginx;
worker_processes  20;

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 Module
#
#   http://wiki.codemongers.com/NginxEventsModule
#
#----------------------------------------------------------------------

events {
   worker_connections  10240;
}


#----------------------------------------------------------------------
# HTTP Core Module
#
#   http://wiki.codemongers.com/NginxHttpCoreModule
#
#----------------------------------------------------------------------

http {
   include       /etc/nginx/mime.types;
   default_type  application/octet-stream;

   log_format  main  '$remote_addr - $remote_user [$time_local] $request '
                     '"$status" $body_bytes_sent "$http_referer" '
        &nnbsp;            '"$http_user_agent" "$http_x_forwarded_for"';

   access_log  /var/log/nginx/access.log  main;

   sendfile        on;
   #tcp_nopush     on;

   #keepalive_timeout  0;
   keepalive_timeout  65;

   #gzip  on;
   
   # Load config files from the /etc/nginx/conf.d directory
   include /etc/nginx/conf.d/*.conf;

   #
   # The default server
   #
   server {
       listen       80;
       server_name  _;

       #charset koi8-r;

       #access_log  logs/host.access.log  main;

       location / {
           root   /usr/share/nginx/html;
           index  index.html index.htm index.php;
       }

       error_page  404              /404.html;
       location = /404.html {
           root   /usr/share/nginx/html;
       }

       # redirect server error pages to the static page /50x.html
       #
       error_page   500 502 503 504  /50x.html;
       location = /50x.html {
           root   /usr/share/nginx/html;
       }

       # proxy the PHP scripts to Apache listening on 127.0.0.1:80
       #
       #location ~ \.php$ {
       #    proxy_pass   http://127.0.0.1;
       #}

       # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
       #
       #location ~ \.php$ {
       #    root           html;
       #    fastcgi_pass   127.0.0.1:9000;
       #    fastcgi_index  index.php;
       #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
       #    include        fastcgi_params;
       #}
       
       location ~ \.php$ {
         root 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;
       }
         

       # deny access to .htaccess files, if Apache's document root
       # concurs with nginx's one
       #
       #location ~ /\.ht {
       #    deny  all;
       #}
   }
}

九、查看phpinfo
编写脚本
vi /usr/share/nginx/html/info.php

内容如下:
phpinfo();
?>

十、修改session目录权限
修改/var/lib/php/session的权限和nginx和php_cgi一致

chown -R nginx.nginx /var/lib/php/session
Tags: ,
分页: 1/1 第一页 [1] 最后页 [ 显示模式: 摘要 | 列表 ]