1、安装apache2
apt-get install apache2
2、配置 Apache2 默认站点
vi /etc/apache2/sites-enabled/000-default
加入一行RedirectMatch ^/$ /apache2-default/
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined RedirectMatch ^/$ /apache2-default/ </VirtualHost>
3、修改 Apache2 主配置
vi /etc/apache2/apache2.conf
要改为:
Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
# Include module configuration: Include /etc/apache2/mods-enabled/*.load Include /etc/apache2/mods-enabled/*.conf
4、httdpd.conf文件添加支持类型
vi /etc/apache2/httdpd.conf
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps