在开发日趋激烈的今天。我们可不能再仅仅会编码了。这样搞不好。就成了一辈子的码奴!所以这里简单的分享一下server的搭建,因为Linux的安全性等一切因素让它成为了server平台的首选环境!今天跟大家分享的是Java项目的server搭建。好啦。步骤来了:
1、下载jdk
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
2、下载tomcat
wget http://apache.etoak.com/tomcat/tomcat-7/v7.0.42/bin/apache-tomcat-7.0.42.tar.gz
3、解压jdk和tomcatmkdir /nac/www
mkdir /nac/www
cd /nac/www
tar zxvf jdk-7u25-linux-i586.gz
tar zxvf apache-tomcat-7.0.42.tar.gz
chmod –R 755 /nac
mv jdk1.7.0_25/ jdk
mv apache-tomcat-7.0.42 tomcat
4、配置环境变量
vi /etc/profile
export JAVA_HOME=/nac/www/jdk
export PATH=$JAVA_HOME/bin:$JRE_HOME/jre/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$LCASSPATH
export CATALINA_HOME=/nac/www/tomcat
export CLASSPATH=.:$JAVA_HOME/lib:$CATALINA_HOME/lib
export PATH=$PATH:$CATALINA_HOME/bin
刷新配置
source /etc/profile
5、改动*.sh权限和运行脚本
cd /apache-tomcat/bin/
chmod 777 *.sh
bash catalina.sh start
bash /apache-tomcat/bin/catalina.sh start
6、改动iptables
vi /etc/sysconfig/iptables
在里面加入
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT //加入mysql
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT //加入tomcat
7、改动mysql和tomcat开机启动
Chkconfig mysqld on
Chkconfig mysqld –list 检查开机启动
改动vi /etc/rc.d/rc.local
/apache-tomcat/bin/catalina.sh start
8、加入mysql的username和password
Mysql –u root
GRANT ALL PRIVILEGES ON *.* TO hupu@"%" IDENTIFIED BY 'hupu' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO hupu@localhost IDENTIFIED BY 'hupu' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY 'root' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY 'root' WITH GRANT OPTION;
9、在浏览器输入server的ip:8080。例如以下:“10.10.2.221:8080”,
当看到这里页面的时候,说明一切都ok了。就这样能够执行部署Java项目的server就搭建好了。