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 -zxvf
apache-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
<Host name="foods.xustiot.com" appBase=="/var/www"
unpackWARs="true" autoDeploy="true" >
<Context path="/" docBase="food" debug="0" reloadable="true" crossContext="true">
</Context>
</Host>
<Host name="app.xustiot.com" appBase=="/var/www"
unpackWARs="true" autoDeploy="true" >
<Context path="/" docBase="test" debug="0" reloadable="true" crossContext="true">
</Context>
</Host>
//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;
}
}
重启所有服务