Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1596929
  • 博文数量: 409
  • 博客积分: 6240
  • 博客等级: 准将
  • 技术积分: 4908
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-01 00:04
文章分类

全部博文(409)

文章存档

2021年(1)

2019年(1)

2017年(1)

2016年(13)

2015年(22)

2013年(4)

2012年(240)

2011年(127)

分类: 系统运维

2015-07-21 13:01:12

目的:
安装jdk、tomcat,发布java工程。
流程:
1.安装jdk;
2.配置/etc/profile中java环境变量
3.下载安装tomcat
4.搭建vsftp,可以上传文件
过程:
1.安装jdk
安装jdk有多种方法,可以去oracle官网下载,也可以利用yum直接安装,由于下载比较慢,我就用yum安装了。

  1. [root@web1 ~]# cat /etc/redhat-release
  2. CentOS release 6.6 (Final)
  3. [root@web1 ~]# file /sbin/init
  4. /sbin/init: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
  5. [root@web1 ~]#
  6. [root@web1 ftppath]# yum -y list java*
  7. Loaded plugins: fastestmirror, refresh-packagekit, security
  8. Loading mirror speeds from cached hostfile
  9. Installed Packages
  10. java-1.6.0-openjdk.x86_64 1:1.6.0.0-11.1.13.4.el6 @anaconda-CentOS-201410241409.x86_64/6.6
  11. java-1.7.0-openjdk.x86_64 1:1.7.0.65-2.5.1.2.el6_5 @anaconda-CentOS-201410241409.x86_64/6.6
  12. Available Packages
  13. java-1.5.0-gcj.x86_64 1.5.0.0-29.1.el6 centos-source-http
  14. java-1.5.0-gcj-devel.x86_64 1.5.0.0-29.1.el6 centos-source-http
  15. java-1.5.0-gcj-javadoc.x86_64 1.5.0.0-29.1.el6 centos-source-http
  16. java-1.5.0-gcj-src.x86_64 1.5.0.0-29.1.el6 centos-source-http
  17. java-1.6.0-openjdk-demo.x86_64 1:1.6.0.0-11.1.13.4.el6 centos-source-http
  18. java-1.6.0-openjdk-devel.x86_64 1:1.6.0.0-11.1.13.4.el6 centos-source-http
  19. java-1.6.0-openjdk-javadoc.x86_64 1:1.6.0.0-11.1.13.4.el6 centos-source-http
  20. java-1.6.0-openjdk-src.x86_64 1:1.6.0.0-11.1.13.4.el6 centos-source-http
  21. java-1.7.0-openjdk-demo.x86_64 1:1.7.0.65-2.5.1.2.el6_5 centos-source-http
  22. java-1.7.0-openjdk-devel.x86_64 1:1.7.0.65-2.5.1.2.el6_5 centos-source-http
  23. java-1.7.0-openjdk-javadoc.noarch 1:1.7.0.65-2.5.1.2.el6_5 centos-source-http
  24. java-1.7.0-openjdk-src.x86_64 1:1.7.0.65-2.5.1.2.el6_5 centos-source-http
  25. java-1.8.0-openjdk.x86_64 1.8.0.20-3.b26.el6 centos-source-http
  26. java-1.8.0-openjdk-demo.x86_64 1.8.0.20-3.b26.el6 centos-source-http
  27. java-1.8.0-openjdk-devel.x86_64 1.8.0.20-3.b26.el6 centos-source-http
  28. java-1.8.0-openjdk-headless.x86_64 1.8.0.20-3.b26.el6 centos-source-http
  29. java-1.8.0-openjdk-javadoc.noarch 1.8.0.20-3.b26.el6 centos-source-http
  30. java-1.8.0-openjdk-src.x86_64 1.8.0.20-3.b26.el6 centos-source-http
  31. java_cup.x86_64 1:0.10k-5.el6 centos-source-http
  32. java_cup-javadoc.x86_64 1:0.10k-5.el6 centos-source-http
  33. java_cup-manual.x86_64 1:0.10k-5.el6 centos-source-http
  34. javacc.x86_64 4.1-0.5.el6 centos-source-http
  35. javacc-demo.x86_64 4.1-0.5.el6 centos-source-http
  36. javacc-manual.x86_64 4.1-0.5.el6 centos-source-http
  37. javassist.noarch 3.9.0-6.el6 centos-source-http
  38. javassist-javadoc.noarch 3.9.0-6.el6 centos-source-http
  39. [root@web1 ftppath]#


  40. [root@web1 ftppath]# yum -y install java-1.8.0-openjdk*
  41. Loaded plugins: fastestmirror, refresh-packagekit, security
  42. Setting up Install Process
  43. Loading mirror speeds from cached hostfile
  44. Resolving Dependencies
  45. --> Running transaction check
  46. ---> Package java-1.8.0-openjdk.x86_64 0:1.8.0.20-3.b26.el6 will be installed
  47. ---> Package java-1.8.0-openjdk-demo.x86_64 0:1.8.0.20-3.b26.el6 will be installed
  48. ---> Package java-1.8.0-openjdk-devel.x86_64 0:1.8.0.20-3.b26.el6 will be installed
  49. ---> Package java-1.8.0-openjdk-headless.x86_64 0:1.8.0.20-3.b26.el6 will be installed
  50. ---> Package java-1.8.0-openjdk-javadoc.noarch 0:1.8.0.20-3.b26.el6 will be installed
  51. ---> Package java-1.8.0-openjdk-src.x86_64 0:1.8.0.20-3.b26.el6 will be installed
  52. --> Finished Dependency Resolution

  53. Dependencies Resolved

  54. ================================================================================
  55.  Package Arch Version Repository Size
  56. ================================================================================
  57. Installing:
  58.  java-1.8.0-openjdk x86_64 1.8.0.20-3.b26.el6 centos-source-http 186 k
  59.  java-1.8.0-openjdk-demo x86_64 1.8.0.20-3.b26.el6 centos-source-http 1.9 M
  60.  java-1.8.0-openjdk-devel x86_64 1.8.0.20-3.b26.el6 centos-source-http 9.5 M
  61.  java-1.8.0-openjdk-headless x86_64 1.8.0.20-3.b26.el6 centos-source-http 29 M
  62.  java-1.8.0-openjdk-javadoc noarch 1.8.0.20-3.b26.el6 centos-source-http 17 M
  63.  java-1.8.0-openjdk-src x86_64 1.8.0.20-3.b26.el6 centos-source-http 45 M

  64. Transaction Summary
  65. ================================================================================
  66. Install 6 Package(s)

  67. Total download size: 103 M
  68. Installed size: 450 M
  69. Downloading Packages:
  70. (1/6): java-1.8.0-openjdk-devel-1.8.0.20-3.b26.el6.x86_6 | 9.5 MB 00:00
  71. (2/6): java-1.8.0-openjdk-headless-1.8.0.20-3.b26.el6.x8 | 29 MB 00:00
  72. (3/6): java-1.8.0-openjdk-javadoc-1.8.0.20-3.b26.el6.noa | 17 MB 00:00
  73. (4/6): java-1.8.0-openjdk-demo-1.8.0.20-3.b26.el6.x86_64 | 1.9 MB 00:00
  74. (5/6): java-1.8.0-openjdk-1.8.0.20-3.b26.el6.x86_64.rpm | 186 kB 00:00
  75. (6/6): java-1.8.0-openjdk-src-1.8.0.20-3.b26.el6.x86_64. | 45 MB 00:01
  76. --------------------------------------------------------------------------------
  77. Total 35 MB/s | 103 MB 00:02
  78. Running rpm_check_debug
  79. Running Transaction Test
  80. Transaction Test Succeeded
  81. Running Transaction
  82.   Installing : java-1.8.0-openjdk-headless-1.8.0.20-3.b26.el6.x86_64 1/6
  83.   Installing : java-1.8.0-openjdk-1.8.0.20-3.b26.el6.x86_64 2/6
  84.   Installing : java-1.8.0-openjdk-devel-1.8.0.20-3.b26.el6.x86_64 3/6
  85.   Installing : java-1.8.0-openjdk-demo-1.8.0.20-3.b26.el6.x86_64 4/6
  86.   Installing : java-1.8.0-openjdk-src-1.8.0.20-3.b26.el6.x86_64 5/6
  87.   Installing : java-1.8.0-openjdk-javadoc-1.8.0.20-3.b26.el6.noarch 6/6
  88.   Verifying : java-1.8.0-openjdk-devel-1.8.0.20-3.b26.el6.x86_64 1/6
  89.   Verifying : java-1.8.0-openjdk-headless-1.8.0.20-3.b26.el6.x86_64 2/6
  90.   Verifying : java-1.8.0-openjdk-javadoc-1.8.0.20-3.b26.el6.noarch 3/6
  91.   Verifying : java-1.8.0-openjdk-demo-1.8.0.20-3.b26.el6.x86_64 4/6
  92.   Verifying : java-1.8.0-openjdk-1.8.0.20-3.b26.el6.x86_64 5/6
  93.   Verifying : java-1.8.0-openjdk-src-1.8.0.20-3.b26.el6.x86_64 6/6

  94. Installed:
  95.   java-1.8.0-openjdk.x86_64 0:1.8.0.20-3.b26.el6
  96.   java-1.8.0-openjdk-demo.x86_64 0:1.8.0.20-3.b26.el6
  97.   java-1.8.0-openjdk-devel.x86_64 0:1.8.0.20-3.b26.el6
  98.   java-1.8.0-openjdk-headless.x86_64 0:1.8.0.20-3.b26.el6
  99.   java-1.8.0-openjdk-javadoc.noarch 0:1.8.0.20-3.b26.el6
  100.   java-1.8.0-openjdk-src.x86_64 0:1.8.0.20-3.b26.el6


  101. [root@web1 ftppath]#
  102. 测试成功
  103. [root@web1 ftppath]# java -version
  104. java version "1.7.0_65"
  105. OpenJDK Runtime Environment (rhel-2.5.1.2.el6_5-x86_64 u65-b17)
  106. OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)
  107. [root@web1 ftppath]# echo $PATH
  108. /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
  109. [root@web1 ftppath]# ll /usr/lib
  110. lib/ lib64/ libexec/
  111. [root@web1 ftppath]# ll /usr/lib/jvm
  112. jvm/ jvm-commmon/ jvm-exports/ jvm-private/
  113. [root@web1 ftppath]# ll /usr/lib/jvm
  114. total 12
  115. lrwxrwxrwx. 1 root root 26 Jul 21 12:13 java -> /etc/alternatives/java_sdk
  116. drwxr-xr-x. 3 root root 4096 Jul 20 15:09 java-1.6.0-openjdk-1.6.0.0.x86_64
  117. drwxr-xr-x. 3 root root 4096 Jul 20 14:56 java-1.7.0-openjdk-1.7.0.65.x86_64
  118. lrwxrwxrwx. 1 root root 32 Jul 21 12:13 java-1.8.0 -> /etc/alternatives/java_sdk_1.8.0
  119. lrwxrwxrwx. 1 root root 40 Jul 21 12:13 java-1.8.0-openjdk -> /etc/alternatives/java_sdk_1.8.0_openjdk
  120. drwxr-xr-x. 9 root root 4096 Jul 21 12:14 java-1.8.0-openjdk-1.8.0.20-3.b26.el6.x86_64
  121. lrwxrwxrwx. 1 root root 34 Jul 21 12:13 java-openjdk -> /etc/alternatives/java_sdk_openjdk
  122. lrwxrwxrwx. 1 root root 21 Jul 21 12:13 jre -> /etc/alternatives/jre
  123. lrwxrwxrwx. 1 root root 27 Jul 20 15:09 jre-1.6.0 -> /etc/alternatives/jre_1.6.0
  124. lrwxrwxrwx. 1 root root 37 Jul 20 15:09 jre-1.6.0-openjdk.x86_64 -> java-1.6.0-openjdk-1.6.0.0.x86_64/jre
  125. lrwxrwxrwx. 1 root root 27 Jul 20 14:56 jre-1.7.0 -> /etc/alternatives/jre_1.7.0
  126. lrwxrwxrwx. 1 root root 38 Jul 20 14:56 jre-1.7.0-openjdk.x86_64 -> java-1.7.0-openjdk-1.7.0.65.x86_64/jre
  127. lrwxrwxrwx. 1 root root 27 Jul 21 12:13 jre-1.8.0 -> /etc/alternatives/jre_1.8.0
  128. lrwxrwxrwx. 1 root root 35 Jul 21 12:13 jre-1.8.0-openjdk -> /etc/alternatives/jre_1.8.0_openjdk
  129. lrwxrwxrwx. 1 root root 48 Jul 21 12:13 jre-1.8.0-openjdk-1.8.0.20-3.b26.el6.x86_64 -> java-1.8.0-openjdk-1.8.0.20-3.b26.el6.x86_64/jre
  130. lrwxrwxrwx. 1 root root 29 Jul 21 12:13 jre-openjdk -> /etc/alternatives/jre_openjdk
  131. [root@web1 ftppath]#

  132. http://blog.chinaunix.net/uid-15463753-id-4252690.html
  133. 默认情况下jdk安装得路径/usr/lib/jvm
  134. 这个机器可能同时安装好几个版本得jdk
  135. [root@web1 bin]# cd /usr/lib/jvm
  136. [root@web1 jvm]# ls
  137. java
  138. java-1.6.0-openjdk-1.6.0.0.x86_64
  139. java-1.7.0-openjdk-1.7.0.65.x86_64
  140. java-1.8.0
  141. java-1.8.0-openjdk
  142. java-1.8.0-openjdk-1.8.0.20-3.b26.el6.x86_64
  143. java-openjdk
  144. jre
  145. jre-1.6.0
  146. jre-1.6.0-openjdk.x86_64
  147. jre-1.7.0
  148. jre-1.7.0-openjdk.x86_64
  149. jre-1.8.0
  150. jre-1.8.0-openjdk
  151. jre-1.8.0-openjdk-1.8.0.20-3.b26.el6.x86_64
  152. jre-openjdk
  153. [root@web1 jvm]#
2.配置java环境变量,并测试变量生效通过:

  1. [root@web1 java-1.8.0-openjdk]# vim /etc/profile
  2. [root@web1 java-1.8.0-openjdk]# cat /etc/profile
  3. # /etc/profile

  4. # System wide environment and startup programs, for login setup
  5. # Functions and aliases go in /etc/bashrc

  6. # It's NOT a good idea to change this file unless you know what you
  7. # are doing. It's much better to create a custom.sh shell script in
  8. # /etc/profile.d/ to make custom changes to your environment, as this
  9. # will prevent the need for merging in future updates.

  10. pathmunge () {
  11.     case ":${PATH}:" in
  12.         *:"$1":*)
  13.             ;;
  14.         *)
  15.             if [ "$2" = "after" ] ; then
  16.                 PATH=$PATH:$1
  17.             else
  18.                 PATH=$1:$PATH
  19.             fi
  20.     esac
  21. }


  22. if [ -x /usr/bin/id ]; then
  23.     if [ -z "$EUID" ]; then
  24.         # ksh workaround
  25.         EUID=`id -u`
  26.         UID=`id -ru`
  27.     fi
  28.     USER="`id -un`"
  29.     LOGNAME=$USER
  30.     MAIL="/var/spool/mail/$USER"
  31. fi

  32. # Path manipulation
  33. if [ "$EUID" = "0" ]; then
  34.     pathmunge /sbin
  35.     pathmunge /usr/sbin
  36.     pathmunge /usr/local/sbin
  37. else
  38.     pathmunge /usr/local/sbin after
  39.     pathmunge /usr/sbin after
  40.     pathmunge /sbin after
  41. fi

  42. HOSTNAME=`/bin/hostname 2>/dev/null`
  43. HISTSIZE=1000
  44. if [ "$HISTCONTROL" = "ignorespace" ] ; then
  45.     export HISTCONTROL=ignoreboth
  46. else
  47.     export HISTCONTROL=ignoredups
  48. fi

  49. export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

  50. # By default, we want umask to get set. This sets it for login shell
  51. # Current threshold for system reserved uid/gids is 200
  52. # You could check uidgid reservation validity in
  53. # /usr/share/doc/setup-*/uidgid file
  54. if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
  55.     umask 002
  56. else
  57.     umask 022
  58. fi

  59. for i in /etc/profile.d/*.sh ; do
  60.     if [ -r "$i" ]; then
  61.         if [ "${-#*i}" != "$-" ]; then
  62.             . "$i"
  63.         else
  64.             . "$i" >/dev/null 2>&1
  65.         fi
  66.     fi
  67. done

  68. unset i
  69. unset -f pathmunge
  70. ###y#k##
  71. JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
  72. JAVA_BIN=$JAVA_HOME/bin
  73. PATH=$PATH:$JAVA_BIN
  74. CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
  75. export JAVA_HOME JAVA_BIN PATH CLASSPATH
  76. [root@web1 java-1.8.0-openjdk]# ls
  77. bin demo include jre lib sample src.zip tapset
  78. [root@web1 java-1.8.0-openjdk]# source /etc/profile
  79. [root@web1 java-1.8.0-openjdk]# echo $JAVA_HOME
  80. /usr/lib/jvm/java-1.8.0-openjdk
  81. [root@web1 java-1.8.0-openjdk]# echo $JAVA_BIN
  82. /usr/lib/jvm/java-1.8.0-openjdk/bin
  83. [root@web1 java-1.8.0-openjdk]# cd $JAVA_BIN
  84. [root@web1 bin]# pwd
  85. /usr/lib/jvm/java-1.8.0-openjdk/bin
  86. [root@web1 bin]# file $JAVA_HOME/lib/dt.jar
  87. /usr/lib/jvm/java-1.8.0-openjdk/lib/dt.jar: Zip archive data, at least v2.0 to extract
  88. [root@web1 bin]# file $JAVA_HOME/lib/tools.jar
  89. /usr/lib/jvm/java-1.8.0-openjdk/lib/tools.jar: Zip archive data, at least v1.0 to extract
  90. [root@web1 bin]#
3.下载安装tomcat
去这里下载,很好找的:,然后传上来,解压、赋予启动脚本x权限、在catalina.sh增加CATALINA_HOME=/opt/apache-tomcat-6.0.30/。

  1. root@web1 opt]# cd ./apache-tomcat-8.0.24
  2. [root@web1 apache-tomcat-8.0.24]# ls
  3. bin lib logs RELEASE-NOTES temp work
  4. conf LICENSE NOTICE RUNNING.txt webapps
  5. [root@web1 apache-tomcat-8.0.24]# cd bin/
  6. [root@web1 bin]# ls
  7. bootstrap.jar daemon.sh startup.sh
  8. catalina.bat digest.bat tomcat-juli.jar
  9. catalina.sh digest.sh tomcat-native.tar.gz
  10. catalina-tasks.xml setclasspath.bat tool-wrapper.bat
  11. commons-daemon.jar setclasspath.sh tool-wrapper.sh
  12. commons-daemon-native.tar.gz shutdown.bat version.bat
  13. configtest.bat shutdown.sh version.sh
  14. configtest.sh startup.bat
  15. [root@master bin]#vim catalina.sh
  16. 添加:
  17. CATALINA_HOME=/opt/apache-tomcat-6.0.30/
  18. [root@web1 bin]# ll
  19. total 788
  20. -rw-r--r--. 1 root root 28386 Jul 1 21:21 bootstrap.jar
  21. -rw-r--r--. 1 root root 13825 Jul 1 21:21 catalina.bat
  22. -rw-r--r--. 1 root root 21492 Jul 1 21:21 catalina.sh
  23. -rw-r--r--. 1 root root 1686 Jul 1 21:21 catalina-tasks.xml
  24. -rw-r--r--. 1 root root 24283 Jul 1 21:21 commons-daemon.jar
  25. -rw-r--r--. 1 root root 204944 Jul 1 21:21 commons-daemon-native.tar.gz
  26. -rw-r--r--. 1 root root 2040 Jul 1 21:21 configtest.bat
  27. -rw-r--r--. 1 root root 1922 Jul 1 21:21 configtest.sh
  28. -rw-r--r--. 1 root root 7888 Jul 1 21:21 daemon.sh
  29. -rw-r--r--. 1 root root 2091 Jul 1 21:21 digest.bat
  30. -rw-r--r--. 1 root root 1965 Jul 1 21:21 digest.sh
  31. -rw-r--r--. 1 root root 3430 Jul 1 21:21 setclasspath.bat
  32. -rw-r--r--. 1 root root 3547 Jul 1 21:21 setclasspath.sh
  33. -rw-r--r--. 1 root root 2020 Jul 1 21:21 shutdown.bat
  34. -rw-r--r--. 1 root root 1902 Jul 1 21:21 shutdown.sh
  35. -rw-r--r--. 1 root root 2022 Jul 1 21:21 startup.bat
  36. -rw-r--r--. 1 root root 1904 Jul 1 21:21 startup.sh
  37. -rw-r--r--. 1 root root 40824 Jul 1 21:21 tomcat-juli.jar
  38. -rw-r--r--. 1 root root 388787 Jul 1 21:21 tomcat-native.tar.gz
  39. -rw-r--r--. 1 root root 4057 Jul 1 21:21 tool-wrapper.bat
  40. -rw-r--r--. 1 root root 5061 Jul 1 21:21 tool-wrapper.sh
  41. -rw-r--r--. 1 root root 2026 Jul 1 21:21 version.bat
  42. -rw-r--r--. 1 root root 1908 Jul 1 21:21 version.sh
  43. [root@web1 bin]# chmod +x s*
  44. [root@web1 bin]# chmod +x ./s*
  45. [root@web1 bin]# ./startup.sh
  46. Cannot find ./catalina.sh
  47. The file is absent or does not have execute permission
  48. This file is needed to run this program
  49. [root@web1 bin]# chmod +x ./ca*
  50. [root@web1 bin]# ./startup.sh
  51. Using CATALINA_BASE: /opt/apache-tomcat-8.0.24
  52. Using CATALINA_HOME: /opt/apache-tomcat-8.0.24
  53. Using CATALINA_TMPDIR: /opt/apache-tomcat-8.0.24/temp
  54. Using JRE_HOME: /usr/lib/jvm/java-1.8.0-openjdk
  55. Using CLASSPATH: /opt/apache-tomcat-8.0.24/bin/bootstrap.jar:/opt/apache-tomcat-8.0.24/bin/tomcat-juli.jar
  56. Tomcat started.
  57. [root@web1 bin]#
  58. 修改tomcat的监听端口
  59. [root@master ~]# cd /opt/apache-tomcat-6.0.30/conf
  60. [root@master ~]# vim server.xml

  61. <Server port="8005" shutdown="SHUTDOWN">【停止tomcat时的端口】
  62.  <Connector port="8081" protocol="HTTP/1.1"
  63.                connectionTimeout="20000"
  64.                redirectPort="8443" /> 【tomcat默认的监听端口是8080,现在改成8081】

  65.  <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />【apache+tomcat模式时访问tomcat的端口】

  66. 现在重启tomcat
4.搭建vsftpd

  1. [root@web1 ~]# cat /etc/redhat-release
  2. CentOS release 6.6 (Final)
  3. [root@web1 ~]# file /sbin/init
  4. /sbin/init: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
  5. [root@web1 ~]# rmp -qa |grep vsftpd
  6. -bash: rmp: command not found
  7. [root@web1 ~]# rpm -qa |grep vsftpd
  8. [root@web1 ~]# yum -y install vsftpd
  9. Loaded plugins: fastestmirror, refresh-packagekit, security
  10. Setting up Install Process
  11. Loading mirror speeds from cached hostfile
  12. centos-source-http | 4.0 kB 00:00
  13. Resolving Dependencies
  14. --> Running transaction check
  15. ---> Package vsftpd.x86_64 0:2.2.2-12.el6_5.1 will be installed
  16. --> Finished Dependency Resolution

  17. Dependencies Resolved

  18. ================================================================================
  19.  Package Arch Version Repository Size
  20. ================================================================================
  21. Installing:
  22.  vsftpd x86_64 2.2.2-12.el6_5.1 centos-source-http 151 k

  23. Transaction Summary
  24. ================================================================================
  25. Install 1 Package(s)

  26. Total download size: 151 k
  27. Installed size: 331 k
  28. Downloading Packages:
  29. vsftpd-2.2.2-12.el6_5.1.x86_64.rpm | 151 kB 00:00
  30. warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
  31. Retrieving key from http://192.168.54.37/centos/6.6/os/x86_64/RPM-GPG-KEY-CentOS-6
  32. Importing GPG key 0xC105B9DE:
  33.  Userid: "CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>"
  34.  From : http://192.168.54.37/centos/6.6/os/x86_64/RPM-GPG-KEY-CentOS-6
  35. Running rpm_check_debug
  36. Running Transaction Test
  37. Transaction Test Succeeded
  38. Running Transaction
  39.   Installing : vsftpd-2.2.2-12.el6_5.1.x86_64 1/1
  40.   Verifying : vsftpd-2.2.2-12.el6_5.1.x86_64 1/1

  41. Installed:
  42.   vsftpd.x86_64 0:2.2.2-12.el6_5.1


  43. [root@web1 ~]# vim /etc/vsftpd/
  44. ftpusers vsftpd.conf
  45. user_list vsftpd_conf_migrate.sh
  46. [root@web1 ~]# vim /etc/vsftpd/vsftpd.conf
  47. [root@web1 ~]# cd /etc/vsftpd/
  48. [root@web1 vsftpd]# ll
  49. total 20
  50. -rw-------. 1 root root 125 Aug 4 2014 ftpusers
  51. -rw-------. 1 root root 361 Aug 4 2014 user_list
  52. -rw-------. 1 root root 4596 Jul 21 11:06 vsftpd.conf
  53. -rwxr--r--. 1 root root 338 Aug 4 2014 vsftpd_conf_migrate.sh
  54. [root@web1 vsftpd]# vim vsftpd.conf
  55. [root@web1 vsftpd]# vim chroot_list
  56. [root@web1 bin]# grep -v "#" /etc/vsftpd/vsftpd.conf
    anonymous_enable=no
    local_enable=YES
    write_enable=YES
    local_umask=022
    dirmessage_enable=YES
    xferlog_enable=YES
    connect_from_port_20=YES
    xferlog_std_format=YES
    chroot_list_enable=YES
    chroot_list_file=/etc/vsftpd/chroot_list
    listen=YES

    pam_service_name=vsftpd
    userlist_enable=YES
    tcp_wrappers=YES
    local_root=/ftppath/upload
    [root@web1 bin]#
  57. [root@web1 vsftpd]# mkdir ftppath
  58. [root@web1 vsftpd]# mkdir /ftppath
  59. [root@web1 vsftpd]# chown ftpjiance:ftpjiance /ftppath/
  60. chown: invalid user: `ftpjiance:ftpjiance'
  61. [root@web1 vsftpd]# useradd -d /ftppath/ -s /sbin/nologin -g ftp ftpjiance
  62. useradd: warning: the home directory already exists.
  63. Not copying any file from skel directory into it.
  64. [root@web1 vsftpd]# passwd ftpjiance
  65. Changing password for user ftpjiance.
  66. New password:
  67. BAD PASSWORD: it is too short
  68. BAD PASSWORD: is too simple
  69. Retype new password:
  70. passwd: all authentication tokens updated successfully.
  71. [root@web1 vsftpd]# chown ftpjiance:ftpjiance /ftppath/
  72. chown: invalid group: `ftpjiance:ftpjiance'
  73. [root@web1 vsftpd]# chown ftpjiance:ftp /ftppath/
  74. [root@web1 vsftpd]#
  75. [root@web1 vsftpd]# ftp localhost
  76. -bash: ftp: command not found
  77. [root@web1 vsftpd]# f
  78. ---------------------------------------------
  79. Microsoft Windows [版本 6.1.7601]
  80. 版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

  81. C:\Users\yangkai>ftp 132.32.50.197
  82. 连接到 132.32.50.197。
  83. 220 (vsFTPd 2.2.2)
  84. 用户(132.32.50.197:(none)): ftpjiance
  85. 331 Please specify the password.
  86. 密码:
  87. 230 Login successful.
  88. ftp> dir
  89. 200 PORT command successful. Consider using PASV.
  90. 150 Here comes the directory listing.
  91. 226 Transfer done (but failed to open directory).
  92. ftp>
  93. -----------------------------------------------------
  94. C:\Users\yangkai>ftp 132.32.50.197
  95. 连接到 132.32.50.197。
  96. 220 (vsFTPd 2.2.2)
  97. 用户(132.32.50.197:(none)): ftpjiance
  98. 331 Please specify the password.
  99. 密码:
  100. 230 Login successful.
  101. ftp> lcd e:\
  102. 目前的本地目录 E:\
  103. ftp> put test.dmp
  104. 200 PORT command successful. Consider using PASV.
  105. 553 Could not create file.
  106. ftp>

  107. --------------------------------------------------
  108. 另附:553 Could not create file.错误的解决
  109.       在RedHat 5上配置了Vsftpd,一切都是没有问题,用户也可以正常登陆,但是在上传文件的时候总是提示:
  110.       553 Could not create file.的错误,百思不得其解,在网上搜了一下,原来是:
  111.       centos 缺省状态是打开selinux的,在这个状态下,vsftp会出现本地用户无法上传的问题(可能是本地用户的home目录,或者是整个目录),错误信息为:
  112.       553 Could not create file.
  113.       要解决这个问题只要:
  114.       1. setsebool -P ftpd_disable_trans 1
  115.       2. service vsftpd restart
  116.       就可以了。

  117. [root@web1 bin]# cat /etc/selinux/config

    # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    #     enforcing - SELinux security policy is enforced.
    #     permissive - SELinux prints warnings instead of enforcing.
    #     disabled - No SELinux policy is loaded.
    SELINUX=enforcing
    # SELINUXTYPE= can take one of these two values:
    #     targeted - Targeted processes are protected,
    #     mls - Multi Level Security protection.
    SELINUXTYPE=targeted


    [root@web1 bin]#

  118. ---------------------------
  119. 查看SELinux状态:

  120. 1、/usr/sbin/sestatus -v ##如果SELinux status参数为enabled即为开启状态

  121. SELinux status: enabled

  122. 2、getenforce ##也可以用这个命令检查

  123. 关闭SELinux:

  124. 1、临时关闭(不用重启机器):

  125. setenforce 0 ##设置SELinux 成为permissive模式

  126.                               ##setenforce 1 设置SELinux 成为enforcing模式

  127. 2、修改配置文件需要重启机器:

  128. 修改/etc/selinux/config 文件

  129. 将SELINUX=enforcing改为SELINUX=disabled

  130. 重启机器即可
  131. --------------------------------------------------------
完成。










阅读(2139) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~