CentOS6.3上安装与配置nginx+php+mysql环境
1. 目前nginx采用是源码包安装的方式(yum安装失败),下载地址:http://nginx.org/en/download.html
我这里的安装包是:nginx-1.12.0.tar.gz
2.在安装nginx前需要安装pcre,我这里的pcre源码包是:pcre-8.35.tar.gz
文件存放路径:/home/nginx/pcre-8.35.tar.gz
tar zxvf pcre-8.35.tar.gz
cd pcre-8.35
./configure --prefix=/usr/local/pcre
make
make install
3.源码包安装nginx;文件存放路径:/home/nginx/nginx-1.12.0.tar.gz
tar zxvf nginx-1.12.0.tar.gz
cd nginx-1.12.0
./configure --prefix=/usr/local/nginx --without-http_memcached_module --with-http_stub_status_module --with-pcre=/home/nginx/pcre-8.35
注意:此处一定要加上pcre的源码所在的路径,否则报错。
make
make install
4. yum安装mysql + php;在安装之前,先装yum-downloadonly,将mysql和php的安装包下载到本地后再安装,方便后日后搭建不能上网的设备。
4.1安装yum-downloadonly
yum install yum-downloadonly 或者 yum install yum-plugin-downloadonly
4.2下载Mysql
yum install mysql mysql-server mysql-devel --downloadonly --downloaddir=/home/PhpMysql
4.3下载PHP
yum install php php-fpm php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml --downloadonly --downloaddir=/home/PhpMysql/
4.4安装mysql和php
cd /home/PhpMysql/
rpm -ivh *.rpm --force
5. 配置nginx: 找到nginx.conf,修改四处即可: 取消两处注释,修改一处参数,增加一处设置。
我安装的文件路径在:/usr/local/nginx/conf/nginx.conf
user nobody; #将此行(也就是文件首行)注释去掉。
location / {
root html;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^/(.*)$ /Autotest/index.php?$1 last;
break;
}
} #此块是增加的,用于页面跳转;如果不加该处设置,能打开项目首页,却无法打第二个页面。
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_param行的参数。
原本此行是:fastcgi_param SCRIPT_FILENAME /script$fastcgi_script_name; 须改为:fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
配置完毕。
6.手动启动
mysql: service mysqld start
php-fpm: service php-fpm start
nginx: /usr/local/nginx/sbin/nginx
7. nginx开机自启动:需要编写自启动脚本,然后chkconfig,如下:
#!/bin/bash
#chkconfig: 235 90 10
#description: nginx self startup by.
PROG='nginx'
PROG_PATH='/usr/local/nginx/sbin/'
get_pid()
{
local pid=`ps aux | grep $1 | grep -v grep| awk '{print $2}'`
echo $pid
}
function start()
{
local pid=$(get_pid $PROG)
if [[ "$pid" != "" ]]; then
echo "Error $PROG is currently running" 1>&2
exit 1
else
$PROG_PATH$PROG 2>&1 &
echo "$PROG started"
fi
}
function stop()
{
echo "begin to stop $PROG"
local pid=$(get_pid $PROG)
if [[ "$pid" != "" ]]; then
kill -9 $pid
echo "$PROG stopped"
else
echo "Error,$PROG not started!" 1>&2
exit 1
fi
}
case "$1" in
start)
start
exit 0
;;
stop)
stop
exit 0
;;
reload|restart|force-reload)
stop
start
exit 0
;;
*)
echo "Usage: $0 {start|stop|reload|restart|force_reload}" 1>&2
exit 1
;;
esac
此处脚本完毕,将文件命名为:atNginx,然后执行chkconfig : chkconfig --add atNginx
8.mysql与php-fpm开机自启动
chkconfig --level 235 mysqld on
chkconfig --level 235 php-fpm on
CentOS6.3上安装与配置nginx+php+mysql环境的更多相关文章
- 在 CentOS 7上安装并配置 Python 3.6 环境
前言 按照此方法安装保证以下报错什么的统统都没有! 基础环境 系统:centos7.4 软件:python3 Retrying (Retry(total=0, connect=None, read=N ...
- centos6.5上安装5.7版本的mysql
centos6.5上安装5.7版本的mysql https://www.cnblogs.com/lzj0218/p/5724446.html 设置root可以在本机以外的机器访问 mysql -uro ...
- CentOS7上安装并配置Nginx、PHP、MySql
一.Nginx 1.安装nginx yum install nginx 2.启动nginx systemctl start nginx 除了systemctl start nginx之外,常用的相关命 ...
- Ubuntu/CentOS 系统上安装与配置Nginx
一.在线安装: Ubuntu:sudo apt-get install nginx CentOS: sudo yum install nginx 二.安装后的位置: 1.服务地址:/etc/init. ...
- Centos 7 手把手教你使用YUM方式安装并配置Nginx+php7-fpm+MySQL
需要准备的内容 一台纯净系统的服务器 远程连接服务器的工具 (我这里使用Xshell) 安装nginx 链接上服务器后执行 yum install nginx 这里需要输入y 后回车,开始安装ngi ...
- LEMP--如何在Ubuntu上安装Linux、Nginx、MySQL和PHP
简介 LEMP是用来搭建动态网站的一组软件,首字母缩写分别表示Linux.Nginx(Engine-X).MySQL和PHP. 本文将讲述如何在Ubuntu安装LEMP套件.当然,首先要安装Ubunt ...
- 使用Homebrew在Mac OS X EI Capitan上安装与配置nginx和PHP
安装nginx brew install nginx sudo nginx 测试安装 在浏览器打开下面的链接地址 http://localhost:8080 nginx.conf配置 # HTTPS ...
- CentOS6.7上安装nginx1.8.0
主题: CentOS6.7上安装nginx1.8.0 环境准备: 1.gcc-c++ 示例:yum install gcc-c++ 安装:gcc-c++ gcc-c++编译工具 2.PCRE(Perl ...
- 最新版CentOS6.5上安装部署ASP.NET MVC4和WebApi
最新版CentOS6.5上安装部署ASP.NET MVC4和WebApi 使用Jexus5.8.1独立版 http://www.linuxdot.net/ ps:该“独立版”支持64位的CentOS ...
随机推荐
- Day 20 常用模块(三)
一.加密模块 1.加密方式: 1.有解密的加密方式 2.无解密的加密方式,碰撞检查 1.不同数据加密后的结果一定不一致 2.相同数据的加密结果一定是一致 2.hashlib模块 1.基本使用 ciph ...
- ASP.NET: Cookie会话丢失,Session超时配置
问题描述: asp.net应用中web.config的SessionState节点:原先是 <sessionState mode="InProc" timeout=" ...
- HttpWebResponse Post 前端控件数据,后台如何接收?
MVC视图页: @{ Layout = null; } <!DOCTYPE html> <html> <head> <title>test</ti ...
- Log4j配置发邮件功能
# 发送日志到指定邮件log4j.appender.mail=org.apache.log4j.net.SMTPAppenderlog4j.appender.mail.Threshold=DEBUGl ...
- sunzl is not in the sudoers file.This incident will be reported
Description: [sunzl@localhost nuc900bsp$] ./install.sh sorry!you are not the root !! [sunzl@localhos ...
- bootice-diskinfo参数
http://bbs.wuyou.net/forum.php?mod=redirect&goto=findpost&ptid=57675&pid=3023573&fro ...
- 找到排序矩阵中从小到大第K个数字
一 题目描述 在一个排序矩阵中找从小到大的第 k 个整数. 排序矩阵的定义为:每一行递增,每一列也递增. 二 题解 由于排序矩阵中的每一行都是递增的,并且每一列都是递增的.从小到大第k个数,实际上就是 ...
- 多线程、互斥锁、异步、GIL
多线程-threading python的thread模块是比较底层的模块,python的threading模块是对thread做了一些包装的,可以更加方便被使用 from threading imp ...
- TensorFlow-GPU+cuda8+cudnn6+anaconda安装遇到的版本错误
第一遍装的时候是cuda10+cudnn5.1这个诡异的组合,失败 卸载cuda就是把所有的NVIDIA有关的应用都删掉,c盘文件也都删掉,不用留. 第二遍是cuda8+cudnn5.1.版本还是对不 ...
- 学习笔记之English
雅思听力地图题的常用短语 - 无忧机经预测 https://mp.weixin.qq.com/s/VmV3L2METymtjMWHY2fNiA 雅思听力租房的那些事儿 - 北京市海淀区环球雅思 htt ...