javaweb开发,vps来做个人测试
首先配置vps(centos)
1.安装javeweb环境
用ssh远程服务器后,中文乱码,因为ssh的字符集和服务器的字符集不一致,服务器是utf-8,可以通过改服务器的/etc/sysconfig/i18n(LANG="zh_CN.GB2312"),但linux服务器一般使用utf-8编码普遍,所以不打算修改服务器编码了,转向设置客户端的字符集,ssh没有找到设置的地方,换了个putty,又没有文件拖动界面,还是terminal(中文正常)上ftp吧。
查看ftp服务和安装
//安装ftp [root@cloud ~]# chkconfig --list [root@cloud ~]# yum -y install vsftpd [root@cloud ~]# chkconfig --level 2345 vsftpd on#设置启动服务 [root@cloud ~]# vi /etc/vsftpd/vsftpd.conf anonymous_enable=NO local_enable=YES chroot_list_enable=YES #使用户不能离开主目录 ascii_upload_enable=YES ascii_download_enable=YES pam_service_name=vsftpd #PAM将根据/etc/pam.d/vsftpd进行认证 guest_enable=YES guest_username=ftp#指定虚拟用户的宿主用户 user_config_dir=/etc/vsftpd/vuser_conf [root@cloud ~]# touch /etc/vsftpd/chroot_list [root@cloud ~]# echo ftp >> /etc/vsftpd/chroot_list #认证db工具生成虚拟用户验证文件 [root@cloud ~]# yum install db4 db4-utils [root@cloud ~]# touch /etc/vsftpd/vuser_passwd.txt#创建密码文本 [root@cloud ~]# vi /etc/vsftpd/vuser_passwd.txt [root@cloud ~]# db_load -T -t hash -f /etc/vsftpd/vuser_passwd.txt /etc/vsftpd/vuser_passwd.db [root@cloud ~]# vi /etc/pam.d/vsftpd#注释所有,添加下面两行 auth required pam_userdb.so db=/etc/vsftpd/vuser_passwd account required pam_userdb.so db=/etc/vsftpd/vuser_passwd #创建虚拟用户FTP服务文件 mkdir /etc/vsftpd/vuser_conf/ vi /etc/vsftpd/vuser_conf/biiluftp #上面vuser_passwd.txt中创建虚拟用户 local_root=/etc/vsftpd/biiluftp write_enable=YES anon_umask=022 anon_world_readable_only=NO anon_upload_enable=YES anon_mkdir_write_enable=YES anon_other_write_enable=YES #创建虚拟用户目录 [root@cloud ~]# mkdir /etc/vsftpd/biiluftp [root@cloud ~]# chmod 777 /etc/vsftpd/biiluftp [root@cloud ~]# service vsftpd restart
ftp服务器时连接失败ftp:connect:Connection refused:(防火墙添加21端口)
[root@cloud ~]# vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT [root@cloud ~]# service iptables restart
ssh上传文件
ftp> lcd #查看本地目录 ftp> put Downloads/jdk-6u7-linux-i586.bin local: Downloads/jdk-6u7-linux-i586.bin remote: Downloads/jdk-6u7-linux-i586.bin 229 Entering Extended Passive Mode (|||26410|). ftp: Can't connect to `103.243.25.191': Connection refused 200 PORT command successful. Consider using PASV. 553 Could not create file.
ftp> epsv4 off
[root@cloud ~]# getsebool -a |grep ftpd
[root@cloud ~]# setsebool allow_ftpd_full_access on
[root@cloud ~]# setsebool ftp_home_dir on
[root@cloud ~]# service vsftpd restart
ok.
ftp上传
ftp> lcd Downloads
ftp> bin #binary模式,不然会报The download file appears to be corrupted.错误
ftp> put jdk-6u7-linux-i586.bin
[root@cloud ~]# cd /etc/vsftpd/biiluftp
[root@cloud biiluftp]# cp -rf jdk-6u7-linux-i586.bin /usr/
jdk安装
[root@cloud usr]# rpm -qa|grep java#卸载已经安装的JAVA
[root@cloud usr]# yum -y remove sun-javadb-common-10.6.2-1.1.i386
[root@cloud usr]# chmod 755 jdk-6u7-linux-i586.bin
[root@cloud usr]# ./jdk-6u7-linux-i586.bin
环境变量
[root@cloud jdk1.6.0_45]# vi /etc/profile
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
export JAVA_HOME=/usr/java/jdk1.6.0_45
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
[root@cloud jdk1.6.0_45]# source /etc/profile
[root@cloud jdk1.6.0_45]# java -version
tomcat安装
[root@cloud usr]# tar -zxvf apache-tomcat-6.0.39.tar.gz -C /usr/local
[root@cloud usr]# vi /usr/local/apache-tomcat-6.0.39/bin/catalina.sh
把web.xml中8080端口改成80后,访问不成功,我靠,还要在防火墙中加80,访问Ok.
2.mysql安装
[root@cloud etc]#yum -y install mysql-server
[root@cloud etc]#chkconfig mysqld on
[root@cloud etc]# service mysqld start #报错
[root@cloud etc]# tail -n 20 /var/log/mysqld.log #Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
[root@cloud etc]# mysql_install_db
[root@cloud etc]# /etc/init.d/mysqld restart
停止 mysqld: [确定]
正在启动 mysqld: [确定]
[root@cloud etc]# mysql -u root
mysql>update mysql.user set host='%' where user='root'; #host is not allowed to connect to this mysql
[root@cloud etc]# /etc/init.d/mysqld restart