CentOS7 JavaWeb环境搭建(JDK、Tomcat、Mysql、vsftpd)
2018-02-11 20:59
711 查看
JDK的安装
CentOS默认安装了JDK 我们先把他卸载。java -version #查看是否安装JAVA 以及Java版本
rpm -qa|grep java #查看JDK信息(搜索关键字Java)
rpm -e –nodeps [softName] 卸载softName
安装JDK(提前在官网下载gz或者rpm压缩包)
mkdir /usr/java # 在usr目录下创建java文件夹
cd 文件夹 #打开进入文件夹
ls -a #当前文件夹下的文件 包括隐藏文件
拷贝下载好的JDK gz压缩包 到/usr/java下
cp JDK.gz /usr/java #拷贝文件到指定的文件夹
tar -xzvf JDK.gz #解压JDK rpm 格式解压 rpm -ivh JDK.rpm
mv JDK.gz newName #重命名一个文件夹
JDK环境变量
vi /etc/profile #修改环境变量
在export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL下添加
JAVA_HOME=/usr/java/jdk1.8
PATH=$PATH:/$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar
exprort JAVA_HOME PATH CLASSPATH
source /etc/profile #使修改立即生效
Tomcat配置
与上述JDK配置一样 提前在官网下载好压缩包解压放置一个文件内修改/etc/profileCATALINA_BASE=/usr/tomcat/tomcat8
PATH=$CATALINA_BASE/bin:$PATH
export PATH CATALINA_BASE
启动TOMCAT
startup.sh start
访问会发现外网访问不了,需要关闭防火墙
centos 7默认使用firewall作为防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
mysql配置
下载mysql源安装包wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
检查mysql源是否安装成功
yum repolist enabled | grep “mysql.-community.”
安装MySQL
yum install mysql-community-server
启动MySQL服务
systemctl start mysqld
查看MySQL的启动状态
systemctl status mysqld
开机启动
systemctl enable mysqld
systemctl daemon-reload
修改root本地登录密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
grep ‘temporary password’ /var/log/mysqld.log
mysql -uroot -p
ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘MyNewPass4!’;
添加远程登录用户
GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ IDENTIFIED BY ‘password’ WITH GRANT OPTION;
配置默认编码为utf8
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置
character_set_server=utf8
init_connect=’SET NAMES utf8’
vsftpd配置
安装vsftpd及ftp命令yum install vsftpd -y
yum install ftp -y
vsftpd服务器的主要配置文件是/etc/vsftpd/vsftpd.conf
配置vsftpd
不允许匿名访问
anonymous_enable=NO
允许使用本地帐户进行FTP用户登录验证
local_enable=YES
当chroot_list_enable=YES,chroot_local_user=YES时,在/etc/vsftpd.chroot_list文件中列出的用户,可以切换到其他目录;未在文件中列出的用户,不能切换到其他目录。
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
配置文件最后添加
allow_writeable_chroot=YES
pam_service_name=vsftpd
要不然会报错
500 OOPS: vsftpd: refusing to run with writable root inside chroot()
如果/etc/vsftpd/chroot_list不存在,则需要创建该文件
vi /etc/vsftpd/chroot_list
:wq直接保存并退出就行。
设定支持ASCII模式的上传和下载功能。
ascii_upload_enable=YES
ascii_download_enable=YES
取消ipv6的监听
#listen_ipv6=YES
开启listen
listen=YES
:wq保存修改,重启vsftpd
systemctl restart vsftpd.service
新建FTP用户
useradd -d /var/ftp/public_root -g ftp -s /sbin/nologin ftpuser # /var/ftp/public_root指定的目录
修改该FTP用户密码
passwd ftpuser
vsftpd.conf配置文件
# Example config file /etc/vsftpd/vsftpd.conf # # The default compiled in settings are fairly paranoid. This sample file # loosens things up a bit, to make the ftp daemon more usable. # Please see vsftpd.conf.5 for all compiled in defaults. # # READ THIS: This example file is NOT an exhaustive list of vsftpd options. # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's # capabilities. # # Allow anonymous FTP? (Beware - allowed by default if you comment this out). anonymous_enable=NO # # Uncomment this to allow local users to log in. # When SELinux is enforcing check for SE bool ftp_home_dir local_enable=YES # # Uncomment this to enable any form of FTP write command. write_enable=YES # # Default umask for local users is 077. You may wish to change this to 022, # if your users expect that (022 is used by most other ftpd's) local_umask=022 # # Uncomment this to allow the anonymous FTP user to upload files. This only # has an effect if the above global write enable is activated. Also, you will # obviously need to create a directory writable by the FTP user. # When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access #anon_upload_enable=YES # # Uncomment this if you want the anonymous FTP user to be able to create # new directories. #anon_mkdir_write_enable=YES # # Activate directory messages - messages given to remote users when they # go into a certain directory. dirmessage_enable=YES # # Activate logging of uploads/downloads. xferlog_enable=YES # # Make sure PORT transfer connections originate from port 20 (ftp-data). connect_from_port_20=YES # # If you want, you can arrange for uploaded anonymous files to be owned by # a different user. Note! Using "root" for uploaded files is not # recommended! #chown_uploads=YES #chown_username=whoever # # You may override where the log file goes if you like. The default is shown # below. #xferlog_file=/var/log/xferlog # # If you want, you can have your log file in standard ftpd xferlog format. # Note that the default log file location is /var/log/xferlog in this case. xferlog_std_format=YES # # You may change the default value for timing out an idle session. #idle_session_timeout=600 # # You may change the default value for timing out a data connection. #data_connection_timeout=120 # # It is recommended that you define on your system a unique user which the # ftp server can use as a totally isolated and unprivileged user. #nopriv_user=ftpsecure # # Enable this and the server will recognise asynchronous ABOR requests. Not # recommended for security (the code is non-trivial). Not enabling it, # however, may confuse older FTP clients. #async_abor_enable=YES # # By default the server will pretend to allow ASCII mode but in fact ignore # the request. Turn on the below options to have the server actually do ASCII # mangling on files when in ASCII mode. # Beware that on some FTP servers, ASCII support allows a denial of service # attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd # predicted this attack and has always been safe, reporting the size of the # raw file. # ASCII mangling is a horrible feature of the protocol. #ascii_upload_enable=YES #ascii_download_enable=YES # # You may fully customise the login banner string: #ftpd_banner=Welcome to blah FTP service. # # You may specify a file of disallowed anonymous e-mail addresses. Apparently # useful for combatting certain DoS attacks. #deny_email_enable=YES # (default follows) #banned_email_file=/etc/vsftpd/banned_emails # # You may specify an explicit list of local users to chroot() to their home # directory. If chroot_local_user is YES, then this list becomes a list of # users to NOT chroot(). # (Warning! chroot'ing can be very dangerous. If using chroot, make sure that # the user does not have write access to the top level directory within the # chroot) chroot_local_user=YES chroot_list_enable=YES # (default follows) chroot_list_file=/etc/vsftpd/chroot_list # # You may activate the "-R" option to the builtin ls. This is disabled by # default to avoid remote users being able to cause excessive I/O on large # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume # the presence of the "-R" option, so there is a strong case for enabling it. #ls_recurse_enable=YES # # When "listen" directive is enabled, vsftpd runs in standalone mode and # listens on IPv4 sockets. This directive cannot be used in conjunction # with the listen_ipv6 directive. listen=YES # # This directive enables listening on IPv6 sockets. By default, listening # on the IPv6 "any" address (::) will accept connections from both IPv6 # and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6 # sockets. If you want that (perhaps because you want to listen on specific # addresses) then you must run two copies of vsftpd with two configuration # files. # Make sure, that one of the listen options is commented !! # listen_ipv6=YES allow_writeable_chroot=YES ascii_upload_enable=YES ascii_download_enable=YES pam_service_name=vsftpd
相关文章推荐
- CentOS7下搭建java开发环境(JDK+Tomcat+MySQL)
- 基于CentOS 7 web服务环境搭建(包含JDK+Nginx+Tomcat+Mysql+Redis)
- 暑期打卡——Ubuntu下的java web开发环境搭建(eclipse+tomcat+mysql+jdk)
- Linux\CentOS系统下的服务器搭建,下载编译环境,安装vsFtpd、nginx、MySQL、JDK、Tomcat、PHP
- Linux下web环境的搭建【java+Mysql+tomcat+Redis】(Centos 6.5)
- 阿里云Centos7.2搭建java开发环境 jdk tomcat mysql注意事项
- Linux下利用jdk+tomcat+mysql搭建JavaWeb服务的环境
- 从零搭建CentOS7 Java开发环境(JDK1.8,MySQL 5.7,Redis3.2,Tomcat8.5)
- Java Web开发环境搭建(jdk+eclipse+tomcat+maven+mysql)
- Linux\CentOS系统下的服务器搭建,下载编译环境,安装vsFtpd、nginx、MySQL、JDK、Tomcat、PHP
- Linux搭建java web服务器环境(jdk7+tomcat7+mysql5.5 基于CentOS 6.5)
- 初学Java Web,搭建开发环境(Eclipse+Tomcat+MySQL)
- Eclipse+Tomcat+MySql搭建java web开发环境
- Mac搭建web后端开发环境:jdk +Eclipse EE + SVN + Tomcat + MySql + mysqlWorkbench
- CentOS+JDK+Tomcat+MySql&JDBCDriver 开发环境搭建实录
- Ubuntu64位(阿里云ECS)配置Java_Web环境(jdk,mysql,tomcat)
- Eclipse+tomcat+MySQL搭建JavaWeb开发环境
- 树莓派搭建java web服务器(三)--- 安装jdk-nginx-mysql-tomcat
- CentOS+JDK+Tomcat+MySql&JDBCDriver 开发环境搭建实录
- CentOS+JDK+Tomcat+MySql&JDBCDriver 开发环境搭建实录