一、nginx 安装

1.查看yum下nginx版本信息

[root@localhost ~]# yum list | grep nginx  

2.手动添加nginx的yum仓库

[root@localhost ~]# vi /etc/yum.repos.d/nginx.repo

添加的内容为:

[nginx] 

name=nginx repo 

baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ 

gpgcheck=0 

enabled=1

3.编辑保存之后再查看nginx版本:

[root@localhost ~]# yum list | grep nginx 

4.安装nginx服务:

[root@localhost ~]# yum install -y nginx

5.启动nginx服务:

[root@localhost ~]# service nginx start

注意:/etc/nginx/nginx.conf   # Nginx配置文件位置

6.设置开机启动

[root@localhost ~]# chkconfig nginx on

7.nginx服务重启:

[root@localhost ~]# /etc/init.d/nginx  restart

8.测试是否正常:

[root@localhost ~]# Curl  http://127.0.0.1

9.删除默认的测试页面:

root@localhost ~]# rm -rf  /usr/share/nginx/html/*

二、安装mysql

1.安装mysql

[root@localhost ~]# yum install mysql mysql-server 

2.启动mysql

[root@localhost ~]# /etc/init.d/mysqld start  

3.设置开机启动

[root@localhost ~]# chkconfig mysqld on 

4.为root设置密码:

[root@localhost ~]# mysql_secure_installation

5.重启启动mysql服务:

[root@localhost ~]# /etc/init.d/mysqld stop   #停止
[root@localhost ~]# /etc/init.d/mysqld start #启动
[root@localhost ~]# service mysqld restart #重启

6.设置允许远程连接mysql

[root@localhost ~]# mysql -u  root -p

Mysql>use mysql;

Mysql>grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

[root@localhost ~]# service mysqld restart    #重启

三、安装PHP

1.安装PHP

[root@localhost ~]# yum install php  -y

2.安装PHP组件,使PHP支持 MySQL、PHP支持FastCGI模式

[root@localhost ~]# yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm

3.重启MySql

/etc/init.d/mysqld restart 

4.重启nginx

/etc/init.d/nginx  restart

5.启动php-fpm

/etc/rc.d/init.d/php-fpm start

6.设置开机启动php-fpm

chkconfig php-fpm on

四、配置nginx支持php

1.备份原有配置文件

cp /etc/nginx/nginx.conf  /etc/nginx/nginx.confbak

2.编辑配置文件

vim  /etc/nginx/nginx.conf  

user  nginx  nginx;      #修改nginx运行账号为:nginx组的nginx用户

:wq!           #保存退出

3.备份原有默认配置文件

cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.confbak 

4.编辑默认配置

vim /etc/nginx/conf.d/default.conf

修复内容为:

index index.php index.html index.htm;   #增加index.php

修改为以下内容:

# pass the PHPscripts 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 $document_root$fastcgi_script_name;
include fastcgi_params;
}
#取消FastCGI server部分location的注释,并要注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径

五、配置php

1.配置文件

vim /etc/php.ini 

#disable_functions=passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec                             #在386行 列出PHP可以禁用危险的函数

#expose_php = Off        #在432行 禁止显示php版本的信息

#magic_quotes_gpc = On   #在745行 打开magic_quotes_gpc来防止SQL注入

六、配置php-fpm

1.备份原有配置文件

cp /etc/php-fpm.d/www.conf   /etc/php-fpm.d/www.confbak

2.编辑配置文件

vim /etc/php-fpm.d/www.conf

修改为以下:

user = nginx   #修改用户为nginx
group = nginx #修改组为nginx

3.重启MySql

/etc/init.d/mysqld  restart

4.重启nginx

/etc/init.d/nginx restart

5.重启php-fpm

/etc/rc.d/init.d/php-fpm  restart

  

总结:到处已成功搭建起在centos下的ngnix+php+mysql应用!

