安装实操:JDK+NGINX+TOMCAT

安装实操:JDK+NGINX+TOMCAT

1 添加依赖的系统工具:
yum -y install gcc gcc-c++ autoconf automake
或执行比较全的命令(如果执行make && make install 命令无法找到的情况)
yum -y install ntp vim-enhanced gcc gcc-c++ gcc-g77 flex bison autoconf automake glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel libtool* zlib-devel libxml2-devel libjpeg-devel libpng-devel libtiff-devel fontconfig-devel freetype-devel libXpm-devel gettext-devel curl curl-devel pam-devel e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

2 安装JDK
上传 jdk-6u37-linux-x64-rpm.bin 到 /usr/java目录下,因为初始化时没有java目录,自行创建即可。
cd /usr/java
执行权限并执行
# chmod u+x jdk-6u37-linux-x64-rpm.bin
# ./jdk-6u37-linux-x64-rpm.bin
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
inflating: jdk-6u37-linux-amd64.rpm
inflating: sun-javadb-common-10.6.2-1.1.i386.rpm
inflating: sun-javadb-core-10.6.2-1.1.i386.rpm
inflating: sun-javadb-client-10.6.2-1.1.i386.rpm
inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm
inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm
inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm
Preparing... ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
plugin.jar...
javaws.jar...
deploy.jar...
Installing JavaDB
Preparing... ########################################### [100%]
1:sun-javadb-common ########################################### [ 17%]
2:sun-javadb-core ########################################### [ 33%]
3:sun-javadb-client ########################################### [ 50%]
4:sun-javadb-demo ########################################### [ 67%]
5:sun-javadb-docs ########################################### [ 83%]
6:sun-javadb-javadoc ########################################### [100%]

Java(TM) SE Development Kit 6 successfully installed.

Product Registration is FREE and includes many benefits:
* Notification of new versions, patches, and updates
* Special offers on Oracle products, services and training
* Access to early releases and documentation

Product and system data will be collected. If your configuration
supports a browser, the JDK Product Registration form will
be presented. If you do not register, none of this information
will be saved. You may also register your JDK later by
opening the register.html file (located in the JDK installation
directory) in a browser.

For more information on what data Registration collects and
how it is managed and used, see:
http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html

Press Enter to continue.....

Done.
安装完成,配置环境变量
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

#PATH=$PATH:$HOME/bin

#export PAT

JAVA_HOME=/usr/java/jdk1.6.0_37
CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar

PATH=$PATH:$HOME/bin:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:/sbin

export PATH JAVA_HOME CLASSPATH
unset USERNAME

第二种情况配置环境变:可能 .bash_profile 不起作用,则要去/etc/ 去配置环境变量
vi /etc/profile
在文件最后加上
JAVA_HOME=/usr/java/jdk1.6.0_37
CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar

PATH=$PATH:$HOME/bin:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:/sbin

export PATH JAVA_HOME CLASSPATH

3 安装NGINX
3.1 安装相关依赖
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
NGINX 要用到pcre 和openssl
3.2 上传并解压包去/usr/src/ 目录编译
# tar zxvf nginx-1.2.6.tar.gz -C /usr/src/
cd /usr/src/ nginx-1.2.6/
执行:
# ./configure
# make && make install
nginx默认安装到/usr/local/nginx目录下,同通过./configure --help命令查看nginx可选择的编译选项。

安装成功后
去/usr/local/nginx/sbin 启动
#./nginx
查看 ps –ef | grep nginx
# ps -ef | grep nginx
root 63423 1 0 10:22 ? 00:00:00 nginx: master process ./nginx
nobody 63424 63423 0 10:22 ? 00:00:00 nginx: worker process
root 63427 60747 0 10:22 pts/1 00:00:00 grep nginx
登录 http://localhost/ 查看
出现
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
表示成功。
4 安装tomcat
4.1 上传并解压到
# tar zxvf apache-tomcat-6.0.36.tar.gz -C /usr/local/
cd /usr/local
cp -r apache-tomcat-6.0.36/ tomcat
rm –rf apache-tomcat-6.0.36
这样就只剩下 tomcat目录了 /usr/local/tomcat

5 设置nginx 参数配置

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#user add error level
error_log logs/error.log info;

#pid logs/nginx.pid;

pid logs/nginx.pid;

