一、安装nginx:
1. 安装pcre库,nginx的rewrite模板需用到pcre库:

  1. mkdir -p /works  
  2. cd /works  
  3. wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.20.tar.gz  
  4. tar -zxvf pcre-8.20.tar.gz  
  5. ./configure  
  6. make && make install  
  7. cd ..  

2. 安装nginx:

  1. wget http://nginx.org/download/nginx-1.0.10.tar.gz  
  2. tar -zxvf nginx-1.0.10.tar.gz  
  3. cd nginx-1.0.10  
  4. ./configure  
  5. make && make install  
  6. cd ..  

3. 新建用户和组:

  1. groupadd www  
  2. useradd -r -g www www  

二、安装PHP5
1. 安装依赖包:

  1. libcurl:  
  2. wget http://curl.haxx.se/download/curl-7.23.1.tar.gz  
  3. tar -zxvf curl-7.23.1.tar.gz  
  4. cd curl-7.23.1/  
  5. ./configure  
  6. make && make install  
  7. cd ..  


libxml2:

  1. wget ftp://xmlsoft.org/libxml2/libxml2-2.7.6.tar.gz  
  2. tar -zxvf libxml2-2.7.6.tar.gz  
  3. cd libxml2-2.7.6  
  4. ./configure  
  5. make && make install  
  6. cd ..   

libxslt:

  1. wget ftp://xmlsoft.org/libxml2/libxslt-1.1.24.tar.gz  
  2. tar -zxvf libxslt-1.1.24.tar.gz  
  3. cd libxslt-1.1.24  
  4. ./configure  make && make install  
  5. cd ..   

freetype:

  1. wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.6.tar.gz  
  2. tar -zxvf freetype-2.4.6.tar.gz  
  3. cd freetype-2.4.6  ./configure  
  4. make && make install  
  5. cd ..  

libpng:

  1. wget "http://prdownloads.sourceforge.net/libpng/libpng-1.5.6.tar.gz?download" 
  2. tar -zxvf libpng-1.5.6.tar.gz  
  3. cd libpng-1.5.6  ./configure  
  4. make && make install  
  5. cd ..  

libjpeg:

  1. wget http://ijg.org/files/jpegsrc.v8c.tar.gz  
  2. tar -zxvf jpegsrc.v8c.tar.gz  
  3. cd jpeg-8c/  
  4. ./configure  
  5. make && make install  
  6. cd ..  

2. 安装php5和php-fpm:

  1. wget http://museum.php.net/php5/php-5.2.16.tar.gz  
  2. wget http://php-fpm.org/downloads/php-5.2.16-fpm-0.5.14.diff.gz  
  3. tar -zxvf php-5.2.16.tar.gz   
  4. gunzip php-5.2.16-fpm-0.5.14.diff.gz   
  5. cd php-5.2.16/  
  6. patch -p1 < ../php-5.2.16-fpm-0.5.14.diff  
  7.  
  8. ./configure \  
  9. --with-curl \  
  10. --enable-calendar \  
  11. --with-xsl \  
  12. --with-libxml-dir \  
  13. --enable-ftp \  
  14. --with-gd \  
  15. --with-freetype-dir \  
  16. --with-jpeg-dir \  
  17. --with-png-dir \  
  18. --enable-mbstring \  
  19. --with-zlib \  
  20. --enable-shared \  
  21. --with-mysql \  
  22. --enable-fastcgi \  
  23. --enable-fpm   
  24. ./configure && make && make install  

修改php-fpm的配置文件/usr/local/etc/php-fpm.conf,设置执行php-fpm的用户和组名:
大约在第62行:

  1. Unix user of processes  
  2. <!--<value name="user">nobody</value>-->                              
  3. Unix group of processes  
  4. <!--<value name="group">nobody</value>-->  

修改为:

  1. Unix user of processes  
  2. <value name="user">www</value>                            
  3. Unix group of processes  
  4. <value name="group">www</value> 

