centos6安装nginx
1、获取官方的仓库地址
我们需要先访问nginx的官方网站,获取官方的仓库地址https://nginx.org/en/linux_packages.html#stable
新建/etc/yum.repos.d/nginx.repo 文件
内容为:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=0
enabled=1
2、安装好仓库后可以直接使用yum安装nginx
yum install -y nginx
3、启动nginx
service nginx start
4、查看
netstat -tunlp|grep 80
就可以看到nginx已经启动了80端口的监听。
并且通过浏览器直接访问服务器的ip地址,能看到已经出现了nginx的欢迎页面
5、设置nginx为开机启动
chkconfig nginx on
6、配置nginx使其支持php程序
。创建web目录和文件
我们假设web目录为/var/www,创建并进入这个目录。
mkdir /var/www
cd /var/www
我们新建两个文件,一个html文件,一个php文件,稍后会看到效果。
a.html的内容为:
<h1>Hello World</h1>
b.php的内容为:
<?php
phpinfo();
?>
。变更nginx配置
vim打开nginx第一个站点的配置文件vim /etc/nginx/conf.d/default.conf
将第9行的root变更为我们指定的目录。
修改
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
变更为
location / {
root /var/www;
index index.html index.htm;
}
将30-36行的注释去掉,使其支持php文件,同时还需要修改root和fastcgi_param选项指定我们的工作目录。
修改
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
变更为
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /var/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
include fastcgi_params;
}
保存后,执行service nginx reload重新载入nginx配置。
此时,我们可以通过浏览器直接访问我们刚才建立的文件了。
centos6安装nginx的更多相关文章
- Centos6 安装nginx
一.编译安装nginx 1.安装nginx所需要的库pcre,pcre的全称为:perl compatible regular expression即perl正则表达式,是为了使nginx具备URL重 ...
- 转载《centos6安装nginx最详细步骤》
出处:https://www.cnblogs.com/hltswd/p/6956264.html 第一步:在centos下面下载 nginx wget http://nginx.or ...
- centos6安装nginx最详细步骤
第一步:在centos下面下载 nginx wget http://nginx.org/download/nginx-1.2.9.tar.gz 解压 tar zxf nginx-1. ...
- centos6.3安装nginx
一般使用linux系统的不少网友可能都是直接使用一键安装包进行安装的,以前作者也这样,但是很多时候这些一键安装方便是方便但是可能在升级及其他很多地方不是很好,本文就说下在centos6.3安装ngin ...
- Centos6 下安装Nginx+Mysql+PHP
安装nginx https://segmentfault.com/a/1190000007928556 添加源 $ wget http://nginx.org/packages/centos/6/no ...
- 【CentOS6.5】安装nginx报错:No package nginx available. Error: Nothing to do
今天在给centos6.5安装nginx时候,提示报错No package nginx available. Error: Nothing to do, 后来百度一下,说缺少EPEL(epel是社区强 ...
- centos6.5编译安装nginx
系统64位 centos6.5 nginx官网:http://nginx.org/ 下载nginx源码包: wget http://nginx.org/download/nginx-1.6.2.ta ...
- centos6.5 安装nginx
安装之前先安装VMware tools(方便于从windows上拷贝文件到linux) 1. nginx安装环境 nginx是C语言开发,建议在linux上运行,本次使用Centos6.5作为安装环境 ...
- Centos6.6 编译安装nginx
一.基本环境 nginx 1.9版以后增加了一些新的特性,支持tcp负载均衡,不过这次还是用1.8.0,这里面有个memcached的代理模块,有时间再测试下 1.centos6.6 2.nginx1 ...
随机推荐
- StanFord ML 笔记 第二部分
本章内容: 1.逻辑分类与回归 sigmoid函数概率证明---->>>回归 2.感知机的学习策略 3.牛顿法优化 4.Hessian矩阵 牛顿法优化求解: 这个我就不记录了,看到一 ...
- git 使用教程(二)
MyEclipse下使用GitHub方法(Eclipse同理) 原创 2016年01月04日 20:30:25 标签: myeclipse / 软件 / git / github / eclipse ...
- shell中的时间值提取(date)
shell中的时间值提取(date) 方法1 # date +%F # date +%T # cat time.sh #!/bin/bash DATE=`date +%F | sed 's/-//g' ...
- <spark> ~/spark/conf/spark-default.conf 配置文件
因为看到我参考的Hadoop/spark集群搭建的文档中的都没有对 /spark-default.conf 的配置 合理地对 /spark-default.conf 进行配置,能够提高执行效率 -- ...
- anchor values list
- 16.Ubuntu安装mysql及win7安装mysql
Ubuntu: 链接地址:https://www.cnblogs.com/logaa/p/6791819.html win7: 链接地址:https://jingyan.baidu.com/artic ...
- ubuntu 14.04 安装 Apache Thrift 0.10
1.到官网下载源码压缩文件 https://thrift.apache.org/download 2.安装依赖软件,可以参考 https://thrift.apache.org/docs/instal ...
- php单图片上传。
1.input:file form 提交 /** * 用户头像上传 * @param [type] $file 图像信息 */ function domeadd($file){ if (is_arra ...
- Android 异步消息处理机制 让你深入理解 Looper、Handler、Message三者关系
转自:http://blog.csdn.net/lmj623565791/article/details/38377229 ,本文出自[张鸿洋的博客] 很多人面试肯定都被问到过,请问Android中的 ...
- docker tomcat镜像制作
推荐使用dockerfile(本文直接拉取tomcat需要进入容器自行安装vim):docker利用Dockerfile来制作镜像 1.查找Docker Hub上的tomcat镜像 [root@loc ...