centos下安装ngnix+php+mysql服务
一、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服务的更多相关文章
- windos下安装多个mysql服务
最近需要使用Mysql制造大量数据,需要多个Mysql服务器.一开始的解决方案是使用多个windows机器.实体机不够,则用虚拟机来搞.但,,,,安装多个虚拟机…….好吧, 在网上查了下,有使用单个机 ...
- Linux CentOS下安装、配置mysql数据库
假设要在Linux上做j2ee开发.首先得搭建好j2ee的开发环境.包含了jdk.tomcat.eclipse的安装(这个在之前的一篇随笔中已经有具体解说了Linux学习之CentOS(七)--Cen ...
- windows下安装、卸载mysql服务
将下载下来的mysql解压到指定目录下(如:d:\mysql)安装服务在命令行输入d:\mysql\bin\mysqld -installnet start mysql卸载服务在命令行输入net st ...
- linux/centOS 下安装 ngnix
Nginx 是一款轻量级的 Web 服务器/反向代理服务器,比较流行,建议在 Linux 下安装运行. Nginx 需要的依赖 它们包括:gcc,openssl,zlib,pcre(可通过rpm -q ...
- window下安装两个mysql服务
产生这个想法主要是因为win系统之前装了mysql,服务名为mysql.又重新安装xampp,导致mysql冲突,xampp中的mysql始终启动不起来. 解决方法如下: 1.修改xampp中my ...
- Centos下安装mysql 总结
一.MySQL安装 Centos下安装mysql 请点开:http://www.centoscn.com/CentosServer/sql/2013/0817/1285.html 二.MySQL的几个 ...
- Centos下安装配置LAMP(Linux+Apache+MySQL+PHP)
Centos下安装配置LAMP(Linux+Apache+MySQL+PHP) 关于LAMP的各种知识,还请大家自行百度谷歌,在这里就不详细的介绍了,今天主要是介绍一下在Centos下安装,搭建一 ...
- Centos下安装mysql 和挂载硬盘
一,CentOS下安装Mysql 6.5 1.检测系统是否自带安装mysql # yum list installed | grep mysql 2.删除已经安装的Mysql # yum -y rem ...
- 【MySQL】CentOS下安装及搭建主从复制
CentOS下安装MySQL 1,wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm 2,rpm -ivh m ...
随机推荐
- Windows Server平台 confluence6.7.1安装与破解
1.1硬件需求建议: CPU:32/64 bit 2.27GHz双核心以上之CPU: 内存:8GB以上: 硬盘:300GB,7200转以上: 建议数据库.Confluence等各自独立一台服务器. 1 ...
- ClassLoader.loadClass()与Class.forName()的区别
ClassLoader.loadClass()与Class.forName()都是反射用来构造类的方法,但是他们的用法还是有一定区别的. 在讲区别之前,我觉得很有不要把类的加载过程在此整理一下. 在J ...
- slotting filter笔记
1.slot filling是为了让用户的意图转化为明确的指令而补全信息的过程. 2.准入条件 从一个开放域转入到封闭域,或者从一个封闭域转入到另一个封闭域,中间的跳转是需要逻辑判断的,而这个逻辑判断 ...
- 简单安装与使用虚拟环境virtualenv
安装虚拟环境的命令如下: sudo pip install virtualenv sudo pip install virtualenvwrapper 创建虚拟环境的命令如下: mkvirtualen ...
- NIO_通道之间传输数据
通道之间传输数据 transferFrom() transferTo() @Test public void test3() throws IOException { FileChannel inCh ...
- JSBridge的原理
前言 参考来源 前人栽树,后台乘凉,本文参考了以下来源 github-WebViewJavascriptBridge JSBridge-Web与Native交互之iOS篇 Ios Android Hy ...
- maven实战读书笔记(二)
一个Spring加载属性的工具类,指定目标位置之后可以用${}的方式加载配置文件 测试maven工程发送email的例子:运行成功的例子—github 常用的命令: mvn clean compile ...
- sprint2(第二天)
昨天没有想到餐桌的功能,今天加到展板.然后今天我们完成了餐桌模板,可以实现添加桌子的桌号.人数.修改和删除功能.不过由于今天学校网络不是很好,晚上我们clone了很久都没clone下来,所以没有上传代 ...
- BugPhobia开发篇章:Scurm Meeting-更新至0x02
0x01 :目录与摘要 If you weeped for the missing sunset, you would miss all the shining stars 索引 提纲 整理与更新记录 ...
- frist Django app — 一、 创建工程(转载)
转载地址:https://www.cnblogs.com/sunshine-2015/p/5658283.html 缘起 既然python都学了,学习python的时候感觉是相见恨晚,一种新的编程语言 ...