#mkdir /var/www/yum_repo

1、nginx安装:

在http://nginx.org/en/linux_packages.html#stable中下载CentOSX对应版本的rpm文件

把下载的nginx-release-centos-5-0.el5.ngx.noarch.rpm拷贝到yum_repo目录下

#rpm -Uvh nginx-release-centos-5-0.el5.ngx.noarch.rpm

#yum install nginx

2、mysql安装:

在http://dev.mysql.com/downloads/repo/yum/中下载CentOSX对应版本的rpm文件

把下载的mysql-community-release-el5-5.noarch.rpm拷贝到yum_repo目录下

#rpm -Uvh mysql-community-release-el5-5.noarch.rpm

#yum install -y mysql-server mysql mysql-deve

3、PHP安装:

在/var/www/yum_repo下:

  Centos 5.X
    #rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm
  CentOs 6.x
    #rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
  CentOs 7.X
 #rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
   #rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
运行yum install
#yum install php55w php55w-cli php55w-common php55w-gd php55w-ldap php55w-mbstring php55w-mcrypt php55w-mysql php55w-pdo

注:如果想升级到5.6把上面的55w换成56w就可以了。

安装PHP FPM

#yum install php55w-fpm
注:如果想升级到5.6把上面的55w换成56w就可以了。
 

【开放80、3306、22端口】

  1. #关闭防火墙
  2. service iptables stop
  3. vi /etc/sysconfig/iptables
  4. #添加
  5. -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
  6. -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
  7. -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
  8. #重启防火墙
  9. service iptables restart

【nginx配置】

  1. vi /etc/nginx/nginx.conf
  2. #在server下找到location / 修改解析PHP文件存放的路径, 修改为:
  3. location / {
  4. root   /var/www/html;
  5. index  index.html index.htm index.php;
  6. }
  7. #root表示虚拟目录设置为/var/www/html,增加默认解析index.php
  8. #在server下找到location ~ /.php$ 修改php解释器FastCGI配置,修改为:
  9. location ~ \.php$ {
  10. root           /var/www/html;
  11. fastcgi_pass   127.0.0.1:9000;
  12. fastcgi_index  index.php;
  13. fastcgi_param  SCRIPT_FILENAME  /var/www/html$fastcgi_script_name;
  14. include        fastcgi_params;
  15. }
  16. #将nginx添加到自启动中
  17. echo "/usr/sbin/nginx" >> /etc/rc.d/rc.local
  18. #将php添加到自启动中
  19. echo "/usr/sbin/php-fpm start" >> /etc/rc.d/rc.local

【nginx虚拟主机配置】

