此教程基于阿里云服务器,安装好系统之后的操作。
1.MySql的配置。
推荐使用阿里云的集成配置工具“Linux一键安装web环境 ”,我使用的版本是sh-1.4.5。
(下载地址http://download.csdn.net/detail/sagitarioo/9829445)
使用Xftp工具将sh-1.4.5拷贝至root目录下。
[root@iZ28e920mwrZ ~]# ls
mysql sh-1.4.5
[root@iZ28e920mwrZ ~]#chmod -R 777 sh-1.4.5
[root@iZ28e920mwrZ ~]#cd sh-1.4.5
[root@iZ28e920mwrZ ~]#./install.sh
选择(nginx)输入1回车,
选择php版本(最大的数字版本最新),
选择Mysql的版本,
按Y确认继续,
等待安装完成。
出现以下文字时安装完成,
---------- make dir ok ----------
---------- env ok ----------
---------- mysql-5.6.21 ok ----------
---------- nginx-1.4.4 ok ----------
---------- php-5.5.7 ok ----------
---------- php extension ok ----------
---------- vsftpd-3.0.2 ok ----------
---------- phpwind-8.7 ok ----------
---------- phpmyadmin-4.1.8 ok ----------
---------- web init ok ----------
---------- rc init ok ----------
---------- mysql init ok ----------
此时输入以下命令
[root@iZ28e920mwrZ sh-1.4.5]# netstat -tunpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 22890/php-fpm: mast
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 22915/nginx: master
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 22928/vsftpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 852/sshd
tcp6 0 0 :::3306 :::* LISTEN 13552/mysqld
udp 0 0 115.28.220.200:123 0.0.0.0:* 471/ntpd
udp 0 0 10.144.255.85:123 0.0.0.0:* 471/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 471/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 471/ntpd
udp6 0 0 :::123 :::* 471/ntpd
到这里mysql就安装好了。
查看初始密码:
[root@iZ28e920mwrZ sh-1.4.5]# cat account.log
##########################################################################
#
# thank you for using aliyun virtual machine
#
##########################################################################
FTP:
account:www
password:密码
MySQL:
account:root
password:密码
尝试进入mysql
[root@iZ28e920mwrZ ~]# mysql -uroot -p
-bash: mysql: command not found
此时可能会出现如上错误。按下面步骤配置:
[root@iZ28e920mwrZ ~]# find / -name mysql
/home/mysql
/run/lock/subsys/mysql
/usr/lib64/mysql
/usr/share/mysql
/root/sh-1.4.5/php-5.5.7/travis/ext/mysql
/root/sh-1.4.5/php-5.5.7/ext/mysql
/root/sh-1.4.5/mysql
/alidata/server/mysql-5.6.21/bin/mysql
/alidata/server/mysql-5.6.21/include/mysql
/alidata/server/mysql-5.6.21/data/mysql
/alidata/server/mysql
/alidata/log/mysql
/var/spool/mail/mysql
[root@iZ28e920mwrZ ~]# ln -s /alidata/server/mysql-5.6.21/bin/mysql /usr/bin/mysql
此时即可进入mysql。
[root@iZ28e920mwrZ ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.21-log MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
修改初始密码。
mysql> use mysql;
Database changed
mysql> update user set password=password("新密码") where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye
到这里mysql即配置完毕。
如果要使用可视化工具如:Navicat for MySql连接数据库,还需要如下操作:
mysql>grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql>flush privileges;
Query OK, 0 rows affected (0.00 sec)
输入ip,账号,密码即可建立连接。
2.配置Jre
[root@iZ28e920mwrZ ~]# yum list java-1.8*
Loaded plugins: langpacks
Available Packages
java-1.8.0-openjdk.i686 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk.x86_64 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-accessibility.x86_64 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-accessibility-debug.x86_64 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-debug.i686 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-debug.x86_64 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-demo.x86_64 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-demo-debug.x86_64 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-devel.i686 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-devel.x86_64 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-devel-debug.i686 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-devel-debug.x86_64 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-headless.i686 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-headless.x86_64 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-headless-debug.i686 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-headless-debug.x86_64 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-javadoc.noarch 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-javadoc-debug.noarch 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-javadoc-zip.noarch 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-javadoc-zip-debug.noarch 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-src.x86_64 1:1.8.0.131-2.b11.el7_3 updates
java-1.8.0-openjdk-src-debug.x86_64 1:1.8.0.131-2.b11.el7_3 updates
[root@iZ28e920mwrZ ~]# yum install java-1.8.0-openjdk*
Transaction Summary
==================================================================================================================
Install 16 Packages (+31 Dependent packages)
Upgrade ( 9 Dependent packages)
Total download size: 301 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
等待自动安装完成,环境变量什么已自动配置好,无需其他设置。
3.Tomcat配置
建议自行下载到电脑解压,然后传到服务器你想放置的目录下。
地址https://mirrors.cnnic.cn/apache/tomcat/中可选择tomcat版本
我选的最新版https://mirrors.cnnic.cn/apache/tomcat/tomcat-8/v8.0.43/bin/apache-tomcat-8.0.43.tar.gz
我把tomcat文件夹放在了usr/local/中。
[root@iZ28e920mwrZ ~]# cd ..
[root@iZ28e920mwrZ /]# cd usr/local/apache-tomcat-8.0.43/bin
[root@iZ28e920mwrZ bin]# chmod u+x *.sh
[root@iZ28e920mwrZ bin]# ./startup.sh
Using CATALINA_BASE: /usr/local/apache-tomcat-8.0.43
Using CATALINA_HOME: /usr/local/apache-tomcat-8.0.43
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.0.43/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/apache-tomcat-8.0.43/bin/bootstrap.jar:/usr/local/apache-tomcat-8.0.43/bin/tomcat-juli.jar
Tomcat started.
公网ip:8080测试一下tomcat.
到这里,Mysql,jre,tomcat均配置完毕。
Mysql的字符编码可能存在问题。
mysql> show variables like 'character%';
+--------------------------+----------------------------------------------+
| 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 | /alidata/server/mysql-5.6.21/share/charsets/ |
+--------------------------+----------------------------------------------+
8 rows in set (0.00 sec)
打开/alidata/server/mysql-5.6.21/my.cnf文件,添加如下图红框中内容:
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 | /alidata/server/mysql-5.6.21/share/charsets/ |
+--------------------------+----------------------------------------------+
8 rows in set (0.01 sec)
mysql> exit;
Bye
将Ecplise中的工程打包成.war格式文件,放到tomcat目录webapps下。公网Ip+端口号+项目名称,即可访问。