1、如何設置Apache通過域名訪問我的應用?已經有了域名
1
2、Apache如何實現頂級域名跳轉到www子域名
?
3、apache解析兩個域名訪問同一個項目的不同頁面
ServerName 你第一個域名RewriteEngine OnRewriteRule index.htm 你第一個需要訪問的頁面</VirtualHost<VirtualHost *:80DocumentRoot "你網站存放的路徑"ServerName 你第二個域名RewriteEngine OnRewriteRule index2.htm 你第二個需要訪問的頁面
4、求助,Apache上放多個域名卻自動跳轉到同一個網站
echo "NameVirtualHost *:80">>/etc/httpd/conf/httpd.conf
/etc/init.d/httpd restart
5、apache 404 錯誤可以根據域名來跳轉
修改httpd.conf對虛擬主機的目錄打開
AllowOverride All
然後在目錄里放一個.htaccess
配置errorDocument 404 /errror.html(error.html 必須大於512B,否則apache忽略)
6、如何配置apache使不同域名轉到不同埠
在Apache官網下載最新版本的Apache軟體,並上傳到伺服器中文件夾下。
2
解壓縮Apache的壓縮包到本地。
命令:tar -zxvf httpd-2.4.25.tar.gz
3
輸入命令:cd httpd-2.4.25,進入解壓好的安裝包內
4
輸入: ./configure
這是對對即將安裝的進行配置。
5
如果出現
checking for APR... no
configure: error: APR not found. Please read the documentation.
報錯說明你的伺服器中沒有安裝APR。下面就重新安裝APR。
6
wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz
wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip
在命令行中依次輸入以上命令下載安裝包。
7
輸入命令:tar -zxvf apr-1.4.5.tar.gz
解壓安裝包。
8
依次輸入命令:
cd apr-1.4.5
./configure --prefix=/usr/local/apr
9
輸入:
make && make install
進行安裝
10
回到apr-util-1.3.12.tar.gz所在的目錄後
輸入:tar -zxvf apr-util-1.3.12.tar.gz
解壓安裝文件
11
輸入:
cd apr-util-1.3.12
./configure --with-apr=/usr/local/apr
12
輸入:make && make install
進行安裝軟體
13
回到pcre-8.10.zip所在的文件夾下
輸入:unzip -o pcre-8.10.zip
進行解壓
依次輸入:
cd pcre-8.10
./configure --prefix=/usr/local/pcre
make && make install
如果此時出現如下錯誤時
make[1]:***[pcrecpp.lo]錯誤1
make[1]:Leaving directory /data/soft/nginx/pcre-8.30
make:***[all]錯誤2
就輸入一下代碼安裝C++即可
yum -y install gcc-c++
然後進入Apache壓縮包的所在目錄
依次輸入:
cd httpd-2.4.25
./configure
輸入:
make && make install
進行安裝apache軟體
cd /usr/local/apache2/bin/
./apachectl start
啟動apache
當出現
AH00558: httpd: Could not reliably determine the server'sfully qualified domain name, using localhost.localdomain. Set the 'ServerName'directive globally to suppress this message
或
Starting httpd: httpd: apr_sockaddr_info_get() failed forMYHOST
先將apache服務停止,在/usr/local/apache2/bin/下 ./apachectl stop
然後切換到配置文件目錄
cd ../conf
將httpd.conf備份一下(防止寫錯造成不可恢復的錯誤)
cp httpd.conf /usr/local/apache2/conf/httpCopy.conf
備份完後就可以編輯該配置文件了(如果你覺得你不會搞錯什麼的,可以不備份)
找到ServerRoot "/usr/local/apache2"
在下面添加
ServerName localhost:80(不修改也是可以的,只是啟動的時候會出現以上的警告,看著煩,實際不會有啥影響)
cd ../bin
啟動apache
./apachectl start
訪問頁面
http://伺服器ip地址/
當出現下面的界面,則標識apache伺服器安裝成功