1.安装apache2
sudo apt-get install apache2
2.安装php
sudo apt-get install libapache2-mod-php5
sudo apt-get install php5
3.安装sql服务器
sudo apt-get install mysql-server
sudo apt-get install php5-mysql
5.修改web目录权限
chown -R www-data:www-data /var/www
6.在/var/www新建目录niot,并将网站内容全部放到此目录
7.在/etc/apache2/sites-available/目录下建立文件niot.conf,内容如下:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
RewriteEngine On
RewriteOptions Inherit
DocumentRoot /var/www/niot
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/niot>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
8.建立配置文件软链接并删除默认有效配置:
sudo ln -s /etc/apache2/sites-available/niot.conf /etc/apache2/sites-enabled/niot.conf
sudo rm /etc/apache2/sites-available/000-default.conf(任何非niot.conf的其他文件)
9. 使apache支持 rewrite 模块(去掉index.php)
sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
10. 添加 rewrite 规则 (网站根目录的 .htaccess 文件)
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index.php|images|robots.txt)
RewriteRule ^(.*)$ /bill/index.php/$1 [L]
11.重启apache
sudo /etc/init.d/apache2 restart