安装CentOS 5.4



         为了搭建LAMP环境,首先要安装某个Linux的发行版本,这里选择了CentOS5.4。安装和设置过程中遇到的几个主要问题整理如下:



 



1.   配置LVM(Logical Volume Manager)



         为了有效的区分开发环境和发布环境;方便对网站用户数据的管理,备份和迁移;并要考虑将来磁盘空间扩展的需求;需要合理的划分Linux系统分区。安装时选择了LVM,并用LVM对Linux文件系统做了如下的划分,见下图:






Linux centos7 logrotate 安装与使用 centos安装lvm_desktop



LVM的基本概念整理,参考



http://blog.chinaunix.net/u2/68904/showart_692460.html



http://doc.chinahtml.com/manual/rhl-cg-zh_cn-9/ch-lvm-intro.html



如何增加在逻辑卷中挂接的文件系统的大小,待下一步整理。



 



2.   设置vnc server的步骤和注意事项



         为了远程管理服务器,需要配置vncserver。并在Windows下安装vnc客户端,客户端这里选择TightVNC。客户端安装设置比较简单,不做讨论了。下面主要针对服务器端如何设置的整理。



A.     增加允许远程登录的用户帐号。



该帐号即是Linux的用户帐号,但需要添加到在/etc/sysconfig/vncservers脚本文件中,若新增帐号,从下面的命令开始。



[root@localhost ~]# adduser tom




[root@localhost ~]# passwd tom




Changing password for user tom.




New UNIX password:




Retype new UNIX password:




passwd: all authentication tokens updated successfully.




 



[root@localhost ~]# vi /etc/sysconfig/vncservers




# The VNCSERVERS variable is a list of display:user pairs.




#




# Uncomment the lines below to start a VNC server on display :2




# as my 'myusername' (adjust this to your own).  You will also




# need to set a VNC password; run 'man vncpasswd' to see how




# to do that.




#




# DO NOT RUN THIS SERVICE if your local area network is




# untrusted!  For a secure way of using VNC, see




# <URL:http://www.uk.research.att.com/archive/vnc/sshvnc.html>.







# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.







# Use "-nohttpd" to prevent web-based VNC clients connecting.







# Use "-localhost" to prevent remote VNC clients connecting except when




# doing so through a secure tunnel.  See the "-via" option in the




# `man vncviewer' manual page.







VNCSERVERS="1:root 3:tom"




VNCSERVERARGS[1]="-geometry 800x600"




VNCSERVERARGS[3]="-geometry 800x600 -nolisten tcp -nohttpd"




 



根据需要修改黑体这段内容,格式为”id1:username1 id2:username2”。多个用户填写在VNCSERVERS字段中,并用空格隔开。



根据网上的一些介绍,也可以用多个VNCSERVERS字段分别表示多个用户。例如:



VNCSERVERS="1:root "




VNCSERVERARGS[1]="-geometry 800x600"







VNCSERVERS="3:tom"




VNCSERVERARGS[3]="-geometry 800x600 -nolisten tcp -nohttpd"




但启动vncserver后始终只有最后那个用户有效,原因不明。



 



B.     设置各个用户密码,并启动vncserver



[root@localhost ~]# su - tom




[tom@localhost ~]$ vncserver







You will require a password to access your desktops.







Password:




Verify:




xauth:  creating new authority file /home/tom/.Xauthority







New 'localhost.localdomain:3 (tom)' desktop is localhost.localdomain:3







Creating default startup script /home/tom/.vnc/xstartup




Starting applications specified in /home/tom/.vnc/xstartup




Log file is /home/tom/.vnc/localhost.localdomain:3.log




 



也可以单独设置用户登录密码



[root@localhost ~]# su - tom




[tom@localhost ~]$ vncpasswd




再启动vncserver



 



C.      修改登录的桌面



第一次启动vncserver后会在用户的Home目录下创建.vnc/xstartup脚本文件,若要修改登录之后的桌面,需要编辑该脚本文件:



[tom@localhost ~]$ cd .vnc




[tom@localhost .vnc]$ ls




localhost.localdomain:3.log  localhost.localdomain:3.pid  passwd  xstartup




[tom@localhost .vnc]$ vi xstartup




#!/bin/sh







# Uncomment the following two lines for normal desktop:




# unset SESSION_MANAGER




# exec /etc/X11/xinit/xinitrc







[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup




[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources




xsetroot -solid grey




vncconfig -iconic &




xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &




twm &




去掉黑体这两行的注释即可。否则登录后只能看到xterm的窗口。



 



D.    打开远程登录的防火墙端口



         防火墙端口的值是:5900 + /etc/sysconfig/vncservers中该用户的id,例如要打开tom的远程登录的防火墙端口,其端口号为:5900 + 3 = 5903。



通过下面的界面增加端口号,也可以通过命令行方式。



 



Linux centos7 logrotate 安装与使用 centos安装lvm_linux_02



 



Linux centos7 logrotate 安装与使用 centos安装lvm_linux_03



修改端口号之后需要重启iptables

[root@localhost ~]# service iptables restart 
   

 
    
  
清除防火墙规则:                                       [确定] 
   

 
    
  
把 chains 设置为 ACCEPT 策略:filter                      [确定] 
   

 
    
  
正在卸载 Iiptables 模块:                                [确定] 
   

 
    
  
应用 iptables 防火墙规则:                               [确定] 
   

 
    
  
载入额外 iptables 模块:ip_conntrack_netbios_ns ip_conntrac  [确定] 
   

 
   

 



 



E.      设置完成之后可以重启vncserver



[root@localhost ~]# service vncserver restart 
   

 
    
  
关闭 VNC 服务器:1:root 3:tom                    [确定] 
   

 
    
  
启动 VNC 服务器:1:root  
   

 
    
  
New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1 
   

 
    
  
 
   

 
    
  
Starting applications specified in /root/.vnc/xstartup 
   

 
    
  
Log file is /root/.vnc/localhost.localdomain:1.log 
   

 
    
  
 
   

 
    
  
3:tom  
   

 
    
  
New 'localhost.localdomain:3 (tom)' desktop is localhost.localdomain:3 
   

 
    
  
 
   

 
    
  
Starting applications specified in /home/tom/.vnc/xstartup 
   

 
    
  
Log file is /home/tom/.vnc/localhost.localdomain:3.log 
   

 
    
  



                                                           [确定]




重启之后就可以从Client端连接vncserver了



 



F.      如何监视vncserver的进程和端口



[root@localhost ~]# netstat -antpl|grep Xvnc 
   

 
    
  
tcp        0      0 0.0.0.0:5801                0.0.0.0:*                   LISTEN      24322/Xvnc           
   

 
    
  
tcp        0      0 0.0.0.0:5802                0.0.0.0:*                   LISTEN      24379/Xvnc           
   

 
    
  
tcp        0      0 0.0.0.0:5901                0.0.0.0:*                   LISTEN      24322/Xvnc           
   

 
    
  
tcp        0      0 0.0.0.0:5903                0.0.0.0:*                   LISTEN      24602/Xvnc           
   

 
    
  
tcp        0      0 0.0.0.0:6001                0.0.0.0:*                   LISTEN      24322/Xvnc           
   

 
    
  
tcp        0      0 0.0.0.0:6002                0.0.0.0:*                   LISTEN      24379/Xvnc           
   

 
    
  
tcp        0      0 :::6001                     :::*                        LISTEN      24322/Xvnc           
   

 
    
  
tcp        0      0 :::6002                     :::*                        LISTEN      24379/Xvnc 
   

 
   


 



G.     设置vncserver的参考



http://jackiechen.blog.51cto.com/196075/143170



http://bobpeers.com/linux/vnc.php



http://space.itpub.net/519536/viewspace-607552



http://blog.chinaunix.net/u2/83656/showart_2067438.html



 



 



3.   安装CentOS过程中的其他注意事项

A.     关于时区的设置



因为有服务器上同时存在Windows系统,所以在设置时区 去掉UTC选项。



 



B.     关于Selinux的策略

http://www.linuxsky.org/doc/network/200706/59.html

http://book.51cto.com/art/200810/94193.htm


安装过程中先关闭Selinux策略。 Selinux若开启会影响下一步Apache中VirtualHost指定/var/www之外路径的访问。


转载于:https://blog.51cto.com/agile/293895