歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux服務器 >> Red hat linux9中的Apache服務器的配置

Red hat linux9中的Apache服務器的配置

日期:2017/3/2 16:54:02   编辑:Linux服務器

在red hat9中自帶了apache2.0
1.httpd:apache2.0
2.httpd-manual:apache2.0手冊


下面是安裝apache2.0方法
//查看系統是否安裝了apache
#rpm -qa|grep httpd
//apache進程名為httpd
//將red hat linux 9的第一個光盤放到光驅後掛裝
#moint /mnt/cdrom
//進入光盤red hat /RPM目錄
#cd /mnt/cdrom/RED HAT/RPMS
//安裝所需的RPM包
#rpm -ivh httpd -2.0.40-21.i386.rpm
#rpm -ivh httpd-manual-2.0.40-21.i386.rpm
//彈出光盤
#cd;eject
安裝光盤後啟動apache服務器
//立即啟動
#service httpd start
//檢測httpd是否被啟動
#pstree|grep httpd
|-httpd---8*[httpd]
//表示已經啟動
//可以用如下的命令查看運行的狀態
#service httpd status
httpd (pid 1880 1879 1878 1877 1878 1877 1876 1875 1874 1873 1870) is running.....
//出現以上類型的提示表示, apache 正在運行
#cd /var/www/html
#mkdir private
#cd private
#touch test
//修改主配置文件
#vi /etc/httpd/conf/httpd.conf
//將/var/www/html/private 目錄訪問權限設為
<Directory "/var/www/html/private">
//允許在.httaccess文件中使用認證和授權指今
AllowOverride AuthConfig
</Directory>
//創建認證的口令文件
#mkdir /var/www/passwd
#cd /var/www/passwd
#htpasswd -c xuhuilong xuhuilong 注意:這個地方的第一個xuhuilong是文件名 第二個的xuhuilong是用戶名 這兩個名字的相同也行 不同也行
New passwd :
Re-type new password:
Adding password for user userxuhuilong
#
//將認證的口今文件的屬主改為apache
#chown apache.apache xuhuilong
#service httpd restart
這樣apache服務器就重新啟動了
//在/var/www/html/private目錄下生成.htaccess 文件
#cd /var/www/html/private
#vi .htaccess
//添加下面內容
AuthType Basic
AuthName "xuhuilong"
AuthUserFile /var/www/passwd/xuhuilong 這裡的xuhuilong是文件名
require vliad-user或xuhuilong都行 這裡的xuhuilong是用戶名xuhuilong

Copyright © Linux教程網 All Rights Reserved