安裝mysql
sudo apt-get install mysql-server
安裝nginx
sudo apt-get install nginx
安裝php5
sudo apt-get install php5-fpm
sudo /etc/init.d/nginx start 啓動服務,在瀏覽器輸入http://localhost,成功返回頁面則繼續下面配置。失敗的則查看日誌。
service nginx status 可以查看服務狀態。
日誌放置在 /var/log/nginx 裏面。
cat /var/log/nginx/error.log 查看日誌
配置:
gedit /etc/nginx/sites-available/default
server {
listen 80;
# listen [::]:80 default_server ipv6only=on;
root /var/www/;(網站目錄)
index index.html index.htm index.php; (加上index.php)
去掉下面這段話的相應註釋,效果如下:
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
#fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
安裝擴展:
數據庫擴展:sudo apt-get install php5-mysql
curl擴展:sudo apt-get install php5-curl