events {
#user add
use epoll;
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;
#access_log logs/access.log

#user add
#client_header_timeout 3m;
#client_body_timeout 3m;
#send_timeout 3m;

#client_header_buffer_size 1k;
#large_client_header_buffers 4 4k;

#sendfile on;
#tcp_nopush on;
#tcp_nopush on;
#tcp_nodelay on;

#keepalive_timeout 0;
#keepalive_timeout 65;

#gzip on;

#proxy

#include proxy.conf ;

#gzip on;

#user add

#include gzip.conf;

server {
listen 80;
server_name localhost;
index index.html index.htm index.jsp; #设定访问的默认首页地址
root /usr/local/nginx/html; #设定网站的资源存放路径

charset UTF-8;

#access_log logs/host.access.log main;

location /index.html
{
index index.html;
proxy_pass http://localhost:8080;#转向tomcat处理
}

location ~ .*.do$ #所有jsp的页面均交由tomcat处理
{
index index.jsp;
proxy_pass http://localhost:8080;#转向tomcat处理
}

location ~ .*.htm$ #所有htm的页面均交由tomcat处理
{
proxy_pass http://localhost:8080;#转向tomcat处理
}

location ~ .*.jsp$ #所有htm的页面均交由tomcat处理
{
proxy_pass http://localhost:8080;#转向tomcat处理
}

location ~ .*.svl$ #所有htm的页面均交由tomcat处理
{
proxy_pass http://localhost:8080;#转向tomcat处理
}

location ~ .*.jhtml$ #所有htm的页面均交由tomcat处理
{
proxy_pass http://localhost:8080;#转向tomcat处理
}

location /p/get #所有htm的页面均交由tomcat处理
{
proxy_pass http://localhost:8080;#转向tomcat处理
}

location /connect/qqlogin #所有htm的页面均交由tomcat处理
{
proxy_pass http://localhost:8080;#转向tomcat处理
}

location /admin/lsoba/* #所有htm的页面均交由tomcat处理
{
proxy_pass http://localhost:8080;#转向tomcat处理
}

location /auth/weibo #所有htm的页面均交由tomcat处理
{
proxy_pass http://localhost:8080;#转向tomcat处理
}

location /weibo/callback #所有htm的页面均交由tomcat处理
{
proxy_pass http://localhost:8080;#转向tomcat处理
}

location /qq/addshare #所有htm的页面均交由tomcat处理
{
proxy_pass http://localhost:8080;#转向tomcat处理
}

# read nginx

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ #设定访问静态文件直接读取不经过tomcat
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 1h;
}



error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443;
# server_name localhost;

# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_timeout 5m;

# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}


6 安装mysql
centos 安装 mysql-server

直接yum install mysql-server

然后启动 /etc/rc.d/ini.d/mysqld start 启动一下就OK了

修改密码:
不用进入mysql执行
# mysqladmin -u root password lijian
lijian为新密码。

重启 mysql 命令:
/etc/init.d/mysqld restart

如果连接mysql 出现 host ... is not allowed to connect to this MySql server
说明权限有问题,执行以下授权即可。
进入mysql 执行:mysql –uroot –p
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'lijian' WITH GRANT OPTION;

6 部署应用
上传ROOT.war包到tomcat 的webapps下。

重启tomcat

完成相应的软连接。
命令最常用的参数是-s,具体用法是:ln -s 源文件 目标文件。
如:
ln -s /usr/local/pic/images/ /usr/local/tomcat/webapps/ROOT/images
ln -s /usr/local/pic/u/ /usr/local/tomcat/webapps/ROOT/u
ln -s /usr/local/pic/cloth/ /usr/local/tomcat/webapps/ROOT/cloth
ln -s /usr/local/pic/html/ /usr/local/tomcat/webapps/ROOT/html

ln -s /usr/local/pic/images/ /usr/local/nginx/html/images
ln -s /usr/local/pic/u/ /usr/local/nginx/html/u
ln -s /usr/local/pic/cloth/ /usr/local/nginx/html/cloth
ln -s /usr/local/pic/html/ /usr/local/nginx/html/html

注:
软连接创建命令: ln -s 目标文件(夹) link文件

tomcat配置:

修改context.xml,在context节点添加allowLinking="true"属性,如下

<Context allowLinking="true">
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值