国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網(wǎng)站 > Nginx > 正文

Linux下Tomcat+Nginx服務器環(huán)境安裝配置的簡明教程

2024-08-30 12:26:07
字體:
供稿:網(wǎng)友

一、安裝
1.安裝JDK
下載的jdk文件為:jdk-6u45-linux-x64.bin,執(zhí)行如下命令進行安裝:

#./jdk-6u12-linux-i586.bin

2.安裝tomcat:

#tar zxvf apache-tomcat-6.0.18.tar.gz#mv apache-tomcat-6.0.29 tomcat

這里我將解壓后的apache-tomcat-6.0.29重命名為了tomcat方便操作。

3.配置環(huán)境變量:
編輯/etc下的profile文件,加上如下內(nèi)容:

JAVA_HOME="/opt/app/jdk1.6.0_45"CLASS_PATH="$JAVA_HOME/lib:$JAVA_HOME/jre/lib"PATH=".:$PATH:$JAVA_HOME/bin"CATALINA_HOME="/opt/app/tomcat"export JAVA_HOME CATALINA_HOME

執(zhí)行下面命令使變更生效:

# source /etc/profile

啟動tomcat并輸入http://domain:8080,如果看到貓的頁面即tomcat和jdk安裝成功
新建文件目錄/home/www為網(wǎng)站存放目錄,設置server.xml文件,在Host name=”localhost”處將appBase=的指向路徑改為/home/www/web
創(chuàng)建index.jsp至/home/www/web/ROOT,內(nèi)容為:“hello!”  重新啟動tomcat,重新訪問,如果看到index.jsp文件內(nèi)容hello!表示設置成功。

4.安裝Nginx
執(zhí)行如下命令解壓nginx:

# tar zxvf nginx-1.4.4.tar.gz# mv nginx-1.4.4 nginx

同樣重命名了一下。
安裝nginx:

# ./configure --prefix=/opt/app/nginx

結(jié)果出現(xiàn)了錯誤:error: C compiler cc is not found,按網(wǎng)上所說安裝編譯源碼所需的工具和庫:

#yum install gcc gcc-c++ ncurses-devel perl

再次安裝,發(fā)現(xiàn)還有錯誤:the HTTP rewrite module requires the PCRE library.
執(zhí)行

# yum -y install pcre-devel openssl openssl-devel

終于成功,

# ./configure --prefix=/opt/app/nginx# make# make install

nginx安裝成功后的安裝目錄為/opt/app/nginx

二、Nginx方面的配置
在/usr/local/目錄下分別安裝nginx和tomcat
為nginx添加conf.d目錄,用于各項目的配置,比如新建renhetoutiao.conf文件

server {  listen   80;  server_name devtoutiao.renhe.cn;  root    /home/renhetoutiao/renhetoutiao/htdocs;  access_log /home/renhetoutiao/renhetoutiao/logs/access_log.log;   location = / {    rewrite ^/$ /index.shtml last;  }   location ~ .shtml {    proxy_pass http://localhost:8081;    proxy_set_header  Host  $host;    proxy_set_header  X-Real-IP  $remote_addr;    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;  }   location ~ .*.(js|css)?$ {    expires 1h;  }}server {  listen   80;  server_name devtoutiao.renhe.cn;  root    /home/renhetoutiao/renhetoutiao/htdocs;  access_log /home/renhetoutiao/renhetoutiao/logs/access_log.log;   location = / {    rewrite ^/$ /index.shtml last;  }   location ~ .shtml {    proxy_pass http://localhost:8081;    proxy_set_header  Host  $host;    proxy_set_header  X-Real-IP  $remote_addr;    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;  }   location ~ .*.(js|css)?$ {    expires 1h;  }}            
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 佛冈县| 木兰县| 揭阳市| 麟游县| 肃南| 麟游县| 高要市| 杨浦区| 陆良县| 霞浦县| 隆安县| 蒙阴县| 阳信县| 长汀县| 定陶县| 安国市| 瑞昌市| 普陀区| 独山县| 阳新县| 绥棱县| 区。| 佛山市| 永德县| 太谷县| 曲阜市| 瑞昌市| 鹰潭市| 鲁山县| 黄石市| 濉溪县| 南城县| 龙州县| 兴义市| 枝江市| 雷波县| 泉州市| 古蔺县| 镇安县| 交口县| 乌拉特前旗|