tomcat8 集成php 环境,CentOS 7 nginx php7 jdk1.8 tomcat8环境搭建

1.nginx安装

编译环境:

yum install gcc gcc-c++ autoconf -y

nigix依赖:

yum install openssl openssl-devel zlib zlib-devel libxml2 libxml2-devel pcre-devel -y

出现openssl not used ,查询openssl的安装位置 rpm -ql openssl

--with-openssl=**

进入sbin中启动nginx    ./nginx

2.php7安装

依赖:

yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel

ps -ef | grep nginx

kill pid

systemctl restart php-fpm.service

3.安装jdk

wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.tar.gz

tar -zxvf file -C /home //-C大写 解压到指定目录

打开/etc/profile(nano /etc/profile)

在最后面添加如下内容:

JAVA_HOME=/usr/local/jdk1.8

JRE_HOME=/usr/local/jdk1.8/jre

CLASSPATH=.:$JRE_HOME/lib:$JAVA_HOME/lib/tools.jar

PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

export JAVA_HOME CLASSPATH PATH JRE_HOME

让系统重新加载该文件:source /etc/profile

4.安装tomcat

wget http://apache.fayea.com/tomcat/tomcat-8/v8.5.4/bin/apache-tomcat-8.5.4.tar.gz

解压 tar -zxvfapache-tomcat-8.5.4.tar.gz

mv apache-tomcat-8.5.4 /usr/local/tomcat8

到tomcat8/bin      ./startup.sh    启动

tomcat URL中文编码 出现乱码(?号)

原因:linux的默认编码不兼容中文,修改系统编码为utf-8即可解决问题

1. vi /etc/profile

2. 在文件最后加上

export LC_ALL="zh_CN.UTF-8"

export LANG="zh_CN.UTF-8"

3. source /etc/profile使文件立即生效

4. echo $LANG 显示默认编码

1.整合php

server {

listen 80;

server_name blog.xustiot.com;

root /var/www/blog;

index index.php index.html index.htm;

charset utf-8;

location ~ \.php($|/) {

set $script $uri;

set $path_info "";

if ($uri ~ "^(.+\.php)(/.+)"){

set $script $1;

set $path_info $2;

}

fastcgi_pass 127.0.0.1:9000;

include fastcgi_params;

fastcgi_param PATH_INFO $path_info;

fastcgi_param SCRIPT_FILENAME $document_root$script;

fastcgi_param SCRIPT_NAME $script;

}

}

//支持pathinfo

2.整合tomcat

tomcat启动卡住

将$JAVA_HOME/jre/lib/security/java.security内,将securerandom.source的内容改为file:/dev/./urandom即可

linux或者部分unix系统提供随机数设备是/dev/random 和/dev/urandom ,两个有区别,urandom安全性没有random高,但random需要时间间隔生成随机数。

可能在生成随机数的时候卡住了,导致tomcat启动不了

在服务器启动时也可以加上参数 -Djava.security.egd=file:/dev/./urandom

//server.xml

unpackWARs="true" autoDeploy="true" >

unpackWARs="true" autoDeploy="true" >

//nginx.conf

server {

listen 80;

server_name foods.xustiot.com;

root /var/www/food;

index index.jsp index.html index.htm;

charset utf-8;

location ~ \.(jsp|jspx|do){

proxy_set_header Host $host;

proxy_set_header X-Forwarded-For $remote_addr;

proxy_pass http://127.0.0.1:8080;

}

}

server {

listen 80;

server_name app.xustiot.com;

root /var/www/test;

index index.jsp index.html index.htm;

charset utf-8;

location ~ \.(jsp|jspx|do){

proxy_set_header Host $host;

proxy_set_header X-Forwarded-For $remote_addr;

proxy_pass http://127.0.0.1:8080;

}

}

重启所有服务

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值