最近指想服务器跑静态文件,所以想单独配置个nginx的webserver,然而并不是我想象的那么简单,使用rpm包来安装会发生很多软件依赖的错误;

当我尝试使用yum安装nginx的时候,总是提示未找到nginx包,最终yum update
解决问题。

安装nginx

yum update

wget
http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/x86_64/epel-release-5-4.noarch.rpm

wget
http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/x86_64/ius-release-1-4.ius.el5.noarch.rpm

rpm -Uvh
epel-release*.rpm ius-releas*.rpm

yum -y install nginx

chkconfig nginx on

#chkconfig --levels 235 nginx on

/etc/init.d/nginx start

nginx根目录

/usr/share/nginx/html

由于现在的webserver不可能只是跑静态文件,索性安装了php

yum -y install lighttpd-fastcgi php-cli php-mysql php-gd php-imap
php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring
php-mcrypt php-mssql php-snmp php-soap php-tidy

配置php fastcGI

vi /etc/php.ini

最后添加

cgi.fix_pathinfo = 1

启动php fastcGI守护进程,并以用户组nginx和用户nginx身份运行

/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u nginx -g nginx -f
/usr/bin/php-cgi -P /var/run/fastcgi-php.pid

开机启动fastcgi

vi /etc/rc.local

/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u nginx -g nginx -f
/usr/bin/php-cgi -P /var/run/fastcgi-php.pid

修改nginx配置文件,添加fastcgi支持

vi /etc/nginx/nginx.conf

#去掉下面几行的注释

location ~ \.php$ {

***

fastcgi_param  SCRIPT_FILENAME
 $document_root$fastcgi_script_name;

#$document_root:/usr/share/nginx/html

include     
  fastcgi_params;

}

/etc/init.d/nginx restart

安装mysql

yum -y install mysql mysql-server

chkconfig --levels 235 mysqld on

/etc/init.d/mysqld start

设置mysql密码及相关设置

mysql_secure_installation

第一次启动上述命令,根据提示操作,直接回车即可。

通过yum安装nginx-mysql-php-fastcgi配置LNMP的更多相关文章

  1. centos6.4 yum安装nginx+mysql+php

    1.配置防火墙,开启80端口.3306端口vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport ...

  2. linux CentOS YUM 安装 nginx+tomcat+java+mysql运行环境

    Java环境配置 1 安装JDK 查看CentOS自带JDK是否已安装 1 [root@test ~]# yum list installed |grep java 若有自带安装的JDK,应如下操作进 ...

  3. [转]CENTOS 6.5 配置YUM安装NGINX+服务器负载均衡

    原文连接: CENTOS 6.5 配置YUM安装NGINX  http://blog.sina.com.cn/s/blog_69f467b70102uyux.html 参考博文: Centos下安装. ...

  4. CentOS 6.7下配置 yum 安装 Nginx

    CentOS 6.7下配置 yum 安装 Nginx. 转载:http://www.linuxidc.com/Linux/2016-07/133283.htm 第一步,在/etc/yum.repos. ...

  5. yum安装nginx,配置资源访问出现403Forbidden问题

    使用yum安装nginx后除了nginx自带页面其他配置页面都是403forbidden问题. 暂时的解决办法是,修该nginx配置文件中的user为root , 然后关闭seliunx或者添加ngi ...

  6. centos7.2环境nginx+mysql+php-fpm+svn配置walle自动化部署系统详解

    centos7.2环境nginx+mysql+php-fpm+svn配置walle自动化部署系统详解 操作系统:centos 7.2 x86_64 安装walle系统服务端 1.以下安装,均在宿主机( ...

  7. yum安装nginx

    1.在/etc/yum.repos.d/目录下创建一个源配置文件ngxin.repo: cd /etc/yum.repos.d/ vim nginx.repo 填写如下内容: [nginx] name ...

  8. nginx上用fastcgi配置python环境

    费了2天的功夫,翻阅了无数的中文.英文资料,终于搞定.写下此文留待以后翻阅用      本文环境,centOS 5.4 ,Nignx-0.8.49, Python 2.6.5   ========== ...

  9. CentOS7 安装Nginx+MySQL

    首先我们需要安装nginx的yum源 [root@AD ~]# rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-releas ...

  10. Linux yum 安装 Nginx

    搭建 Nginx 静态服务器 安装 Nginx 使用 yum 安装 Nginx: yum install nginx -y 修改 /etc/nginx/conf.d/default.conf,去除对 ...

随机推荐

  1. LoadRunner使用之变量关联

    性能测试LR小结之参数关联(LoadRunner11.0) 关联对于LR是经常需要用到的,本章使用简单登录来介绍关联功能. 1.       Q:何为关联? 所谓的关联就是把脚本中某些写死的代码(ha ...

  2. java提高篇---ArrayList

    一.ArrayList概述 ArrayList是实现List接口的动态数组,所谓动态就是它的大小是可变的.实现了所有可选列表操作,并允许包括 null 在内的所有元素.除了实现 List 接口外,此类 ...

  3. uafxcwd.lib(afxmem.obj) : error LNK2005 解决方法

    项目为非MFC,但要用到MFC的库,使用过程中遇到的问题总结一下 uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl opera ...

  4. number_format

    number_format — 以千位分隔符方式格式化一个数字 说明 string number_format ( float $number [, int $decimals = 0 ] ) str ...

  5. 异常详细信息: System.Web.Hosting.HostingEnvironmentException: 访问 IIS 元数据库失败 解决方法

    访问IIS元数据库失败 同理,给操作系统的新建用户赋予IIS操作权限同样可以采用该命令来处理 说明: 执行当前 Web 请求期间,出现未处理的异常.请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错 ...

  6. WinCE开机Logo的实现(USB下载图片到nandflash)

    WinCE开机启动Logo使用Eboot读取NandFlash中的图片数据,然后显示的方式.对于开机logo的方式网友http://jazka.blog.51cto.com/809003/664131 ...

  7. JS cookie的使用

    js设置cookie有很多种方法. 第一种:(这个是w3c官网的代码) <script> //设置cookie function setCookie(cname, cvalue, exda ...

  8. jquery之 animate()方法详解

    jQuery.animate() 函数详解 animate()函数用于执行一个基于css属性的自定义动画. 你可以为匹配的元素设置css样式,animate()函数将会执行一个从当前样式到指定的css ...

  9. R: NULL, NA, and NaN

    NaN (“Not a Number”) means 0/0 NA (“Not Available”) is generally interpreted as a missing value and ...

  10. 虚拟机guest为windows7的环境下安装破解版simplify3d_3.0.2

    情形: 1.主机(host):ubuntu 2.虚拟机里安装的操作系统版本(guest):windows 7专业版 3.simplify3d破解版版本:3.0.2(破解需要的工具均在下文的百度云地址里 ...