启动php-fpm:

  1. /usr/local/sbin/php-fpm start  
  2. lsof -i:9000  
  3. netstat -ant|grep 9000    
  4. #9000为php-fpm的默认端口,可以在/usr/local/etc/php-fpm.conf中修改。  

修改nginx配置文件/usr/local/nginx/conf/nginx.conf,我的nginx配置文件如下:

  1. worker_processes  10;  
  2. events {  
  3.     worker_connections  1024;  
  4. }  
  5. http {  
  6.     include       mime.types;  
  7.     default_type  application/octet-stream;  
  8.     sendfile        on;  
  9.     keepalive_timeout  65;  
  10.     gzip  on;  
  11.     server {  
  12.         listen       80;  
  13.         server_name  ead;  
  14.  root /data/faceshow/www;  
  15.         location / {  
  16.             root   html;  
  17.             index  index.php index.html index.htm;  
  18.         }  
  19.         error_page   500 502 503 504  /50x.html;  
  20.         location = /50x.html {  
  21.             root   html;  
  22.         }  
  23.    
  24.  #此段代码为关键  
  25.         location  ~ \.php$ {  
  26.             fastcgi_pass   127.0.0.1:9000; #对应php-fmp的端口  
  27.             fastcgi_index  index.php;  
  28.             fastcgi_param  SCRIPT_FILENAME  /data/faceshow/www/$fastcgi_script_name;    
  29.          #php文件的物理路径  
  30.             include        fastcgi_params;  
  31.         }  
  32.    
  33.  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$  
  34.      {  
  35.         expires      30d;  
  36.      }  
  37.      location ~ .*\.(js|css)?$  
  38.      {  
  39.         expires      1h;  
  40.      }      
  41.     }  
  42. }  
  43.  

启动nginx:

  1. /usr/local/nginx/bin/nginx   
  2. /usr/local/nginx/bin/nginx -s reload  

三、常见问题:
问题: nginx ./configure时报如下错误

  1. ./configure: error: the HTTP rewrite module requires the PCRE library.  
  2. You can either disable the module by using --without-http_rewrite_module  
  3. option, or install the PCRE library into the system, or build the PCRE library  
  4. statically from the source with nginx by using --with-pcre=<path> option.  

解决:这是由于未PCRE库,请安装PCRE库在运行./configure。也可以使用带--without-http_rewrite_module参数进行./configure,但是这将导致nginx不支持rewrite功能!

四、相关文件下载地址:
libcurl: http://curl.haxx.se/download.html
libxml2: ftp://xmlsoft.org/libxml2/
libxslt: ftp://xmlsoft.org/libxml2/
libpng: http://www.libpng.org/pub/png/libpng.html
libjpeg: http://ijg.org/files/
freetype:http://download.savannah.gnu.org/releases/freetype/
pcre:http://www.pcre.org/

nginx:http://nginx.org/en/download.html
php-fpm:http://php-fpm.org/
php5:http://www.php.net/releases/
MySQL:http://www.mysql.com/downloads/mirror.php?id=404683#mirrors

本日志由 Admin 于 2011-11-29 16:32:12 发表到 Linux/Unix 中,目前已经被浏览 297 次,评论 1 次;

作者添加了以下标签: LinuxUnixNginxPhp

一、安装MYSQL
下载页面:http://www.mysql.com/downloads/mirror.php?id=404683#mirrors
1. 添加用户帐号和安装依赖包

  1. groupadd mysql  
  2. useradd -r -g mysql mysql  
  3. yum install gcc gcc-c++ libtool autoconf automake imake libxml2-devel expat-devel ncurses-devel cmake bison 

2. 下载、解压源码包

  1. mkdir -p /data/temp
  2. cd /data/temp
  3. wget ftp://ftp.fi.muni.cz/pub/mysql/Downloads/MySQL-5.5/mysql-5.5.18.tar.gz  
  4. tar -zxvf mysql-5.5.18.tar.gz  
  5. cd mysql-5.5.18 

3. cmake进行编译

  1. cmake . \  
  2. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \  
  3. -DDEFAULT_CHARSET=utf8 \  
  4. -DEXTRA_CHARSETS=all \  
  5. -DDEFAULT_COLLATION=utf8_general_ci \  
  6. -DMYSQL_USER=mysql  
  7.  
  8. make  
  9. make install   
  10. cd /usr/local/mysql  
  11. chown -R mysql .  
  12. chgrp -R mysql .  
  13. scripts/mysql_install_db --user=mysql  
  14. chown -R root .  
  15. chown -R mysql data  
  16. cp support-files/my-medium.cnf /etc/my.cnf  
  17. bin/mysqld_safe --user=mysql &    
  18. cp support-files/mysql.server /etc/init.d/mysqld  
  19. cd /usr/local/bin  
  20. ln -fs /usr/local/mysql/bin/mysql mysql 

4. 把mysql 添加为系统启动服务

  1. cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld  
  2. cd /etc/rc.d/init.d  
  3. chkconfig --add mysqld         
  4. service mysqld start/stop 

二、安装Apache
下载页面:http://www.apache.org/dist/httpd/
1. 安装apache:

  1. wget http://www.apache.org/dist/httpd/httpd-2.2.21.tar.gz  
  2. tar -zxvf httpd-2.2.21.tar.gz  
  3. cd httpd-2.2.21  
  4. ./configure --enable-modules=so --enable-rewrite  
  5. make && make install 

2. 安装扩展:

  1. cd srclib/apr  
  2. make  
  3. make install  
  4.  
  5. cd ../apr-util/  
  6. ./configure --with-apr=../apr  
  7. make   
  8. make install  

二、安装PHP5
1. 安装依赖包:
libcurl:

  1. wget http://curl.haxx.se/download/curl-7.23.1.tar.gz  
  2. tar -zxvf curl-7.23.1.tar.gz  
  3. cd curl-7.23.1/  
  4. ./configure  
  5. make && make install  
  6. cd .. 

libxml2:

  1. wget ftp://xmlsoft.org/libxml2/libxml2-2.7.6.tar.gz  
  2. tar -zxvf libxml2-2.7.6.tar.gz  
  3. cd libxml2-2.7.6  
  4. ./configure  
  5. make && make install  
  6. cd .. 

libxslt:

  1. wget ftp://xmlsoft.org/libxml2/libxslt-1.1.24.tar.gz  
  2. tar -zxvf libxslt-1.1.24.tar.gz  
  3. cd libxslt-1.1.24  
  4. ./configure  
  5. make && make install  
  6. cd .. 

freetype:

  1. http://download.savannah.gnu.org/releases/freetype/freetype-2.4.6.tar.gz  
  2. tar -zxvf freetype-2.4.6.tar.gz  
  3. cd freetype-2.4.6  
  4. ./configure   
  5. make && make install  
  6. cd .. 

libpng:

  1. wget "http://prdownloads.sourceforge.net/libpng/libpng-1.5.6.tar.gz?download" 
  2. tar -zxvf libpng-1.5.6.tar.gz   
  3. cd libpng-1.5.6  
  4. ./configure   
  5. make && make install  
  6. cd .. 

libjpeg:

  1. wget http://ijg.org/files/jpegsrc.v8c.tar.gz  
  2. tar -zxvf jpegsrc.v8c.tar.gz  
  3. cd jpeg-8c/  
  4. ./configure   
  5. make && make install  
  6. cd .. 

2. 安装PHP:

  1.  
  2. wget http://cn2.php.net/get/php-5.2.17.tar.bz2/from/hk.php.net/mirror  
  3. cat php-5.2.17.tar.bz2 |bunzip2 | tar xvf -   
  4. cd php-5.2.17   
  5. ./configure --with-apxs2=/usr/local/apache2/bin/apxs  \  
  6.  --with-curl \  
  7.  --enable-calendar \  
  8.  --with-xsl \  
  9.  --with-libxml-dir \  
  10.  --enable-ftp \  
  11.  --with-gd \  
  12.  --with-freetype-dir \  
  13.  --with-jpeg-dir \  
  14.  --with-png-dir \  
  15.  --enable-mbstring \  
  16.  --with-zlib \  
  17.  --enable-shared \  
  18.  --with-mysql   
  19. make && make install  
  20. cd ..  

3. 让apache加载php模块:

  1. vim /usr/local/apache2/conf/httpd.conf  
  2. #确保下面三行在httpd.conf配置文件中存在
  3. LoadModule php5_module modules/libphp5.so  
  4. AddType application/x-httpd-php .php  
  5. AddType application/x-httpd-php-source .phps  

4. 启动HTTP服务及测试

  1. /usr/local/apache2/bin/httpd -k restart  
  2. echo "<?php phpinfo(); ?>" > /usr/local/apache2/htdocs/index.php   
  3. #使用浏览器打开URL:http://ip/index.php 


常见错误:
1. 现象:make install时报"dlname not found in /usr/local/apache2/modules/libphp5.la."
    解答:这是由于apache与php的libtool版本不一致引起的。

  1. /usr/local/apache2/build/libtool --version  
  2. ltmain.sh (GNU libtool) 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)  
  3. ./libtool --version  
  4. ltmain.sh (GNU libtool) 1.5.22 (1.1220.2.365 2005/12/18 22:14:06)  

    解决方法:使php安装目录下的libtool与apache的libtool版本一致,再重新安装,操作如下:

  1. cd /data/temp/  
  2. cp /usr/local/apache2/build/libtool .  
  3. make clean  
  4. make install  
  5.  


相关文件下载地址:依赖包下载地址:
libcurl: http://curl.haxx.se/download.html
libxml2: ftp://xmlsoft.org/libxml2/
libxslt: ftp://xmlsoft.org/libxml2/
libpng: http://www.libpng.org/pub/png/libpng.html
libjpeg: http://ijg.org/files/
freetype:http://download.savannah.gnu.org/releases/freetype/

apache:http://www.apache.org/dist/httpd/
PHP:http://www.php.net/downloads.php
MySQL:http://www.mysql.com/downloads/mirror.php?id=404683#mirrors

本日志由 Admin 于 2011-11-28 17:29:19 发表到 Linux/Unix 中,目前已经被浏览 332 次,评论 1 次;

作者添加了以下标签: LinuxApachePhpMySQL

1、 在用"Python setup.py"命令安装PostgreSQL的Python驱动时:

  1. running build_ext   
  2. error: No such file or directory  

解决办法:在文件"setup.cfg"设置"pg_config"未正确的完整路径,如"pg_config=/usr/bin/pg_config"。如果当前系统中不存在"pg_config",请先安装"postgresql-devel-*.*.rpm"包。
2、连接PostgreSQL数据库时报如下错误:

  1. psql: 致命错误:  用户 "***" Ident 认证失败 

  1. psql: FATAL: Ident authentication failed for user “username”, mais pourquoi donc ? 

解决办法:修改"pg_hba.conf"文件中认证方式"METHOD"为"md5"或"trust",具体参考文件中的说明。
3、在用"make"编译软件时提示:

  1. "Makefile", line 88: Missing dependency operator  
  2. "Makefile", line 89: Missing dependency operator  
  3. "Makefile", line 91: Need an operator  
  4. "Makefile", line 92: Need an operator  
  5. "Makefile", line 93: Missing dependency operator  
  6. "Makefile", line 94: Missing dependency operator  
  7. Error expanding embedded variable. 

解决办法:用"gmake"编译就OK了。

本日志由 Admin 于 2011-03-02 18:32:10 发表到 Linux/Unix 中,目前已经被浏览 1121 次,评论 27 次;

作者添加了以下标签: LinuxUnixError

  VNC是Virtual Network Computing(虚拟网络计算机)的缩写。VNC是由AT&T的欧洲研究实验室开发的一款优秀的跨平台远程桌面控制软件,支持Linux,Unix,Windows等操作系统跨平台远程桌面控制。VNC有两部分组成,分别是:服务端(vncserver)和客户端(vncviewer)。下面以Linux(VNC服务端)、Windows(VNC客户端)为平台介绍VNC的安装、配置和使用。

实验环境
VNC服务端:
操作系统:Red Hat Enterprise Linux AS 5
内核版本:2.6.18-8.el5
 CPU构架:i386 SMP
附件软件:Red Hat Enterprise Linux AS 5 DVD安装盘
VNC客户端:
操作系统:Windows Server 2008 Enterprise
 浏览器:Windows Internet Explorer 7

1. 在Linux下安装VNC
将Red Hat Enterprise Linux AS 5 DVD安装盘放入DVD光驱,执行下列命令进行安装:

  1. # mkdir -p /mnt/cdrom  文章来至[爱E族]:http://www.aiezu.com
  2. # mount -t auto /dev/cdrom /mnt/cdrom  
  3. # cd /mnt/cdrom/Server  
  4. # rpm -ivh rpm -ivh vnc-server-4.1.2-9.el5.i386.rpm  
  5. # rpm -ivh vnc-4.1.2-9.el5.i386.rpm 

文章来至[爱E族]:http://www.aiezu.com
2. 配置Linux下的VNC Server
①. VNC的运行机制介绍:
  在配置VNC前,必须了解VNC的运行机制。Linux下的VNC可以同时启动多个vncserver,各个vncserver之间用显示编号(display number)来区分,每个vncserver服务监听3个端口,它们分别是:
5800+显示编号:  VNC的httpd监听端口,如果VNC客户端为IE,Firefox等非vncviewer时必须开放。
5900+显示编号:  VNC服务端与客户端通信的真正端口,必须无条件开放。
6000+显示编号:  X监听端口,可选。
  显示编号、开放的端口分别由/etc/sysconfig/vncservers文件中的VNCSERVERS和VNCSERVERARGS控制。VNCSERVERS的设置方式为“VNCSERVERS="显示编号1:用户名1 …"”,如:VNCSERVERS="1:root 2:aiezu"。VNCSERVERARGS的设置方式为VNCSERVERARGS[显示编号1]="参数一 参数值一 参数二 参数值二  ……",如VNCSERVERARGS[2]="-geometry 800x600 -nohttpd",VNCSERVERARGS的详细参数有:

-geometry桌面分辨率,默认1024x768;
-nohttpd不监听HTTP端口(58xx端口);
-nolisten tcp不监听X端口(60xx端口);
-localhost只允许从本机访问;
-AlwaysShared默认只同时允许一个vncviewer连接,此参数允许同时连多个vncviewer;
-SecurityTypes None登录不需要密码认证VncAuth默认值,要密码认证。

②. 修改/etc/sysconfig/vncserver文件:
  熟悉Linux下VNC的运行机制后,开始正式配置VNC Server。vi /etc/sysconfig/vncserver,添加如下三行:文章来至[爱E族]:http://www.aiezu.com

  1. VNCSERVERS="1:root 3:aiezu" 
  2. VNCSERVERARGS[1]="-geometry 800x600 -nolisten tcp" 
  3. VNCSERVERARGS[3]="-geometry 1024x768 -nolisten tcp" 

本例我们开启两个vncserver,分别是root用户,显示编号为1和用户aiezu,显示编号为3,并且全不开启X监听端口60xx。

③. 设置VNC用户密码:
  接下来设置VNC的密码,此步骤不可跳过,否则VNC Server将无法启动,在Linux Shell下执行下列命令:

  1. # su - aiezu  
  2. # vncpasswd  
  3. Password:  文章来至[爱E族]:http://www.aiezu.com
  4. Verify:  
  5. # su - root  
  6. # vncpasswd  
  7. Password:  
  8. Verify: 
  9. service vncserver start //启动vncserver

运行上面命令后,会在用户根目录($HOME)下的".vnc"文件夹下生成一系列文件。其中passwd为vnc用户密码文件,由vncpasswd生成。其他的都由vnc初次启动时生成,xstartup为VNC客户端连接时启动的脚本。文章来至[爱E族]:http://www.aiezu.com

