tomcat+nginx+mysql+jdk 环境搭建

1、安装JDK 

rzsz 上传到服务器安装 jdk 7u55

2、安装tomcat

下载tomcat 7 

http://apache.fayea.com/tomcat/tomcat-7/v7.0.61/bin/apache-tomcat-7.0.61.tar.gz

3、安装nginx

nginx 安装依赖一下三个包

3.1  openssl-1.0.1c.tar.gz   

http://www.openssl.org/source/openssl-1.0.2a.tar.gz

3.2  pcre-8.36.tar.gz   需要安装依赖包  yum install -y gcc gcc-c++ 

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz

3.3  zlib-1.2.8.tar.gz

http://zlib.net/zlib-1.2.8.tar.gz

3.4  yum install mhash、yum install zlib-devel 

3.5  ./configure   /configure --prefix=/usr/local/nginx/  --with-http_stub_status_module --with-http_ssl_module --with-openssl=/usr/local/nginx/soft/openssl-1.0.1c (指定openssl 库的路径) --with-pcre=../soft/pcre-8.21 --with-zlib=../soft/zlib-1.2.8

groupadd -r nginx
useradd -r -g nginx -s /bin/false -M nginx

#注意  前面至少一个有空格
./configure --sbin-path=/usr/local/nginx/nginx 
--conf-path=/usr/local/nginx/nginx.conf 
--pid-path=/usr/local/nginx/nginx.pid 
--with-http_ssl_module 
--with-pcre=../pcre-8.21   #指向解压的源码目录
--with-zlib=../zlib-1.2.8     #指向解压的源码目录
--with-openssl=../openssl-1.0.1  #指向解压的源码目录
--with-http_stub_status_module #启用 nginx 的 NginxStatus 功能,用来监控 Nginx 的当前状态
--user=nginx 
--group=nginx

make && make install 

3.6 启动nginx  服务   /usr/local/nginx/nginx/sbin/nginx -c /usr/loacl/nginx/nginx/conf/nginx.conf (/usr/local/nginx/nginx 是nginx的安装目录)

  重新加载nginx 服务 /usr/local/nginx/nginx/sbin/nginx -s reload 

  ------------------------------------------------------------------------------------

nginx 下载地址:http://nginx.org/download/nginx-1.7.12.tar.gz

  

server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root /usr/local/tomcat/apache-tomcat-7.0.59/webapps/ROOT;(tomcat web存放文件夹)
index index.html index.htm index.jsp;
}

#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;
#}
location ~ .jsp$ {
proxy_pass http://127.0.0.1:8080;(nginx 代理tomcat 8080 端口)

}

---------------------------------------------------------------

   /usr/local/nginx/sbin/nginx -t  检查 nginx.conf 配置文件是否正确

4、安装mysql

 安装rpm Mysql-server 5.5 ; Mysql-client 5.5

http://mirrors.sohu.com/mysql/MySQL-5.5/MySQL-devel-5.5.41-1.linux2.6.x86_64.rpm

http://mirrors.sohu.com/mysql/MySQL-5.5/MySQL-server-5.5.41-1.linux2.6.x86_64.rpm

http://mirrors.sohu.com/mysql/MySQL-5.5/MySQL-client-5.5.41-1.linux2.6.x86_64.rpm

/etc/init.d/mysql start (启动mysql)

/usr/bin/mysqladmin -u root   password 'create password' 创建root 密码

/usr/bin/mysqladmin -u root  -p 'old password' password 'create new password' 更改新密码;

mysql 数据库初始化  mysql_install_db

原文地址:https://www.cnblogs.com/zhzhao/p/4391371.html