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 ...
随机推荐
- ORA-00257: archiver error. Connect internal only, until freed……
今天给客户测 试问题,让客户把数据发过来了.解压缩后一看,他们还是用的oracle 815版本的(他们exp导出时,带了导出日志,从导出日志中看出来是oracle 815版本的),不过没有关系,低版本 ...
- 【DevExpress】GridView的RowClick事件禁用Checkbox选择的解决办法
添加GridView的RowCellClick事件,代码如下 private void gvBoxMails_RowCellClick(object sender, DevExpress.XtraGr ...
- cpu工作原理
- git 放弃本地修改,强制拉取更新
开发时,对于本地的项目中修改不做保存操作(或代码改崩),可以用到Git pull的强制覆盖,具体代码如下: git fetch --all git reset --hard origin/master ...
- 蓝桥第八届省赛 javaB组承压计算
X星球的高科技实验室中整齐地堆放着某批珍贵金属原料. 每块金属原料的外形.尺寸完全一致,但重量不同.金属材料被严格地堆放成金字塔形. 7 5 8 7 8 8 9 2 7 2 8 1 4 9 1 8 1 ...
- 必须学会git和maven
转自: http://tieba.baidu.com/p/3458400116 很多人应该用过svn cvs之类的代码版本管理工具,git也是其中之一. svn和git最大的几个区别要点,svn必须要 ...
- MSDE2008安装备忘
MSDE2008安装备忘(适用于WIN7 8 10) 1.系统中必须要VC8.0,即VC2005运行库.2.系统中必须要有.net framework2.0.3.5.4.6运行库.3.windows防 ...
- Servlet-Context学习笔记
介绍 ServletContext其实就是全局作用域对象, 上下文环境对象 利用context可以实现对,当前网站中所有的Servlet共享数据 context对象只能由Tomcat负责创建,在tom ...
- Spring AOP Capabilities and Goal
Spring AOP是用纯的java实现的.不需要任何个性的实现过程.Spring AOP不需要控制类加载器,并且它适用于Servlet容器或者应用服务器. Spring AOP当前只支持方法执行的连 ...
- java 日志脱敏框架 sensitive,优雅的打印脱敏日志
问题 为了保证用户的信息安全,敏感信息需要脱敏. 项目开发过程中,每次处理敏感信息的日志问题感觉很麻烦,大部分都是用工具类单独处理,不利于以后统一管理,很不优雅. 于是,就写了一个基于 java 注解 ...