如何搭建linuxweb伺服器
Ⅰ 我裝了虛擬機是linux系統,想把它設置成一個web伺服器,放一些網頁,便於一些實踐,希望各位能夠說的詳細
web服務:你需要搭建一個apache服務或者是httpd服務,二選一
apache服務搭建過程:
解壓:tarzxvfhttpd-2.0.63.tar.gz
進入解壓後的目錄:cdhttpd-2.0.63
安裝前編譯:./configure–prefix=/usr/local/apache(自定義路徑)
編譯後:安makemakeinstall
進入自定義目錄:cd/usr/local/apache/bin
開啟ApachewebServer:./apachectlstart
httpd服務搭建過程
一、手動安裝httpd所需的包或著用yuminstallhttpd
postgresql-libs-8
apr-1.2.7.11.i386
apr-util-1.2.7-6.i
httpd-2.2.3-11.e15
Ⅱ 怎麼搭建一個可以被外網訪問的linux web伺服器
首先需要將你的web伺服器搭建好,然後需要做NAT,我這里有我的一個做NAT的筆記,分享給你
NAT
拓撲結構圖:
要求:
1.內網能夠ping通外網地址,並且成功訪問外網中的web服務;
2.外網能夠訪問內網的ftp服務。
步驟:
一:內網伺服器配置
1.在內網中設置好ip地址,網關和DNS均為NAT伺服器內網口地址,並搭建好ftp服務,此處略
二:NAT伺服器配置
1.在NAT只能中添加一塊網卡作為 外網卡,並設置好ip地址
2.開啟NAT伺服器的路由功能
[root@c2 ~]# vi /etc/sysctl.conf
net.ipv4.ip_forward = 1 //將0改為1
[root@c2 ~]# sysctl -p //永久生效
3.配置防火牆(必須按照以下循序配置,否則配置完成後不能拼通外網,需配置第二次)
#iptables-X
#iptables-t nat -X
#iptables --flush
#iptables -t nat --flush
//以上為重置鏈表的命令
#iptables-t nat -A POSTROUTING -s 192.168.1.0/24 -o eth1 -j SNAT --to 202.10.10.12
//這條命令是將內網192.168.1.0/24的源地址映射為NAT伺服器的外網口地址,eth1為外網卡
# iptables -t nat -A PREROUTING -p tcp--dport 21 -j DNAT --to 192.168.1.11
# iptables -t nat -A PREROUTING -p tcp--dport 20 -j DNAT --to 192.168.1.11
//這兩條命令是發布內務的ftp服務
或者:
# iptables -t nat -A PREROUTING -p tcp -d 202.10.10.12--dport 21 -j DNAT --to 192.168.1.11
# iptables -t nat -A PREROUTING -p tcp -d 202.10.10.12--dport 20 -j DNAT --to 192.168.1.11
#/etc/init.d/iptablessave
#/etc/init.d/iptablesrestart
驗證:
內網訪問外網的web服務:
[root@c1 ~]# curl 202.10.10.13
web
外網訪問內網的ftp服務(外網的防火牆一定要關閉,否則ls查看目錄時會出錯,或者打開外網的20號埠新建鏈接的也可以)#
[root@c3 ~]# ftp 202.10.10.12
Connected to 202.10.10.12 (202.10.10.12).
220 (vsFTPd 2.2.2)
Name (202.10.10.12:root): ftp01
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode(192,168,1,11,93,1).
ftp: connect: Network isunreachable //列不出內容是因為進入了passive模式
ftp>passive //用passive命令切換passive模式和active模式
Passivemode off.
ftp> ls
200 PORT command successful. Consider usingPASV.
150 Here comes the directory listing.
226 Directory send OK.
ftp>
補充:
刪除防火牆中配置的記錄
[root@c2 ~]# iptables -t nat -L POSTROUTING -n --line-number //列出記錄和記錄序號
[root@c2 ~]# iptables -t nat -D POSTROUTING1 //根據序號刪除記錄
你將內網的ftp服務換成web服務就可以了,主要是弄懂NAT的原理,將內部服務通過DNAT發布到外網
Ⅲ 如何使用Linux+Oracle+tomcat搭建web伺服器
安裝linux操作系統,安裝jdk,安裝tomcat配置環境變數,更改tomcat配置文件,寫入資料庫連接信息,比如:
通過tomcat連接192.168.1.100上的oracle資料庫,其中sid為orcl
[tomcat@localhost classes]# pwd
/home/tomcat/apache-tomcat-6.0.1/webapps/***/WEB-INF/classes
[tomcat@localhost classes]# vim hibernate.properties
jdbc.url=jdbc:oracle:thin:@192.168.1.100:1521:orcl
Ⅳ Linux怎麼搭建Web伺服器
Linux系統使用AMH就可以簡單方便的搭建web伺服器
一、使用xshell登錄linux伺服器
至此,在linux下的web伺服器已經安裝完成