Blog

  • centos6.2 x64安装vnc

    有的客户想买vps使用vnc,不知道这样做的意义在哪,不过安装一下练练手也可以。这里使用的版本是centos6.2 x64.

    参考:https://www.grumpyland.com/blog/72/tutorial-installing-vnc-for-centos-6-vps/

    ##安装epel包
    rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
    rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
    ##安装桌面
    yum groupinstall -y Desktop Fonts Xfce
    ##安装vnc-server
    yum install -y tigervnc-server

    操作vnc不要用root,创建用户jpuyy

    useradd jpuyy
    passwd jpuyy

    接下来使用jpuyy来操作

    #su -l jpuyy
    $vncpasswd

    输入两次密码之后,在~/.vnc/下有一个文件passwd ,说明创建vnc用户成功。

    接下来ctrl+D,使用root操作

    vi /etc/sysconfig/vncservers

    写入如下内容,意思是第一个用户为jpuyy,分辨率为1024×786

    VNCSERVERS="1:jpuyy"
    VNCSERVERARGS[1]="-geometry 1024x786"

    启动vncserver

    service vncserver start

    可设置开机启动

    /sbin/chkconfig vncserver on

    为了更佳的体验效果,安装firefox,首先安装rpmforge源

    rpm -ivh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
    yum install -y firefox
    yum install -y flash-plugin

    这时,使用vnc客户端,打开ip:5901,密码为执行$vncpasswd时创建的密码。即可使用vnc远程进行管理。

  • 存在的asp文件却提示404

    前段时间有一客户要把之前的asp网站搬家,2003跑IIS,asp企业站有点过时的东西,现在也只有大学的课上还会搞这个吧?

    配好之后打开index.asp却提示404错误。

    搜索后发现IIS已经默认不支持ASP。开启方法:

    IIS-WEB服务扩展 -> Active Server Pages -> 允许

  • rpm命令

    用CentOS也有一段时间了,整理一下rpm命令的用法

    安装.rpm的文件,-i代表–install,-v代表–verbose,-h代表–hash 以#显示安装进度

    rpm -ivh package.rpm

    升级软件包

    rpm -U packupdate.rpm

    查看已经安装的软件

    列出已经安装的全部软件包,查具体包可接 | grep 来筛选,或使用通配符

    rpm -qa

    例如:

    # rpm -qa httpd* 
    httpd-tools-2.2.15-15.el6.centos.1.x86_64
    httpd-2.2.15-15.el6.centos.1.x86_64
    或
    # rpm -qa | grep http
    httpd-tools-2.2.15-15.el6.centos.1.x86_64
    httpd-2.2.15-15.el6.centos.1.x86_64

    找到某文件属于哪个软件包,使用

    rpm -qf filename

    例如:

    rpm -qf /etc/httpd/conf/httpd.conf

    执行结果: httpd-2.2.15-15.el6.centos.1.x86_64

    -qi 查看已经安装的软件包的功能,

    rpm -qi packagename

    -pqi 查看没有安装的.rpm包的详细信息

    [root@localhost ~]# rpm -pqi epel-release-6-8.noarch.rpm 
    Name        : epel-release                 Relocations: (not relocatable)
    Version     : 6                                 Vendor: Fedora Project
    Release     : 8                             Build Date: Mon 05 Nov 2012 11:54:41 AM CST
    Install Date: (not installed)               Build Host: buildvm-05.phx2.fedoraproject.org
    Group       : System Environment/Base       Source RPM: epel-release-6-8.src.rpm
    Size        : 22169                            License: GPLv2
    Signature   : RSA/8, Mon 05 Nov 2012 11:29:49 PM CST, Key ID 3b49df2a0608b895
    Packager    : Fedora Project
    URL         : http://dl.fedoraproject.org/pub/epel/
    Summary     : Extra Packages for Enterprise Linux repository configuration
    Description :
    This package contains the Extra Packages for Enterprise Linux (EPEL) repository
    GPG key as well as configuration for yum and up2date.

    如查看wget的功能说明

    rpm -qi wget

    删除已经安装的软件包

    rpm -e packagename

    查看已经安装好的软件包都包含哪些文件

    rpm -ql iptables

    查看某个 rpm 包包含有哪些文件

    rpm -qlp package.rpm

    对于 yum 源里没有安装在本机的 rpm 包查看要装哪些文件,可以这样查(前提要安装好yum-utils)

    repoquery -q -l --plugins memcached

    参考:http://www.cyberciti.biz/faq/howto-list-find-files-in-rpm-package/

  • ssh登录自动发邮件提醒

    大前提:

    因涉及到发邮件,debian下需安装exim4并可对外发邮件,centos则需安装mailx,sendmail。

    方案1,对所有用户生效,创建文件

    vim /etc/ssh/sshrc

    加入以下内容

    #!/bin/bash
    [email protected]
    mail -s "notification:user $USER login from ${SSH_CLIENT%% *}" $yourmail <<EOT
     the ip information : http://www.123cha.com/ip/?q=${SSH_CLIENT%% *}
     login date: `date +%Y/%m/%d" "%H:%M:%S`
     if this is not you , please contact xxx for help.
    EOT

    方案2,不影响他人,只针对自己的账户

    vim ~/.bashrc

    添加

    echo 'ALERT Shell Access on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" [email protected]
  • PHP message: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted

    今天在用某程序生成html文章的时候,到46%的时候页面空白了。

    首先就是查nginx的日志

    2012/11/18 22:01:02 [error] 11485#0: *66546 FastCGI sent in stderr: “PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in ….

    网上一查,才发现设定的值偏小了,到php.ini查找,466行处

    memory_limit = 128M

    改为256M后,重新生成html,没有问题了。

    昨天刚学了vim的一个技巧:将光标定位在128上,按住ctrl+a,数字变大,这次正好用上了。(数字减小,按ctrl+x)

    另一种方法是修改程序,不建议这样操作。

    具体说明在:http://www.php.net/manual/en/ini.core.php#ini.memory-limit

    要设置不限制,则值为-1

     

  • linux中pkill,kill,killall的用法

    killall也可以跟进程名

    killall – kill processes by name

    killall sends a signal to all processes running any of the specified commands. If no signal name is specified, SIGTERM is sent.

    kill 是要据进程号来杀死进程,加-9强制杀死

    结合ps 或 pgrep

    pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout. All the criteria have to match. For example,

    $ pgrep -u root sshd

    will only list the processes called sshd AND owned by root.

    但是这样只会显示进程号,怎么办? 永远不要忘了man一下

    man pgrep里给出了实例

    我试了一下,如

    ps `pgrep -u www-data` 或者 ps $(pgrep -u www-data) 可以查看到详细的属于www-data用户的进程

    root@debian:~# ps `pgrep -u www-data`
    PID TTY STAT TIME COMMAND
    3128 ? S 0:00 : worker process
    12245 ? S 0:04 php-fpm: pool www
    12246 ? S 0:04 php-fpm: pool www
    12247 ? S 0:05 php-fpm: pool www
    12248 ? S 0:06 php-fpm: pool www
    12249 ? S 0:05 php-fpm: pool www
    12250 ? S 0:05 php-fpm: pool www