1.安装Nginx
sudo add-apt-repository ppa:nginx/stable //add nginx source sudo apt-get update //update source sudo apt-get install nginx // install
有用的命令:
启动Nginx:sudo /etc/init.d/nginx start 关闭Nginx:sudo /etc/init.d/nginx stop 重启Nginx:sudo /etc/init.d/nginx restart
2.安装PHP
sudo apt-get install php5-cli php5-cgi php5-fpm php5-mcrypt php5-mysql
3. 配置Nginx
sudo vim /etc/nginx/sites-available/default index那行改为:“index index.html index.htm index.php;” 去掉以下行的注释: location ~ .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; }
设置根目录:
sudo mkdir /var/www/
sudo vim /etc/nginx/sites-avaliable/default
把root更改为"root /var/www;"
4.测试
在/var/www/下建立test.php文件,输入如下内容:
<?php phpinfo();?>
在浏览器中输入:http://localhost/test.php