阿里云服务器部署C语言开发环境
2015-12-12 16:15
639 查看
一. 配置服务器
1. 阿里云服务器相关的信息
阿里云会发一个短信到手机上, 上面有服务器的公网ip, root用户的用户名和密码.先买一个月试用一下.
服务器还没有启用, 统计数据基本没啥用.
20G的磁盘
2. 使用SecureCRT终端连接
(1) 连接服务器
此时进入了终端, 界面比较戳 :
(2) 配置界面
选项 -> 会话选项 进行如下配置 :配置完之后的界面 :
界面看起来帅气多了.
3. 使用xftp上传文件
打开xftp之后就会弹出下面的对话框, 选择 New 按钮;在这个界面配置连接服务器的参数, 注意要选择SFTP协议, 因为阿里云服务器默认选择没有安装FTP, 只能使用SFTP协议连接;
点击确定之后, 就会创建这个连接;
选择想要的连接, 点击connect按钮, 就可以连接到服务器上了.
root目录 :
根目录 :
上传一个文件示例 :
二. 配置C语言开发环境
1. 安装gcc
(1) 配置yum源
yum安装gcc很容易, 使用 yum -y install gcc 命令, 就可以安装gcc编译器, 但是除了一点问题:yum命令 : 说明安装了yum
yum -y install gcc 命令 安装gcc编译器 : 安装失败, 是因为没有安装yum源.
阿里云的服务器上安装了yum, 但是没有配置yum源, 这让人很郁闷, 尤其像我这种运维小白, 查资料吧, 终与搞定了;
yum源在 etc/yum.conf 文件中进行配置 :
阿里云服务器中的 yum.conf :
view
sourceprint?
01.
[main]
02.
cachedir=/var/cache/yum
03.
keepcache=
0
04.
debuglevel=
2
05.
logfile=/var/log/yum.log
06.
distroverpkg=redhat-release
07.
tolerant=
1
08.
exactarch=
1
09.
obsoletes=
1
10.
gpgcheck=
1
11.
plugins=
1
12.
exclude=*.i?
86
kernel kernel-xen kernel-debug
13.
14.
# Note: yum-RHN-plugin doesn't honor
this
.
15.
metadata_expire=1h
16.
17.
# Default.
18.
# installonly_limit =
3
19.
20.
# PUT YOUR REPOS HERE OR IN separate files named file.repo
21.
# in /etc/yum.repos.d
显然里面没有配置yum源, 需要在后面加上下面的内容 :
view
sourceprint?
01.
[base]
02.
name=CentOS-
5
- Base
03.
baseurl=http:
//ftp.sjtu.edu.cn/centos/5/os/$basearch/
04.
gpgcheck=
1
05.
gpgkey=http:
//mirror.centos.org/centos/RPM-GPG-KEY-centos5
06.
07.
[update]
08.
name=CentOS-
5
- Updates
09.
baseurl=http:
//ftp.sjtu.edu.cn/centos/5/updates/$basearch/
10.
gpgcheck=
1
11.
gpgkey=http:
//mirror.centos.org/centos/RPM-GPG-KEY-centos5
12.
13.
[addons]
14.
name=CentOS-
5
- Addons
15.
baseurl=http:
//ftp.sjtu.edu.cn/centos/5/addons/$basearch/
16.
gpgcheck=
1
17.
gpgkey=http:
//mirror.centos.org/centos/RPM-GPG-KEY-centos5
18.
19.
[extras]
20.
name=CentOS-
5
- Extras
21.
baseurl=http:
//ftp.sjtu.edu.cn/centos/5/extras/$basearch/
22.
gpgcheck=
1
23.
gpgkey=http:
//mirror.centos.org/centos/RPM-GPG-KEY-centos5
24.
25.
[centosplus]
26.
name=CentOS-
5
- Plus
27.
baseurl=http:
//ftp.sjtu.edu.cn/centos/5/centosplus/$basearch/
28.
gpgcheck=
1
29.
enabled=
0
30.
gpgkey=http:
//mirror.centos.org/centos/RPM-GPG-KEY-centos5
31.
32.
#contrib - packages by Centos Users
33.
[contrib]
34.
name=CentOS-
5
- Contrib
35.
baseurl=http:
//ftp.sjtu.edu.cn/centos/5/contrib/$basearch/
36.
gpgcheck=
1
37.
enabled=
1
38.
gpgkey=http:
//mirror.centos.org/centos/RPM-GPG-KEY-centos5
39.
40.
[dag]
41.
name=Dag RPM Repository
for
RHEL5
42.
baseurl=http:
//ftp.riken.jp/<a href="http://www.it165.net/os/oslin/" target="_blank" class="keylink">Linux</a>/dag/redhat/el5/en/$basearch/dag/
将yum源追加到 etc/yum.conf 配置文件中即可.
(2) GPG keys 错误
由于yum安装了不同版本的 GPG keys, 会出现下面的错误 :warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
此时解决方法 : 执行 rpm --import http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5 命令 即可解决该问题;
(3) 安装gcc编译器
执行 yum -y install gcc 命令, 即可成功安装gcc编译器.view
sourceprint?
01.
[root
@AY13120614215362640bZ
~]# yum -y install gcc
02.
addons |
1.9
kB
00
:
00
03.
base |
1.1
kB
00
:
00
04.
contrib |
1.9
kB
00
:
00
05.
dag |
1.9
kB
00
:
00
06.
extras |
2.1
kB
00
:
00
07.
update |
1.9
kB
00
:
00
08.
Excluding Packages in global exclude list
09.
Finished
10.
Setting up Install Process
11.
Resolving Dependencies
12.
--> Running transaction check
13.
---> Package gcc.x86_64
0
:
4.1
.
2
-
54
.el5 set to be updated
14.
--> Finished Dependency Resolution
15.
16.
Dependencies Resolved
17.
18.
=============================================================================================================================================================
19.
Package Arch Version Repository Size
20.
=============================================================================================================================================================
21.
Installing:
22.
gcc x86_64
4.1
.
2
-
54
.el5 base
5.3
M
23.
24.
Transaction Summary
25.
=============================================================================================================================================================
26.
Install
1
Package(s)
27.
Update
0
Package(s)
28.
Remove
0
Package(s)
29.
30.
Total download size:
5.3
M
31.
Downloading Packages:
32.
gcc-
4.1
.
2
-
54
.el5.x86_64.rpm |
5.3
MB
00
:
00
33.
Running rpm_check_debug
34.
Running Transaction Test
35.
Finished Transaction Test
36.
Transaction Test Succeeded
37.
Running Transaction
38.
Installing : gcc
1
/
1
39.
40.
Installed:
41.
gcc.x86_64
0
:
4.1
.
2
-
54
.el5
42.
43.
Complete!
验证gcc安装成功 : 输入 gcc --help 命令
view
sourceprint?
01.
[root
@AY13120614215362640bZ
~]# gcc --help
02.
Usage: gcc [options] file...
03.
Options:
04.
-pass-exit-codes Exit with highest error code from a phase
05.
--help Display
this
information
06.
--target-help Display target specific command line options
07.
(Use
'-v --help'
to display command line options of sub-processes)
08.
-dumpspecs Display all of the built in spec strings
09.
-dumpversion Display the version of the compiler
10.
-dumpmachine Display the compiler's target processor
11.
-print-search-dirs Display the directories in the compiler's search path
12.
-print-libgcc-file-name Display the name of the compiler's companion library
13.
-print-file-name=<lib> Display the full path to library <lib>
14.
-print-prog-name=<prog> Display the full path to compiler component <prog>
15.
-print-multi-directory Display the root directory
for
versions of libgcc
16.
-print-multi-lib Display the mapping between command line options and
17.
multiple library search directories
18.
-print-multi-os-directory Display the relative path to OS libraries
19.
-Wa,<options> Pass comma-separated <options> on to the assembler
20.
-Wp,<options> Pass comma-separated <options> on to the preprocessor
21.
-Wl,<options> Pass comma-separated <options> on to the linker
22.
-Xassembler <arg> Pass <arg> on to the assembler
23.
-Xpreprocessor <arg> Pass <arg> on to the preprocessor
24.
-Xlinker <arg> Pass <arg> on to the linker
25.
-combine Pass multiple source files to compiler at once
26.
-save-temps Do not delete intermediate files
27.
-pipe Use pipes rather than intermediate files
28.
-time Time the execution of each subprocess
29.
-specs=<file> Override built-in specs with the contents of <file>
30.
-std=<standard> Assume that the input sources are
for
<standard>
31.
--sysroot=<directory> Use <directory> as the root directory
for
headers
32.
for
headers and libraries
33.
-B <directory> Add <directory> to the compiler's search paths
34.
-b <machine> Run gcc
for
target <machine>,
if
installed
35.
-V <version> Run gcc version number <version>,
if
installed
36.
-v Display the programs invoked by the compiler
37.
-### Like -v but options quoted and commands not executed
38.
-E Preprocess only;
do
not compile, assemble or link
39.
-S Compile only;
do
not assemble or link
40.
-c Compile and assemble, but
do
not link
41.
-o <file> Place the output into <file>
42.
-x <language> Specify the language of the following input files
43.
Permissible languages include: c c++ assembler none
44.
'none'
means revert to the
default
behavior of
45.
guessing the language based on the file's extension
46.
47.
Options starting with -g, -f, -m, -O, -W, or --param are automatically
48.
passed on to the various sub-processes invoked by gcc. In order to pass
49.
other options on to these processes the -W<letter> options must be used.
50.
51.
For bug reporting instructions, please see:
52.
<url:http: bugzilla=
""
bugzilla.redhat.com=
""
>.</url:http:></letter></language></file></file></version></version></machine></machine></directory></directory></directory></directory></standard></standard></file></file></arg></arg></arg></arg></arg></arg></options></options></options></options></options></options></prog></prog></lib></lib>
2. 配置vim编辑器
一个好的vim编译器配置, 能让开发效率提升十倍, 这里推荐一个vim编辑器的配置文件 :vimrc 文件 下载地址 : http://download.csdn.net/detail/han1202012/6684437
使用xftp工具直接上传到服务器的 root下.
vim编辑器在secureCRT上的效果 :
有高亮显示, 有代码自动提示;
蓝色注释看得太费眼了, 改成绿色注释, 在vimrc文件中加上 hi Comment ctermfg=green , 可以将注释颜色改为绿色;
暂时就这样配置了, 如果有进一步的改进, 在继续在这篇博客上继续改进.
3. 编译运行C语言程序
编译刚才的文件 :执行成功, C语言开发环境安装完毕!
三. 配置J2EE运行环境
1. 安装tomcat
(1) 下载tomcat
tomcat下载地址 : http://tomcat.apache.org/download-60.cgi 地址栏输入下面地址可下载 : http://mirror.esocc.com/apache/tomcat/tomcat-6/v6.0.37/bin/apache-tomcat-6.0.37-deployer.tar.gz
使用xftp将tomcat上传到阿里云服务器上, 将tomcat安装到一个目录中, 在目录同级创建一个app目录, 用来存放网站源码, war包.
(2) 安装配置tomcat
使用 tar xvfz apache-tomcat-6.0.37 命令 解压tar.gz文件到当前文件;解压完成后 :
为了方面起见, 更改tomcat目录以及其子目录下所有文件的访问权限为755 : 使用 chmod -R 755 目录名/* 可以改变该目录下所有子文件的访问权限.
修改tomcat/conf/server.xml配置 : 在这个文件中添加Context配置, 这个配置指向网站源文件目录 :
在app目录中存放网站的源文件 :
(3) 启动tomcat
启动脚本位置在tomcat根目录中的 bin 下的 startup.sh, 执行这个脚本文件 即可启动tomcat .查看启动日志 :
启动 tomcat成功;
此时访问 : http://115.28.42.124:8080 即可访问该网站, 只是个demo.
2. 期间的一些排错
好坎坷, 出了好多错误, 不过还好都解决了tomcat启动端口占用问题 : 执行 ps -ef|grep java 可以查看java相关的进程
杀死被占用的进程 : kill -9 31658 就可以将该tomcat终止;
查看tomcat日志 命令 : tail -f -n 200 文件名
其中的-f 是 日志滚动, -n 200 指定显示多少航日志
vim编辑器复制 : ctrl + shift + c
vim编辑器粘贴 : ctrl + shift + v
网站地址 : http://115.28.42.124:8080 终于部署好了
相关文章推荐
- C/C++用户模式下改写硬盘主引导记录(MBR)
- C++学习笔记34——类的static成员
- C语言MOOC视频地址
- C语言对数组的各种操作操作
- c语言之内联inline
- c++_4:多态_2_虚函数的原理
- 实战c++中的string系列--CDuiString和string的转换(duilib中的cduistring)
- 实战c++中的string系列--CDuiString和string的转换(duilib中的cduistring)
- 简单利用模板的例子
- 关于CodeBlocks中stdc++-6.dll缺失的小问题
- 关于CodeBlocks中stdc++-6.dll缺失的小问题
- C++ <chrono> 时间库
- C语言的printf函数的执行顺序
- C语言总结
- C++常用字符串分割方法
- c语言之变量存储类型
- C语言基础总结1
- C语言中的关键字
- Persistence机制
- VC++程序调试debug dump