• 安装nginx

apt-get install nginx
  • 配置nginx

位置: /etc/nginx/nginx.conf  ,其中包含了

include /etc/nginx/conf.d/*.conf;  

include /etc/nginx/sites-enabled/*;

在这两个配置中的文件也是生效的。

错误日志  error_log /var/log/nginx/error.log; ,这个非常实用,在后面的配置完成重启后,可以通过此日志来快速排错。

这里,我们把配置文件放在  /etc/nginx/sites-enabled/default; 中。

index index.php index.html index.htm;

...

location ~\.php$ {
try_files $uri = ;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
include fastcgi_params;
}

保存文件,使配置文件生效

/etc/init.d/nginx reload

nginx相关命令

service nginx start
service nginx stop
service nginx restart

在  /usr/share/nginx/html 下新建index.php

<?php
phpinfo();
  • 安装PHP

sudo apt-get install php5-fpm
sudo apt-get install php5-gd # Popular image manipulation library; used extensively by Wordpress and it's plugins.
sudo apt-get install php5-cli # Makes the php5 command available to the terminal for php5 scripting
sudo apt-get install php5-curl # Allows curl (file downloading tool) to be called from PHP5
sudo apt-get install php5-mcrypt # Provides encryption algorithms to PHP scripts
sudo apt-get install php5-mysql # Allows PHP5 scripts to talk to a MySQL Database
sudo apt-get install php5-readline # Allows PHP5 scripts to use the readline function
  • 配置php监听端口

位置: /etc/php5/fpm/pool.d/www.conf

把 listen = /var/run/php5-fpm.sock 改为:
listen = 127.0.0.1:9000

查看php运行进程

ps -waux | grep php5

php启动相关命令

service php5-fpm stop
service php5-fpm start
service php5-fpm restart
service php5-fpm status

重启php进程,访问查看效果

curl http://localhost

若是不生效,可通过查看/var/log/nginx/error.log 日志来定位

参考文档:https://www.cnblogs.com/Bonker/p/4252588.html

最新文章

  1. 版本控制简介,git使用----使用GitHub托管代码
  2. windows下在文件夹中快速启动cmd
  3. 安装 gcc-c++ 时报错和原有 gcc 版本冲突
  4. css3中变形与动画(二)
  5. linux的命令
  6. C#压缩加密和vb压缩加密
  7. iOS xcode 8 注释快捷键
  8. 根据权限显示隐藏SharePoint 2010快速启动栏的链接
  9. 【转】Perl Unicode全攻略
  10. 使用Libmicrohttpd搭建内嵌(本地)服务器
  11. SDWebImage 加载显示 WebP 与性能问题
  12. 虚拟机与Docker有何不同
  13. Servlet案例6:显示用户的上次访问时间
  14. zjoi2010基站选址
  15. python threading模块2
  16. mvc 分部视图(Partial)显示登陆前后变化以及Shared文件夹在解决方案资源管理器中没有显示的问题
  17. VS2010已停止工作,framework 4.0安装失败
  18. JPA中的Page与Pageable
  19. 解决PHPWind局域网不能访问问题
  20. android studio 安卓工作室 汉化完整版

热门文章

  1. CSS:清除浮动
  2. Eclipse中文乱码问题
  3. 并不对劲的bzoj3994:loj2185:p3327[SDOI2015]约数个数和
  4. 【CQ18阶梯赛第8场】题解
  5. 05:LGTB 与偶数
  6. JAVA泛型与可变参数
  7. [angularJS]ng-hide|ng-show切换
  8. java链接sqlserver数据库
  9. 025--python初识类和对象
  10. Android中shape的使用 (转载)