发表于: 2016-04-03 23:22:31
1 2945
今天完成的事:
完成任务3
一个月前申请的阿里云服务器了,当时申请的是ubuntu系统的。今天上午把除了nginx全都做完了。觉得ubuntu系统太麻烦。于是下午换成了centos系统,重新开始做。所幸任务3比较简单
1.安装mysql
yum list mysql-server -->service mysqld start -->chkconfig mysqld on -->/usr/bin/mysql -uroot -->set password for 'root'@'localhost'=password('×××××××');
2、新建数据库CREATE DATABASE lingyv;
3、新建表格
create table student( id int auto_increment primary key, name varchar(32), birth bigint,profession varchar(50),create_at bigint,update_at bigint);
5.安装jdk
yum -y install java-1.7.0-openjdk
4.安装启用jetty
wget http://download.eclipse.org/jetty/9.2.15.v20160210/dist/
scp jetty-distribution-9.2.15.v20160210.tar.gz root@121.42.155.28://home/downloads
tar -xvf jetty-distribution-9.2.15.v20160210.tar.gz
mv jetty-distribution-9.2.5.v20141112 /opt
mv jetty-distribution-9.2.5.v20141112 jetty
useradd -m jetty
chown -R jetty:jetty /opt/jetty/
ln -s /opt/jetty/bin/jetty.sh /etc/init.d/jetty
chkconfig --add jetty
chkconfig --level 345 jetty on
vi /etc/default/jetty
JETTY_HOME=/opt/jetty
JETTY_USER=jetty
JETTY_PORT=8080
JETTY_HOST=50.116.24.78
JETTY_LOGS=/opt/jetty/logs/
5.传输war文件至服务器
scp lingyvtest2.war root@121.42.155.28:/opt/jetty/webapps
6启动jetty
serivice jetty start
7访问http://121.42.155.28:8080/lingyvtest2/date/getdate
8.postman:add方法失败
手动添加
查询:成功
本地测试各方法:成功
重新打包:maven install
关闭jeety:service jetty stop
传输war文件至服务器
重新开启jetty
测试:除了add、update两个方法外。其他均正常。add、update方法sql语句中create_at,update_at包含now()函数。在服务器mysql中手动添加数据,用now()函数,只加入了2016年。执行SELECT now();,返回时间正常,这是为什么呢?
9.用shell ssh,一段时间没操作就会自动短线
解决http://blog.csdn.net/hitabc141592/article/details/40150983
10:编写start.sh,stop.sh
[root@iZ28gnty9urZ sh]# vi start.sh
[root@iZ28gnty9urZ sh]# vi stop.sh
[root@iZ28gnty9urZ sh]# chmod +x start.sh
[root@iZ28gnty9urZ sh]# chmod +x stop.sh
[root@iZ28gnty9urZ sh]# ./stop.sh
关闭jetty
Stopping Jetty: OK
[root@iZ28gnty9urZ sh]# ./start.sh
开启jetty
Starting Jetty: StartLog to /opt/jetty/logs/start.log
2016-04-03 18:02:03.746:INFO::main: Logging initialized @926ms
2016-04-03 18:02:03.841:WARN:oejs.HomeBaseWarning:main: This instance of Jetty is not running from a separate {jetty.base} directory, this is not recommended. See documentation at http://www.eclipse.org/jetty/documentation/current/startup.html
2016-04-03 18:02:04.207:INFO::main: Redirecting stderr/stdout to /opt/jetty/logs/2016_04_03.stderrout.log
. . . OK Sun Apr 3 18:02:18 CST 2016
11.了解nginx
12.安装nginx
yum install nginx nginx.x86_64
13.启动nginx
service nginx start
14.更改配置文件
参考(https://segmentfault.com/a/1190000002797601#articleHeader10
http://www.chinaz.com/web/2015/0424/401323.shtml)
[root@iZ28gnty9urZ nginx]# service nginx stop
Stopping nginx: [ OK ]
[root@iZ28gnty9urZ nginx]# service jetty stop
Stopping Jetty: OK
vi nginx.conf
15.成功
通过jetty
通过nginx
16、将nginx加入start.sh,stop.sh
[root@iZ28gnty9urZ sh]# ./start.sh
开启jetty
Starting Jetty: StartLog to /opt/jetty/logs/start.log
2016-04-03 23:02:52.352:INFO::main: Logging initialized @879ms
2016-04-03 23:02:52.441:WARN:oejs.HomeBaseWarning:main: This instance of Jetty is not running from a separate {jetty.base} directory, this is not recommended. See documentation at http://www.eclipse.org/jetty/documentation/current/startup.html
2016-04-03 23:02:52.797:INFO::main: Redirecting stderr/stdout to /opt/jetty/logs/2016_04_03.stderrout.log
. . . OK Sun Apr 3 23:03:07 CST 2016
开启nginx
Starting nginx: [ OK ]
[root@iZ28gnty9urZ sh]# ./stop.sh
关闭nginx
Stopping nginx: [ OK ]
关闭jetty
Stopping Jetty: OK
17、查看nginx文件
cd /var/log/nginx
cat err.log(错误日志)
cat access.log(访问日志)
明天计划的事情:女朋友去实习,上午去机场送她。下午慕课网学习HTML、CSS、JavaScript,开始着手任务4
遇到的问题:软件包在本地测试一切正常。上传到服务器中,用postman测试时,其中sql语句中用到now()函数的方法就会不能用。mysql中手动添加用户,使用now()函数,插入的是2016(create_at,update_at 时间用的类型是bigint),但是直接用SELECT now(),获取的时间是正常的。
收货:了解了nginx。学会在服务器中jetty,ngidx的基本用法
评论