【Linux 操作系统】阿里云服务器 操作实战 部署C语言开发环境(vim配置,gcc) 部署J2EE网站(jdk,tomcat)
.
作者?:萬境絕塵?
轉(zhuǎn)載請注明出處?:?http://blog.csdn.net/shulianghan/article/details/18964835
.
博客總結(jié) : 設(shè)置SecureCRT顯示行數(shù) : 會話選項 -> 終端 -> 仿真 -> 回滾(回滾緩沖區(qū)) 設(shè)置一個NNNN值.
在公司呆久了, 感覺全身都生銹了, 突然心血來潮, 準(zhǔn)備自己用java寫一個網(wǎng)站.
選來選去, 最終感覺阿里云的服務(wù)器性價比蠻高的, 買了一個最便宜的配置用來學(xué)習(xí)用.
在家里配置了一下, 到了公司又不會配置了, 怕忘了寫篇博客記錄下來, 一通配置下來, 發(fā)現(xiàn)自己有運維工程師的潛質(zhì).?
一. 配置服務(wù)器
1. 阿里云服務(wù)器相關(guān)的信息
阿里云會發(fā)一個短信到手機(jī)上, 上面有服務(wù)器的公網(wǎng)ip, root用戶的用戶名和密碼.
先買一個月試用一下.
服務(wù)器還沒有啟用, 統(tǒng)計數(shù)據(jù)基本沒啥用.
20G的磁盤
2. 使用SecureCRT終端連接
(1) 連接服務(wù)器
此時進(jìn)入了終端, 界面比較戳 :?
(2) 配置界面?
選項 -> 會話選項 進(jìn)行如下配置 :
?
配置完之后的界面 :?
界面看起來帥氣多了.
3. 使用xftp上傳文件
打開xftp之后就會彈出下面的對話框, 選擇 New 按鈕;
在這個界面配置連接服務(wù)器的參數(shù), 注意要選擇SFTP協(xié)議, 因為阿里云服務(wù)器默認(rèn)選擇沒有安裝FTP, 只能使用SFTP協(xié)議連接;
點擊確定之后, 就會創(chuàng)建這個連接;
選擇想要的連接, 點擊connect按鈕, 就可以連接到服務(wù)器上了.
root目錄 :?
根目錄 :
?
上傳一個文件示例 :?
二. 配置C語言開發(fā)環(huán)境
1. 安裝gcc
(1) 配置yum源
yum安裝gcc很容易, 使用 yum -y install gcc 命令, 就可以安裝gcc編譯器, 但是除了一點問題:
yum命令 : 說明安裝了yum
yum -y install gcc 命令 安裝gcc編譯器 : 安裝失敗, 是因為沒有安裝yum源.
阿里云的服務(wù)器上安裝了yum, 但是沒有配置yum源, 這讓人很郁悶, 尤其像我這種運維小白, 查資料吧, 終與搞定了;
yum源在 etc/yum.conf 文件中進(jìn)行配置 :?
阿里云服務(wù)器中的 yum.conf :?
[main] cachedir=/var/cache/yum keepcache=0 debuglevel=2 logfile=/var/log/yum.log distroverpkg=redhat-release tolerant=1 exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 exclude=*.i?86 kernel kernel-xen kernel-debug# Note: yum-RHN-plugin doesn't honor this. metadata_expire=1h# Default. # installonly_limit = 3# PUT YOUR REPOS HERE OR IN separate files named file.repo # in /etc/yum.repos.d
顯然里面沒有配置yum源, 需要在后面加上下面的內(nèi)容 :?
[base] name=CentOS-5 - Base baseurl=http://ftp.sjtu.edu.cn/centos/5/os/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5[update] name=CentOS-5 - Updates baseurl=http://ftp.sjtu.edu.cn/centos/5/updates/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5[addons] name=CentOS-5 - Addons baseurl=http://ftp.sjtu.edu.cn/centos/5/addons/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5[extras] name=CentOS-5 - Extras baseurl=http://ftp.sjtu.edu.cn/centos/5/extras/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5[centosplus] name=CentOS-5 - Plus baseurl=http://ftp.sjtu.edu.cn/centos/5/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5#contrib - packages by Centos Users [contrib] name=CentOS-5 - Contrib baseurl=http://ftp.sjtu.edu.cn/centos/5/contrib/$basearch/ gpgcheck=1 enabled=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5[dag] name=Dag RPM Repository for RHEL5 baseurl=http://ftp.riken.jp/Linux/dag/redhat/el5/en/$basearch/dag/
將yum源追加到 etc/yum.conf 配置文件中即可.?
(2) GPG keys 錯誤
由于yum安裝了不同版本的 GPG keys, 會出現(xiàn)下面的錯誤 :?
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
此時解決方法 : 執(zhí)行?rpm --import http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5 命令 即可解決該問題;
(3) 安裝gcc編譯器
執(zhí)行 yum -y install gcc 命令, 即可成功安裝gcc編譯器.
[root@AY13120614215362640bZ ~]# yum -y install gcc addons | 1.9 kB 00:00 base | 1.1 kB 00:00 contrib | 1.9 kB 00:00 dag | 1.9 kB 00:00 extras | 2.1 kB 00:00 update | 1.9 kB 00:00 Excluding Packages in global exclude list Finished Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package gcc.x86_64 0:4.1.2-54.el5 set to be updated --> Finished Dependency ResolutionDependencies Resolved=============================================================================================================================================================Package Arch Version Repository Size ============================================================================================================================================================= Installing:gcc x86_64 4.1.2-54.el5 base 5.3 MTransaction Summary ============================================================================================================================================================= Install 1 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 5.3 M Downloading Packages: gcc-4.1.2-54.el5.x86_64.rpm | 5.3 MB 00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running TransactionInstalling : gcc 1/1 Installed:gcc.x86_64 0:4.1.2-54.el5 Complete!
驗證gcc安裝成功 : 輸入 gcc --help 命令
[root@AY13120614215362640bZ ~]# gcc --help Usage: gcc [options] file... Options:-pass-exit-codes Exit with highest error code from a phase--help Display this information--target-help Display target specific command line options(Use '-v --help' to display command line options of sub-processes)-dumpspecs Display all of the built in spec strings-dumpversion Display the version of the compiler-dumpmachine Display the compiler's target processor-print-search-dirs Display the directories in the compiler's search path-print-libgcc-file-name Display the name of the compiler's companion library-print-file-name=<lib> Display the full path to library <lib>-print-prog-name=<prog> Display the full path to compiler component <prog>-print-multi-directory Display the root directory for versions of libgcc-print-multi-lib Display the mapping between command line options andmultiple library search directories-print-multi-os-directory Display the relative path to OS libraries-Wa,<options> Pass comma-separated <options> on to the assembler-Wp,<options> Pass comma-separated <options> on to the preprocessor-Wl,<options> Pass comma-separated <options> on to the linker-Xassembler <arg> Pass <arg> on to the assembler-Xpreprocessor <arg> Pass <arg> on to the preprocessor-Xlinker <arg> Pass <arg> on to the linker-combine Pass multiple source files to compiler at once-save-temps Do not delete intermediate files-pipe Use pipes rather than intermediate files-time Time the execution of each subprocess-specs=<file> Override built-in specs with the contents of <file>-std=<standard> Assume that the input sources are for <standard>--sysroot=<directory> Use <directory> as the root directory for headersfor headers and libraries-B <directory> Add <directory> to the compiler's search paths-b <machine> Run gcc for target <machine>, if installed-V <version> Run gcc version number <version>, if installed-v Display the programs invoked by the compiler-### Like -v but options quoted and commands not executed-E Preprocess only; do not compile, assemble or link-S Compile only; do not assemble or link-c Compile and assemble, but do not link-o <file> Place the output into <file>-x <language> Specify the language of the following input filesPermissible languages include: c c++ assembler none'none' means revert to the default behavior ofguessing the language based on the file's extensionOptions starting with -g, -f, -m, -O, -W, or --param are automaticallypassed on to the various sub-processes invoked by gcc. In order to passother options on to these processes the -W<letter> options must be used.For bug reporting instructions, please see: <URL:http://bugzilla.redhat.com/bugzilla>.
2. 配置vim編輯器
一個好的vim編譯器配置, 能讓開發(fā)效率提升十倍, 這里推薦一個vim編輯器的配置文件 :?
vimrc 文件 下載地址 :?http://download.csdn.net/detail/han1202012/6684437?
使用xftp工具直接上傳到服務(wù)器的 root下.
vim編輯器在secureCRT上的效果 :?
有高亮顯示, 有代碼自動提示;
藍(lán)色注釋看得太費眼了, 改成綠色注釋, 在vimrc文件中加上 hi Comment ctermfg=green , 可以將注釋顏色改為綠色;
暫時就這樣配置了, 如果有進(jìn)一步的改進(jìn), 在繼續(xù)在這篇博客上繼續(xù)改進(jìn).
3. 編譯運行C語言程序?
編譯剛才的文件 :?
執(zhí)行成功, C語言開發(fā)環(huán)境安裝完畢!
三. 配置J2EE運行環(huán)境
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上傳到阿里云服務(wù)器上, 將tomcat安裝到一個目錄中, 在目錄同級創(chuàng)建一個app目錄, 用來存放網(wǎng)站源碼, war包.
(2) 安裝配置tomcat
使用?tar xvfz apache-tomcat-6.0.37 命令 解壓tar.gz文件到當(dāng)前文件;
解壓完成后 :?
為了方面起見, 更改tomcat目錄以及其子目錄下所有文件的訪問權(quán)限為755 : ?使用 chmod -R 755 目錄名/* 可以改變該目錄下所有子文件的訪問權(quán)限.?
修改tomcat/conf/server.xml配置 : ?在這個文件中添加Context配置, 這個配置指向網(wǎng)站源文件目錄 :?
在app目錄中存放網(wǎng)站的源文件 :?
(3) 啟動tomcat
啟動腳本位置在tomcat根目錄中的 bin 下的 startup.sh, 執(zhí)行這個腳本文件 即可啟動tomcat .
查看啟動日志 :?
啟動 tomcat成功;
此時訪問 : http://115.28.42.124:8080 即可訪問該網(wǎng)站, 只是個demo.
2. 期間的一些排錯
好坎坷, 出了好多錯誤, 不過還好都解決了
tomcat啟動端口占用問題 : ?執(zhí)行 ps -ef|grep java 可以查看java相關(guān)的進(jìn)程
殺死被占用的進(jìn)程 : kill -9 31658 就可以將該tomcat終止;
查看tomcat日志 命令 : tail -f -n 200 文件名?
其中的-f 是 日志滾動, -n 200 指定顯示多少航日志?
vim編輯器復(fù)制 : ctrl + shift + c?
vim編輯器粘貼 : ctrl + shift + v
.
作者?:萬境絕塵?
轉(zhuǎn)載請注明出處?:?http://blog.csdn.net/shulianghan/article/details/18964835
.
網(wǎng)站地址 :?http://115.28.42.124:8080 終于部署好了
360是流氓啊 啥都沒放就說我的網(wǎng)站有病毒?
總結(jié)
以上是生活随笔為你收集整理的【Linux 操作系统】阿里云服务器 操作实战 部署C语言开发环境(vim配置,gcc) 部署J2EE网站(jdk,tomcat)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【UML 建模】UML建模语言入门 --
- 下一篇: 【Android 应用开发】Androi