1. 安装及启动nginx
输入yum install nginx命令进行nginx的安装,当需要确认时输入”y“确认。
yum install nginx
安装完成后,输入service nginx start启动nginx服务。
service nginx start
输入wget http://127.0.0.1测试nginx服务。
wget http://127.0.0.1
2. 安装PHP及相应组件
输入yum install php php-fpm命令进行PHP的安装,当需要确认时输入”y“确认。
yum install php php-fpm
输入service php-fpm start启动php-fpm服务,并使用命令cat /etc/php-fpm.d/www.conf |grep -i 'listen ='查看php-fpm配置。

service php-fpm start

cat /etc/php-fpm.d/www.conf |grep -i 'listen ='
上图可见php-fpm的默认配置的监听端口为9000,现在需要修改配置将php解析的请求转发到127.0.0.0:9000处理即可。
使用命令nginx -t查找nginx配置文件,并使用vi命令修改该配置文件:
nginx -t
vi
/etc/nginx/nginx.conf
在配置文件中找到以下片段,修改红色部分。(按任意键(或者i键)行文本编辑,以“#”开头的为注释行。编辑完成后,按Esc键,在输入:wq,保存并退出)

server {
listen 80;
root /usr/share/nginx/html;
server_name localhost; #charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main; location / {
index index.html index.htm;
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} }
修改后保存,输入service nginx restart重启nginx服务。 service nginx restart 在web目录下创建index.php: vi /usr/share/nginx/html/index.php 用vi命令进行编辑,写入以下信息: Hello World 在浏览器中,访问服务器公网IP+php网页名称查看环境配置是否成功,如果页面可以显示“hello world”,说明配置成功

注意:刚买的阿里云服务器要配置安全组,不然公网在浏览器中打不开

 

最新文章

  1. eclipse for java developer和eclipse for java ee developer的区别
  2. SharePoint 2013 中的 PowerPoint Automation Services
  3. 2016年Java服务器端开发面试总结
  4. RouterOS 软路由开启SSH服务器
  5. 异常System.Web.HttpException (0x80004005): Server cannot set status after HTTP headers have been sent.
  6. java写入文件的几种方法小结
  7. Windows Live Writer的Markdown插件MarkdownInLiveWriter支持语法高亮了
  8. c#:类 相关练习;
  9. Android Paint之 setXfermode PorterDuffXfermode 讲解
  10. c++ 连接数据库
  11. C#按LastID进行分页——与lambda形成链式
  12. oracle语句总结(一)
  13. springboot注解使用说明
  14. 用shell处理以下内容 1、按单词出现频率降序排序! 2、按字母出现频率降序排序! the squid project provides a number of resources toassist users design,implement and support squid installations. Please browsethe documentation and support
  15. C#导出 Excel 时, 生成 CheckBox 控件
  16. xtrabackup备份MySQL并主从同步
  17. C++ CBitmap,HBitmap,Bitmap区别及联系
  18. selenium常用命令
  19. Jrebel不生效的原因和解决办法
  20. POJ 1337 A Lazy Worker(区间DP, 背包变形)

热门文章

  1. json-server(copy)
  2. TLabel的FocusControl属性什麽意思
  3. 00405EB0 mov eax,dword ptr [ecx] 是什么意思?
  4. python接口自动化感悟
  5. [代码]--给GridControl中的某列添加图片
  6. 【Luogu P4074】[WC2013]糖果公园(树上带修改莫队)
  7. Goodbye My Old Days
  8. 个推Node.js 微服务实践:基于容器的一站式命令行工具链
  9. Qt error ------ 'XXX' has not been declared
  10. Access时间日期函数大全