Apache @ Linux&FreeBSD Setup
1. Linux Setup
1.1 Installation
wget -P tar/ http://apache.justdn.org/httpd/httpd-2.X.XX.tar.bz2tar jxvf tar/httpd-2.X.XX.tar.bz2
cd httpd-2.X.XX
./configure --prefix=/usr/local/apache
make -j 10
make install
1.2 Config setting
cp support/apachectl /etc/init.d/httpd
chmod 755 /etc/init.d/httpd
Add following to the head "/etc/init.d/httpd" : 修改/etc/init.d/httpd:前面几行改成如下样子.
1 2 3 4 5 6 7 | # Startup script for the Apache Web Server # chkconfig: 35 85 15 # description: Apache is a World Wide Web server. It is used to serve \ # HTML files and CGI. # processname: httpd # pidfile: /usr/local/apache/log/httpd.pid # config: /usr/local/apache/conf/httpd.conf |
Run
chkconfig --add httpd
Configuration "/usr/local/apache/conf/httpd.conf"
ServerName yourservername.yourdomainname:80
#在/root/.bash_profile 中的PATH****后加上:/usr/local/apache/bin
2. 用Apache的.htaccess文件增加用户认证
1 2 3 4 5 6 7 | Alias /test"/var/www/test" <Directory "/var/www/test"> Options Indexes MultiViews AllowOverride AuthConfig #表示进行身份验证 Order allow,deny Allow from all </Directory> |
3.名字型虚拟主机
1 2 3 4 5 6 7 8 9 10 11 | NameVirtualHost 61.152.210.22 <VirtualHost 61.152.210.22> ServerAdmin eric@bizeasy.cn ServerName www.bizeasy.cn DocumentRoot /home/eric/public_html/igenus </virtualHost> <VirtualHost 61.152.210.22> ServerAdmin eric@dyzq.com ServerName mail.dyzq.com DocumentRoot /usr/local/httpd/htdocs/ </virtualHost> |
4.Other
在这里,最好是在apache的配置中增加默认文件类型的cache机制,即利用apache的expires模块,新增类似如下几行:
1 2 3 4 5 6 7 | ExpiresActive On ExpiresByType text/html "access plus 10 minutes" ExpiresByType text/css "access plus 1 day" ExpiresByType image/jpg "access 1 month" ExpiresByType image/gif "access 1 month" ExpiresByType image/jpg "access 1 month" ExpiresByType application/x-shockwave-flash "access plus 3 day" |
5.Install Apache HTTP Server 2.20 by using FreeBSD (Ports)
5.1
cd /usr/ports/www/apache22
make install clean
5.2
//A Apache HTTP Server script apache22.sh is located at /usr/local/etc/rc.d to provide Apache HTTP Server start and shutdown service. To enable Apache web server to automatically starts whenever after server reboots, issue the following command at CLI:
echo 'apache22_enable="YES"' >> /etc/rc.conf
//To start Apache HTTP web server immediately, use:
/usr/local/sbin/apachectl start
//OR
/usr/local/etc/rc.d/apache22 start
5.3 Apache installation DONE.
The freebsd apache22 httpd.conf location: /usr/local/etc/apache22/httpd.conf
| -欢迎为本文评级 |
相关日志 |
本文读者也关心以下内容:
|















































Leave a reply