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: ,
点击在新窗口中浏览此图片

  今天配置了环境时,差点没郁闷死。

  先是下了最新的Apache 2.2.4 ,一直默认下去,很快装好啦,一启动,失败cry

一查,“could not bind to address 0.0.0.0:80”,question晕,我什么时候设了0.0.0.0了,我是设的localhost啊cry,再查Apache配置文件http.conf,服务名没错

ServerName localhost:80

再看监听端口,才发现,默认为

Listen 80

有一行解释为Change this to Listen on specific IP addresses as shown below to  prevent Apache from glomming onto all bound IP addresses (0.0.0.0),晕死,以前都是默认为127.0.0.1的,新版既然默认为0.0.0.0啦,赶紧改为

Listen localhost:80

再一重启,OKgrin

  接着去下了最新的php 5.2.2 ,也是一路默认到安装模式,因为php的typic模式会装少很多扩展模块,我就选了custom模式,然后全选安装,然后一路安装也是没任务问题。

  可到了apache重启时就再也起不来啦fear

  一查http.conf,晕,php当成cgi模式配给我了,还将apache, apache2, apache2.2 全配上了,一查线程,果然起了三个,晕,赶紧删掉,最后配为

LoadModule php5_module "D:\PHP\\php5apache2_2.dll"
AddType application/x-httpd-php .php

再一重启,还是不行cry,查系统日志,模块没找到,喔,忘了,将php下的的dll文件和php/ext下的dll文件全拷到windows/system32下,php.ini拷到windows下,再重启,还不行anger,火起,将php.ini里的没用扩展模块先全屏蔽掉,最后只留常用的几个模块

[PHP_CURL]
extension=php_curl.dll
[PHP_EXIF]
extension=php_exif.dll
[PHP_GD2]
extension=php_gd2.dll
[PHP_GETTEXT]
extension=php_gettext.dll
[PHP_MCRYPT]
extension=php_mcrypt.dll
[PHP_MHASH]
extension=php_mhash.dll
[PHP_MYSQL]
extension=php_mysql.dll
[PHP_MYSQLI]
extension=php_mysqli.dll

再重启,哈哈,总算OK啦grin

PS:windows下的php.ini和php目录下的php.ini最好保护一致,发现服务两个都读到一样。

我病拉

[不指定 2006/10/12 23:17 | by birdsky ]
点击在新窗口中浏览此图片                                                                                              

生病时,我总是赖在床上,
那时我就可以躲在梦中忘记疼痛了
生病时,我总是吃不下东西,
除了老妈子熬的白粥及煎鸡蛋以外

现在我生病了
cry
我很难受
可我还要上班
我吃不下东西
因为老妈不在我身边


Tags:
分页: 3/4 第一页 上页 [1] [2] [3] [4] 下页 最后页 [ 显示模式: 摘要 | 列表 ]