④. 修改".vnc/xstartup"文件:
  执行到上面步骤后,VNC Server已经能正常运行。但是默认设置下,客户连接时启动的是xterm,我们如果想看到桌面,必须将用户根目录下的".vnc/xstartup"文件中的最后两行注释掉,然后根据你安装的桌面坏境,添加一行"startkde &"或者"gnome-session &"。如下:

  1. #!/bin/sh  
  2.  
  3. # Uncomment the following two lines for normal desktop:  
  4. # unset SESSION_MANAGER  
  5. # exec /etc/X11/xinit/xinitrc  
  6.  文章来至[爱E族]:http://www.aiezu.com
  7. [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup  
  8. [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources  
  9. xsetroot -solid grey  
  10. vncconfig -iconic &  
  11. #xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &  
  12. #twm &  文章来至[爱E族]:http://www.aiezu.com
  13. startkde &  
  14. # gnome-session & 

  配置完各个用户根目录下的".vnc/xstartup"后,执行service vncserver restart 重新启动vncserver使配置生效。
⑤. 配置防火墙:
  如果Linux启用了防火墙,必须允许VNC的相关端口(58xx,59xx,60xx)。具体的端口,请参照第2大步骤的①小步骤的VNC运行机制介绍,本例开启5801,5803,5901,5903端口就可以。在Linux命令提示符下输入"system-config-securitylevel-tui"启动防火墙配置工具,点"Customize",在"Other Port"中输入"5801:tcp 5803:tcp 5901:tcp 5903:tcp",然后点"OK"既可。
文章来至[爱E族]:http://www.aiezu.com
3. VNC客户端配置与连接
①. 在windows下使用IE进行远程控制连接:
  使用浏览器连接时,服务端的VNCSERVERARGS设置必须没有"-nohttpd参数",并且防火墙允许VNC的58xx和59xx端口通过。浏览器必须安装了Java支持插件,Java插件下载地址:http://www.java.com/zh_CN/download/manual.jsp
②. 使用在windows下vncviewer远程控制连接:
  使用vncviewer进行远程控制是最简单方式,服务器只需开启"59xx"端口就可以了。客户端也无需配置,双击vncviewer后,在server文本框中输入vncserver的ip地址和端口即可(本例为:192.168.1.22:5901)。vncviewer绿色版的本地下载地址为:http://www.aiezu.com/soft/vnc-4_1_2-x86_win32_viewer.exe
③. 在Linux下使用vncviewer进行远程控制连接:
  使用vncviewer前必须安装vnc-4.1.2-9.el5.i386.rpm包,vncviewer的用法为:vncviewer host:显示编号。
④. 在windows下使用vncviewer+putty.exe通过ssh安全通道连接:
  打开putty,在左边的"Category"中依次点"Connection"->"SSH"->"Tunnels"。在"Source Port"文本框中输入"5901","Destination"文本框中输入"localhost:5901",点击"Add,添加端口转发。然后在putty左边的"Category"下点"Session",输入服务器的IP地址后,点"Open"按钮,输入密码登陆后,既成功启用了端口转发。接着在本机打开vncviewer输入"127.0.0.1:5901"即可成功连接到远程的5901端口。
⑤. 在Linux下使用vncviewer+ssh安全通道连接:
  与④类似,在linux vnc客户端shell下运行"ssh -L 5901:localhost:5901 vncserverhost"命令,输入用户名密码。即完成通过shh安全通道,将远程的5901端口转发到本机的5901端口。然后在shell下运行"vncviewer 127.0.0.1:1"命令即可以连接到远程的VNC Server。
  上面的五种连接方式中,前面三种方式数据都是未加密的形式在网络中传输的,是极为不安全的方式,建议不要采用。文章来至[爱E族]:http://www.aiezu.com

4. 常见问题
①. 问:为什么成功连接后,没有显示桌面,而只是现实一个Terminal窗口?
①. 答:在未修改用户根目录下的".vnc/xstartup"文件,xstartup的默认设置即是此情况。请按第2大步的第②小步修改xstartup,然后运行"service vncserver restart"重新启动vncserver服务即可。
②. 问:如何查看VNC正在运行的显示编号端口号?
①. 答:在Linux命令提示符下执行"netstat -tlup|grep vnc",即可以查看到端口号,端口号的后两位即显示编号。
③. 问:如何关闭指定的显示编号?文章来至[爱E族]:http://www.aiezu.com
①. 答:vncserver -kill :number 即可以关闭指定的显示编号和对应的端口号。
④. 问:为何我通过浏览器连接VNC 端口时,浏览器显示了一个红叉。
①. 答:那是因为你的浏览器没装Java插件的缘故,下载Java插件安装即可。
⑤. 问:客户端连接时"Connetcion timed out(10060)"是怎么回事?
①. 答:对于客户端连接时出现"Connetcion timed out(10060)"或者"No route to host:connect",请检查防火墙是否开启了58xx,59xx,vncserver是否正常运行,以及/etc/sysconfig/vncserver文件配置是否正确。
⑥. 问:在通过VNC连接的图形界面桌面启动X应用时出现:"Error: Can't open display: :0.0"错误?
①. 答:请使用"echo $DISPLAY"命令查看"DISPLAY"坏境变量是否设置为":显示编号:0",如:":1:0"。如果不是此形式,启动X应用时会出现此错误。此时可以通过"export DISPLAY=:1:0"设置正确的DISPLAY。还有一种可能就是切换了用户启动X应用,当前用户没有权限使用X窗口,这时返回到启用VNC的用户,运行"xhost +"允许其他用户访问此X窗口即可。

本日志由 Admin 于 2010-07-18 15:37:11 发表到 Linux/Unix 中,目前已经被浏览 4437 次,评论 17 次;

作者添加了以下标签: LinuxVncServerService

  linux shell提供了历史命令记录功能,通过对历史命令的调用,我们可以在shell提示符下节约大量的时间和命令输入。
  linux系统Shell历史命令默认保存在用户主目录下的".bash_history"文件中。当然,我们也可以通过修改坏境变量"HISTFILE"来设置Linux Shell历史命令记录文件的路径,如在用户目录下的".bashrc"文件中的添加行"export HISTFILE=~/history/history.file",重新登录bash即生效。要查看Linux shell历史命令,我们可以直接在命令提升符下输入:

  1. # history 

如果只是查看最近的10条历史命令,可以在命令提升符下输入:

  1. # history 10 

  在linux系统的默认配置下,重复的历史命令都会存入".bash_history"文件。如果不希望在输入history命令查看历史命令时,看到连续重复的历史命令,我们可以在".bashrc"中加入下面两行:

  1. export HISTCONTROL=ignoreboth  
  2. shopt -s histappend 

其中第一行的命令的作用为“移除Linux shell命令历史记录中连续重复的文件”,第二行的作用为“shell 退出时,将shell 的历史记录附加到您的记录文件”。

更灵活的Linux Shell历史命令调用方法:

  除了使用history命令查看历史命令外,Linux系统还提供了非常灵活的Shell历史命令调用方法,我们可以在Shell命令提示符或者Shell脚本中使用它们:
  !!    前一条命令;
  !:0    不带参数的前一条命令名;
  !^    前一条命令的第一个参数;
  !:n    前一条命令的第n个参数;
  !$     前一条命令的最后一个参数;
  !*     前一条命令的所有参数,命令名除外;
  !n     第n条命令;
  !-n    倒数第n条命令;
  !str    最近一条以str开头的命令;
  !?str    最近一条包含str的命令;
  ^a^b  将上一条命令名中的a替换为b;
  !:gs/a/b 将上一条命令的所有a替换为b(包含命令名和参数)。

本日志由 Admin 于 2010-07-15 13:58:44 发表到 Linux/Unix 中,目前已经被浏览 3062 次,评论 70 次;

作者添加了以下标签: LinuxShellHistory

101/2