一、安装mysql
1、 sudo apt-get update
2、 sudo apt-get install apt-get nginx
二、安装mysql
1、 sudo apt-get install mysql-server
2、 让mysql创建数据存储目录:sudo mysql_install_db
3、 修改一些不安全的默认配置:mysql_secure_installation
三、安装php5
1、 sudo apt-get install php5-fpm php5-mysql -y
2、 vim /etc/php5/fpm/php.ini里的cgi.fix_pathinfo=1改成cgi.fix_pathinfo=0
3、 重启php进程:sudo service php5-fpm restart
4、 修改本配置文件:sudo vim /etc/nginx/sites-available/default,内容如下:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
server_name server_domain_name_or_IP;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
5、 重启nginx: sudo service nginx restart
四、测试
1、 sudo vim /usr/share/nginx/html/info.php,添加好下内容:
<?php
phpinfo();
?>
2、 访问: http://localhost/info.php
PS:步驟參考自http://www.cnblogs.com/kiscall/p/5561428.html