注:本博客内容仅在Ubuntu上测试过,其他发行版不一定适用,望知晓。
FTP服务器- vsftpd
-
安装vsftpd服务器
sudo apt-get install vsftpd
-
进入vsftpd.conf文件配置
sudo vi /etc/vsftpd.conf
-
具体设置
- 设置anonymous_enable=NO,关闭匿名上传
- 指定ftp上传目录 local_root=/home/joysoarkey/ftp
- 允许本机登录 local_enable=YES
-
修改允许登录的用户
chroot_list_enable=YES chroot_list_file=/etc/vsftpd.chroot_list
-
允许上传文件到FTP服务器
write_enable=YES
-
新建文件vsftpd.chroot_list
sudo vi /etc/vsftpd.chroot_list
在其中放入被允许登录的ubuntu用户名
-
更改权限【重要】
将/home/joysoarkey/ftp文件夹拥有者的权限减去w
sudo chmod u-w /home/joysoarkey/ftp
-
重启FTP服务器
sudo /etc/init.d/vsftpd restart
若重启成功,则终端会显示以下信息[ ok ] Restarting vsftpd (via systemctl): vsftpd.service.
在其他机器连接服务器(ip地址视具体情况而定),若显示登录成功则说明FTP服务正常,可以使用。
``` C:\Users\Soarkey>ftp 192.168.0.104 连接到 192.168.0.104。 220 (vsFTPd 3.0.3) 200 Always in UTF8 mode. 用户(192.168.0.104:(none)): joysoarkey 331 Please specify the password. 密码: 230 Login successful. ftp> ```
- 上传下载
上传:put 文件名
下载:get 文件名
有图形化界面的开源ftp软件:FileZilla
SSH服务器 - openssh-server
-
检查是否已经安装
在终端输入ssh localhost,若出现以下提示说明未安装joysoarkey@Ubuntu-PC:~$ ssh localhost ssh: connect to host localhost port 22: Connection refused
以下提示说明已经安装
joysoarkey@Ubuntu-PC:~$ ssh localhost joysoarkey@localhost's password: Welcome to Ubuntu 16.10 (GNU/Linux 4.8.0-59-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage
0 packages can be updated.
0 updates are security updates.
Last login: Sun Jul 30 20:19:51 2017 from 192.168.0.101
```
-
安装ssh-server
sudo apt-get install openssh-server
-
远程登录
ssh 用户名@IP
安装JDK
- 下载JDK
JDK官网下载地址 -
解压JDK
设置存放路径为/opt(可自定义),进入到root账户,将下载好的JDK文件拷贝到/opt目录cp jdk-8u144-linux-i586.tar.gz /opt
解压
tar zxvf jdk-8u144-linux-i586.tar.gz
等待一段时间,JDK就解压完成了。JDK目录下有以下文件
-
设置环境变量
在/etc/profile中进行JDK环境变量的编辑。vi /etc/profile
在文件的最后加入以下几行(对应的位置填你的JDK解压目录)【注意不要输错】
export JAVA_HOME=/opt/jdk1.8.0_144 export JRE_HOME=/opt/jdk1.8.0_144/jre export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
配置完成之后,一定记得要用命令
source /etc/profile
刷新配置文件,让配置文件生效!!! -
检验是否安装成功
在终端输入java,出现以下界面说明已经安装配置成功了!恭喜!root@ubuntu:~$ java Usage: java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] (to execute a jar file) where options include: -d32 use a 32-bit data model if available -d64 use a 64-bit data model if available -client to select the "client" VM -server to select the "server" VM -minimal to select the "minimal" VM The default VM is client. -cp <class search path of directories and zip/jar files> -classpath <class search path of directories and zip/jar files> A : separated list of directories, JAR archives, and ZIP archives to search for class files. -D<name>=<value> set a system property -verbose:[class|gc|jni] enable verbose output -version print product version and exit -version:<value> Warning: this feature is deprecated and will be removed in a future release. require the specified version to run -showversion print product version and continue -jre-restrict-search | -no-jre-restrict-search Warning: this feature is deprecated and will be removed in a future release. include/exclude user private JREs in the version search -? -help print this help message -X print help on non-standard options -ea[:<packagename>...|:<classname>] -enableassertions[:<packagename>...|:<classname>] enable assertions with specified granularity -da[:<packagename>...|:<classname>] -disableassertions[:<packagename>...|:<classname>] disable assertions with specified granularity -esa | -enablesystemassertions enable system assertions -dsa | -disablesystemassertions disable system assertions -agentlib:<libname>[=<options>] load native agent library <libname>, e.g. -agentlib:hprof see also, -agentlib:jdwp=help and -agentlib:hprof=help -agentpath:<pathname>[=<options>] load native agent library by full pathname -javaagent:<jarpath>[=<options>] load Java programming language agent, see java.lang.instrument -splash:<imagepath> show splash screen with specified image See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
-
编写一个java文件测试
编辑Hello.java文件public class Hello{ public static void main(String[] args){ System.out.println("Hello World!"); } }
编译:
javac Hello.java
执行:
java Hello
顺利输出:
Hello World!
至此,JDK的配置已经完成!
Tomcat服务器
- 下载Tomcat
Tomcat官网下载 -
解压Tomcat
先将下载好的安装包拷贝到/opt中(目录可根据你自己喜好而定)cp apache-tomcat-9.0.0.M22.tar.gz /opt
解压
tar zxvf apache-tomcat-9.0.0.M22.tar.gz
-
启动server服务
进入到tomcat的bin目录下,启动服务./startup.sh
启动成功后会输出
Using CATALINA_BASE: /opt/apache-tomcat-9.0.0.M22 Using CATALINA_HOME: /opt/apache-tomcat-9.0.0.M22 Using CATALINA_TMPDIR: /opt/apache-tomcat-9.0.0.M22/temp Using JRE_HOME: /opt/jdk1.8.0_144 Using CLASSPATH: /opt/apache-tomcat-9.0.0.M22/bin/bootstrap.jar:/opt/apache-tomcat-9.0.0.M22/bin/tomcat-juli.jar Tomcat started.
此时即可在浏览器中通过IP:8080访问tomcat了。
mysql
-
安装mysql
sudo apt-get install mysql-server mysql-client
在安装过程中会出现以下提示,这里输入数据库root用户的密码。
-
检查mysql是否安装成功
sudo netstat -tap | grep mysql
成功的话会显示如下信息
-
常用操作
- 登录:
mysql -uroot -p
- 检查MySQL服务器占用端口:
netstat -nlt|grep 3306
- 检查MySQL服务器系统进程:
ps -aux|grep mysql
- 查看数据库的字符集编码:
show variables like '%char%';
- 登录:
-
开启mysql远程访问
如果你输入命令netstat -nlt|grep 3306
,显示的不是0.0.0.0:*
,而是127.0.0.1:3306
,
那么就需要开启mysql的远程访问功能。
(1)打开mysql配置文件sudo vim /etc/mysql/my.cnf #找到将bind-address = 127.0.0.1注销 #bind-address = 127.0.0.1
(2)修改完重启mysql
sudo /etc/init.d/mysql restart
(3)检查mysql占用端口
netstat -nlt|grep 3306 tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
此时即为成功开启远程访问
注:mysql版本不同的话,可能设置也不同。可以参考以下文章。
-
设置字符集为UTF-8
首先查看数据库字符编码,输入show variables like 'character\_set_%';
mysql> show variables like 'character_set_%'; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.03 sec)
接下来将latin1编码的属性改为utf8,有两种方法,一种是通过mysql命令修改,一种是通过配置文件修改。
-
通过mysql命令行
mysql> set character_set_client=utf8; Query OK, 0 rows affected (0.00 sec) mysql> set character_set_connection=utf8; Query OK, 0 rows affected (0.00 sec) mysql> set character_set_database=utf8; Query OK, 0 rows affected (0.00 sec) mysql> set character_set_results=utf8; Query OK, 0 rows affected (0.00 sec) mysql> set character_set_server=utf8; Query OK, 0 rows affected (0.00 sec) mysql> set character_set_system=utf8; Query OK, 0 rows affected (0.01 sec) mysql> set collation_connection=utf8; Query OK, 0 rows affected (0.01 sec) mysql> set collation_database=utf8; Query OK, 0 rows affected (0.01 sec) mysql> set collation_server=utf8; Query OK, 0 rows affected (0.01 sec)
-
通过配置文件修改
打开mysql配置文件: sudo vim/etc/mysql/my.cnf 在[client]下追加: default-character-set=utf8在[mysqld]下追加: character-set-server=utf8 在[mysql]下追加: default-character-set=utf8
再次查看字符编码,确保已经修改成功,如下
mysql> show variables like 'character%'; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ |
rows in set (0.00 sec)
-
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。