centos下安装ngnix+php+mysql服务的更多相关文章

  1. windos下安装多个mysql服务

    最近需要使用Mysql制造大量数据,需要多个Mysql服务器.一开始的解决方案是使用多个windows机器.实体机不够,则用虚拟机来搞.但,,,,安装多个虚拟机…….好吧, 在网上查了下,有使用单个机 ...

  2. Linux CentOS下安装、配置mysql数据库

    假设要在Linux上做j2ee开发.首先得搭建好j2ee的开发环境.包含了jdk.tomcat.eclipse的安装(这个在之前的一篇随笔中已经有具体解说了Linux学习之CentOS(七)--Cen ...

  3. windows下安装、卸载mysql服务

    将下载下来的mysql解压到指定目录下(如:d:\mysql)安装服务在命令行输入d:\mysql\bin\mysqld -installnet start mysql卸载服务在命令行输入net st ...

  4. linux/centOS 下安装 ngnix

    Nginx 是一款轻量级的 Web 服务器/反向代理服务器,比较流行,建议在 Linux 下安装运行. Nginx 需要的依赖 它们包括:gcc,openssl,zlib,pcre(可通过rpm -q ...

  5. window下安装两个mysql服务

    产生这个想法主要是因为win系统之前装了mysql,服务名为mysql.又重新安装xampp,导致mysql冲突,xampp中的mysql始终启动不起来.   解决方法如下: 1.修改xampp中my ...

  6. Centos下安装mysql 总结

    一.MySQL安装 Centos下安装mysql 请点开:http://www.centoscn.com/CentosServer/sql/2013/0817/1285.html 二.MySQL的几个 ...

  7. Centos下安装配置LAMP(Linux+Apache+MySQL+PHP)

    Centos下安装配置LAMP(Linux+Apache+MySQL+PHP)   关于LAMP的各种知识,还请大家自行百度谷歌,在这里就不详细的介绍了,今天主要是介绍一下在Centos下安装,搭建一 ...

  8. Centos下安装mysql 和挂载硬盘

    一,CentOS下安装Mysql 6.5 1.检测系统是否自带安装mysql # yum list installed | grep mysql 2.删除已经安装的Mysql # yum -y rem ...

  9. 【MySQL】CentOS下安装及搭建主从复制

    CentOS下安装MySQL 1,wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm 2,rpm -ivh m ...

随机推荐

  1. Redis的C语言客户端(hiredis)的安装和使用

    关键词:hiredis, cRedis, redis clients, redis客户端, C客户端, 华为云分布式缓存服务 hiredis是一个非常全面的C语言版redis接口库,支持所有命令.管道 ...

  2. RHEL7 利用单个物理网卡实现VLAN

    使用nmcli创建网桥配置 #nmcli connection add type bridge con-name br0 stp no 使用nmcli创建VLAN设备配置 #nmcli connect ...

  3. SSH 报错解决方法记录汇总

    SSH 密钥签名失败 情景: 使用 SSH 密钥验证身份时 报错: sign_and_send_pubkey: signing failed: agent refused operation 环境: ...

  4. 工程能力之C4模型

    概述 刚在InfoQ上看到一篇介绍C4Model的文章,觉得这个模型设计的很赞,很有指导意义,做个简单的记录. Why,为什么需要架构图? ThoughtWorks中国 文章中有几句话我觉得很有道理, ...

  5. Linux 系统安全检查(shell)

    脚本内容: #!/bin/bash echo " (__)" echo " (oo)" echo " /------\/ " echo &q ...

  6. poweroff命令详解

    2019-02-17  基础命令学习目录首页   原文链接:https://www.cnblogs.com/Baron-Lu/p/6951297.html 在本篇中,我们会向你解释 shutdown. ...

  7. python之爬虫_并发(串行、多线程、多进程、异步IO)

    并发 在编写爬虫时,性能的消耗主要在IO请求中,当单进程单线程模式下请求URL时必然会引起等待,从而使得请求整体变慢 import requests def fetch_async(url): res ...

  8. mybatis之模糊查询SQL

    一,MySQL数据库 name like concat('%' , #{name} , '%') 二,Oracle数据库 name like '%' || #{name} || '%'

  9. Sprint6

    进展:今天更改一下我们的计划,从实现主要功能开始,及闹钟和事件提醒部分.查看了一些有关闹钟部分的资料.

  10. 计算器简单封装和ASP.net

    封装: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ...