· learnings  · 2 min read

Linux学习日志 Ⅷ

设置apache web server
***************************************************************************
设置文件存放在/etc/httpd/conf/httpd.conf, 里面由Global, Main, Virtual Host三部分组成。

web server存放网页的主文件夹是/var/www/html

httpd.conf
DirectoryIndex 设置主页文件名。(Ex. default.html)
***************************************************************************

设置多用户网络服务器:
1.在用户目录下/home/,创建public_html,并且给足权限,755一般就没有问题的。
2.编辑/etc/httpd/conf/httpd.conf

程序代码 程序代码

<Directory /home/*/public_html>
    Option –ExecCGI +FollowSymlink +Indexes
    AllowOveride None
    Order allow,deny
    Allow from all

ExecCGI – permit cgi script
FollowSymlink – any symbolic links will successfully point to the relevant web page
Indexes – enable a directory listing
AllowOveride (All/None) – allow/ignore .htaccess
Order allow,deny – access control

***************************************************
如果要用cgi,
1.添加 ExecCGI,
2.添加AddHandler cgi-script.cgi

如果用.htaccess来控制
1.添加 AllowOveride All
2.创建.htaccess文件

程序代码 程序代码

AuthType Basic
AuthName “ “
AuthUserFile
AuthGroupFile
Require valid-user
Require group
------------------------------------ *
Allow from
Deny from
Satisfy all
Satisfy any
------------------------------------

3.建立网络用户在.htpasswd里
Htpasswd –c .htpasswd

4.创建组文件.htgroup
添加webgroup:

***************************************************
添加 userDir public_html, 去掉userDir Disable

3.service httpd restart

*****************************************
添加虚拟主机:
编辑/etc/httpd/conf/httpd.conf

程序代码 程序代码

<VirtualHost IP:PORT>
ServerName syanix.com
DocumentRoot /home/syanix

如果要用SSL的话,需要distcache, mod_ssl两个包
设置文件在/etc/httpd/conf.d/ssl/conf
Listen 433
DocumentRoot <…>
ServerName <…>

建立证书
/etc/pki/tls/certs
Make localhost.key
Make.crt
Make testcert

绑定域名到本地
编辑/etc/hosts
*****************************************

    Share:
    Back to Blog