vi /etc/nginx/nginx.conf
#在http最后一行加入
include    /etc/nginx/conf.d/*.conf;
#不带url重写

  1. server {
  2. listen 80 default;
  3. server_name dev.localhost;
  4. access_log logs/dev.access.log;
  5. root /var/www/html;
  6. server_name_in_redirect off;
  7. location / {
  8. index index.html index.php;
  9. }
  10. location ~ \.php$ {
  11. fastcgi_pass   127.0.0.1:9000;
  12. fastcgi_index  index.php;
  13. fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
  14. include        fastcgi_params;
  15. }
  16. }

#带url重写(zend framework)

  1. server {
  2. listen 80;
  3. server_name dev.localhost;
  4. access_log logs/dev.access.log;
  5. root   /var/www/html;
  6. location / {
  7. index index.html index.php;
  8. if (-e $request_filename ) {
  9. break;
  10. }
  11. if ( $request_filename ~* \.(js|ico|gif|jpg|jpeg|xml|swf|txt|png|css|html|htm)$ ) {
  12. return 404;
  13. }
  14. rewrite .* index.php;
  15. }
  16. location ~ .*\.php$ {
  17. include fastcgi_params;
  18. fastcgi_param  SCRIPT_FILENAME    $document_root/index.php;
  19. #fastcgi_param REQUEST_URI $document_uri?$query_string;
  20. fastcgi_read_timeout 120;
  21. fastcgi_pass  127.0.0.1:9000;
  22. fastcgi_index index.php;
  23. }
  24. }
      1. #重启nginx
      2. /usr/sbin/nginx -s reload
      3. #重启php
      4. /usr/sbin/php-fpm restart

yum安装nginx+PHP+Mysql的更多相关文章

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

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

  2. Linux--YUM 安装 nginx php mysql

    Linux--YUM 安装 nginx php mysql (2011-11-13 11:27:14) 转载▼ 标签: 杂谈 分类: Linux 1.先新建一个 repo # vi /etc/yum. ...

  3. Linux 环境下安装 Nginx+php+mysql 开发环境

    一直以来都没有养成记录学习的好习惯,我想从这么一天开始,把自己学习和工作中的经验和坑都记录下来.等到以后老的时候还有可以回忆的地方. 最近在学习linux,虽然已经玩linux很久了,但是没有怎么用心 ...

  4. yum安装nginx

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

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

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

  6. centos7通过yum安装nginx

    centos7通过yum安装nginx nginx不支持centos7通过yum直接安装~~~ 1.查看操作系统位数[root@-jenkins ~]# rpm -aq|grep centos-rel ...

  7. <亲测>CentOS7中使用yum安装Nginx的方法

    CentOS7中使用yum安装Nginx的方法   最近无意间发现Nginx官方提供了Yum源.因此写个文章记录下. 1.添加源 默认情况Centos7中无Nginx的源,最近发现Nginx官网提供了 ...

  8. Centos下yum安装Nginx报错 No package nginx available.

    在Centos6下使用yum安装Nginx报错 解决方案: yum install epel-release

  9. CentOS7使用yum安装nginx

    CentOS默认没有nginx的yum源需要yum安装nginx可以使用一下方法 一,环境检测 二,设置yum源 rpm -Uvh http://nginx.org/packages/centos/7 ...

随机推荐

  1. iOS键盘高度的获取

    代码如下: - (void)viewDidLoad { [super viewDidLoad]; //增加监听,当键盘出现或改变时收出消息 [[NSNotificationCenter default ...

  2. 浅谈getStackTrace()方法(一)

    缘起: 今天看到有一个工具类中有一句: String msgToPrint = Thread.currentThread().getStackTrace()[1].getMethodName(); 输 ...

  3. 【CF1020B】Badge(模拟)

    题意:给定n个人,每个人指向第a[i]个人,要求输出从每个人开始第一个被访问到两次的人的编号 n<=1e3 思路: #include<cstdio> #include<cstr ...

  4. WebRTC编译详细介绍 (转)

    WebRTC技术交流群:234795279   原文地址:http://blog.csdn.net/temotemo/article/details/7056581 WebRTC编译 本人环境: 操作 ...

  5. 03深入理解C指针之---变量与内存

    该系列文章源于<深入理解C指针>的阅读与理解,由于本人的见识和知识的欠缺可能有误,还望大家批评指教. C语言是一种编译型的语言,C源代码在编译成可执行文件后,经常以以下三种方式使用内存: ...

  6. Devexpress控件中gridcontrol Drag a column header here to group by that column 更换

    参照网站:http://documentation.devexpress.com/#WPF/DevExpressXpfGridDataViewBase_RuntimeLocalizationStrin ...

  7. TStringList,快速解析 查找测试。。。很有用,再也不用 FOR 循环了

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABKAAAALHCAIAAAA2Gq0zAAAgAElEQVR4nOydeVgUV76wK5OZb5JJZi

  8. Reveal.js演讲幻灯片框架

    摘要 还需学习参考的链接  https://www.tuicool.com/articles/2AFFj2j 无意中看到这个插件,很喜欢,可以作用在演讲ppt,幻灯片,用户指引上等.代码简单,易维护 ...

  9. Codefroces Gym101572 I.Import Spaghetti-有向图跑最小环输出路径(Floyd)

    暑假学的很多东西,现在都忘了,补这道题还要重新学一下floyd,有点难过,我暑假学的东西呢??? 好了,淡定,开始写题解. 这个题我是真的很难过啊,输入简直是有毒啊(内心已经画圈诅咒出题人无数次了.. ...

  10. 东方14ACM小组 15:Challenge 11

    Challenge 11 查看 提交 统计 提问 总时间限制:  10000ms 单个测试点时间限制:  1000ms 内存限制:  262144kB 描述 给一个长为N的数列,有M次操作,每次操作是 ...