阿里云服务器部署C语言开发环境

一. 配置服务器

1. 阿里云服务器相关的信息

阿里云会发一个短信到手机上, 上面有服务器的公网ip, root用户的用户名和密码.

先买一个月试用一下.

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/ba293c580fe07af3685f28a9eb9d8aa9.jpeg

服务器还没有启用, 统计数据基本没啥用.

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/579b30cd5640972fc88263693fba1b99.jpeg

20G的磁盘

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/1fc63ffb0d00564f6b146f1337f46870.jpeg

2. 使用SecureCRT终端连接

(1) 连接服务器

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/27f106f855e9d4a95c7edafded43382c.jpeg

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/fad9e8d8a2cf992158177bdeb20c7c81.jpeg

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/a9e35f1933997bfb88b2ec5818cb9e8b.jpeg

此时进入了终端, 界面比较戳 :

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/fa98666f0f0d5606e0cac0cdc77ed82c.jpeg

(2) 配置界面

选项 -> 会话选项 进行如下配置 :

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/38d61e4f08f496e3dff751ba7064dda1.jpeg

配置完之后的界面 :

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/7d92b6102bd0df6ae22742fc59aa1f77.jpeg

界面看起来帅气多了.

3. 使用xftp上传文件

打开xftp之后就会弹出下面的对话框, 选择 New 按钮;

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/341f2dd6d7021265eba0c8b0552bf2a6.jpeg

在这个界面配置连接服务器的参数, 注意要选择SFTP协议, 因为阿里云服务器默认选择没有安装FTP, 只能使用SFTP协议连接;

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/37669602653922a65b4473392d7d2342.jpeg

点击确定之后, 就会创建这个连接;

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/f6ba57858ac8541c1ed36969ba3b6001.jpeg

选择想要的连接, 点击connect按钮, 就可以连接到服务器上了.

root目录 :

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/57ed34e403a71c3d0c58675997ed79c2.jpeg

根目录 :

 

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/ad52623f7ecb11516142888cdc819a26.jpeg

上传一个文件示例 :

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/b8420be8876007349d5683b73693ba7e.jpeg

二. 配置C语言开发环境

1. 安装gcc

(1) 配置yum源

yum安装gcc很容易, 使用 yum -y install gcc 命令, 就可以安装gcc编译器, 但是除了一点问题:

yum命令 : 说明安装了yum

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/98d9ff50b68082c82d6f1a08bd2d97d9.jpeg


yum -y install gcc 命令 安装gcc编译器 : 安装失败, 是因为没有安装yum源.

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/b4846dcb7a61efda18633ceb819f9277.jpeg

阿里云的服务器上安装了yum, 但是没有配置yum源, 这让人很郁闷, 尤其像我这种运维小白, 查资料吧, 终与搞定了;

yum源在 etc/yum.conf 文件中进行配置 :

阿里云服务器中的 yum.conf :

 

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源, 需要在后面加上下面的内容 :

 

 

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编译器.

 

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 命令

 

 

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.youkuaiyun.com/detail/han1202012/6684437

使用xftp工具直接上传到服务器的 root下.

vim编辑器在secureCRT上的效果 :

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/36808d400462831be6dc413628f29ca1.jpeg

有高亮显示, 有代码自动提示;

蓝色注释看得太费眼了, 改成绿色注释, 在vimrc文件中加上 hi Comment ctermfg=green , 可以将注释颜色改为绿色;

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/7019e8e111b7fafedf9badf8e65e5e83.jpeg

暂时就这样配置了, 如果有进一步的改进, 在继续在这篇博客上继续改进.

3. 编译运行C语言程序

编译刚才的文件 :

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/2ee76cd35db48096e094a3e5a4797d75.jpeg

执行成功, 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包.

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/f1aa8ad54a2c159378579ca456dd21ee.jpeg

(2) 安装配置tomcat

使用 tar xvfz apache-tomcat-6.0.37 命令 解压tar.gz文件到当前文件;

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/eb355bfd34f3726d3627b33de6b701a3.jpeg

解压完成后 :

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/820b16a8f56ee08f9df8083994d47961.jpeg

为了方面起见, 更改tomcat目录以及其子目录下所有文件的访问权限为755 : 使用 chmod -R 755 目录名/* 可以改变该目录下所有子文件的访问权限.

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/cf4f38ca7b657cef0dc709bb58fa6383.jpeg

修改tomcat/conf/server.xml配置 : 在这个文件中添加Context配置, 这个配置指向网站源文件目录 :

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/8f668a3d72e77311badb5fef4d127999.jpeg

在app目录中存放网站的源文件 :

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/836cb3320d87c3ece0a24575b8cd6463.jpeg

(3) 启动tomcat

启动脚本位置在tomcat根目录中的 bin 下的 startup.sh, 执行这个脚本文件 即可启动tomcat .

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/b763ecbe28eace1fd9d6b301b99a0d52.jpeg

查看启动日志 :

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/801113bf9f202d65e53b971ba3c7d959.jpeg

启动 tomcat成功;

此时访问 : http://115.28.42.124:8080 即可访问该网站, 只是个demo.

2. 期间的一些排错

好坎坷, 出了好多错误, 不过还好都解决了

tomcat启动端口占用问题 : 执行 ps -ef|grep java 可以查看java相关的进程

data-cke-saved-src=https://i-blog.csdnimg.cn/blog_migrate/a6caaaa989511680d78b43ad64f8d91f.jpeg

杀死被占用的进程 : 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 终于部署好了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值