今天配置CentOS6.5下安装Nginx + php7 + mysql5.7.15遇到了一些坑。本来家里的电脑在配置环境的时候没有问题,拿去公司的电脑上就是到处报错。不知道是不是人品问题。今晚在家重装了一个centos,安装之后进行了全部yum update。本来以为上午的问题可能是没有更新软件,图样图森破。下面总结一下今晚对nginx部分的心得。

因为PCRE本来是用在nginx重写rewrite的时候,解析正则的正则解析库,所以在安装nginx之前,默默的先装上基本应用:

yum -y install gcc automake autoconf libtool gcc-c++ gd zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt libmcrypt-devel pcre pcre-devel

ok,现在下载并解压:

  wget http://nginx.org/download/nginx-1.10.1.tar.gz

  tar zxvf nginx-1.10.1

  cd nginx-1.10.1

  ./configure --prefix=/usr/local/nginx

通过find,知道了pcre默认安装在/usr/local/nginx/auto/lib/pcre,那么,

./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/nginx/auto/lib/pcre

接下来就是一轮报错:

1.发生错误为:

make[2]: *** 没有规则可以创建目标“distclean”。 停止。

网上看到的办法一一做了尝试:

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-openssl=/usr/include/openssl   --user=www --group=www

2.发生错误为:

"conf/koi-win" 与"/usr/local/nginx/conf/koi-win" 为同一文件

据说这是因为防火墙的原因。我又关了防火墙重启:

vi + /etc/sysconfig/iptables
#添加配置项
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
#重启防火墙
service iptables restart

3.接着出现:

nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: No such file or directory)
#0: getpwnam("www") failed

喝喝。现在log不能打开,网上说,这是nginx已经运行,被执行启动,这个不算致命错误;

然后就没有了!!!

好吧我杀进程,总算不在运行了吧:

kill -9 nginx

4.再次make && make install ,亲人,胡汉三我又回来了!

cp: `conf/koi-win’ and `/usr/local/nginx/conf/koi-win’ 为同一文件。

所以上面这一切都是在逗我咯?

好吧。仔细翻了一下,nginx/conf/koi-win,和/usr/local/nginx/conf/kol-win,终于在阿里云上面找到了答案,路径的问题嘛

./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf

终于在默念天灵灵地灵灵装好系统行不行的诚恳祷告下,make && make install成功了。以下部分转载自阿里云,并经过实际测试:

接下来启动nginx

#方法1 
[root@unique nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 
#方法2 
[root@unique nginx]# cd /usr/local/nginx/sbin 
[root@unique sbin]# ./nginx

停止nginx

#查询nginx主进程号 
ps -ef | grep nginx
#停止进程 
kill -QUIT 主进程号(我的是27854)  #快速停止 
kill -TERM 主进程号(我的是2993)  #强制停止 
pkill -9 nginx

重启nginx

[root@unique sbin]# /usr/local/nginx/sbin/nginx -s reload

这个时候如果出现nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed

想必是需要:

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

继续

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

测试nginx

#测试端口 
netstat –na|grep 80
#浏览器中测试 
http://ip:80

做一个自定义的nginx启动停止脚本

[root@unique sbin]# vi /etc/init.d/nginx

把下面的脚本复制进去然后保存

#! /bin/sh
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the nginx web server PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/$NAME.conf
PIDFILE=/usr/local/nginx/logs/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME set -e
[ -x "$DAEMON" ] || exit 0 do_start() {
 $DAEMON -c $CONFIGFILE || echo -n "nginx already running"
} do_stop() {
 kill -INT `cat $PIDFILE` || echo -n "nginx not running"
} do_reload() {
 kill -HUP `cat $PIDFILE` || echo -n "nginx can't reload"
} case "$1" in
 start)
 echo -n "Starting $DESC: $NAME"
 do_start
 echo "."
 ;;
 stop)
 echo -n "Stopping $DESC: $NAME"
 do_stop
 echo "."
 ;;
 reload|graceful)
 echo -n "Reloading $DESC configuration..."
 do_reload
 echo "."
 ;;
 restart)
 echo -n "Restarting $DESC: $NAME"
 do_stop
 do_start
 echo "."
 ;;
 *)
 echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
 exit 3
 ;;
esac exit 0

给文件添加执行权限

[root@unique sbin]# chmod +x /etc/init.d/nginx
#然后可以通过
#/etc/init.d/nginx start 命令启动nginx
#/etc/init.d/nginx stop 命令停止nginx
#/etc/init.d/nginx restart 命令重启nginx #重启nginx
[root@unique init.d]# /etc/init.d/nginx restart
Restarting nginx daemon: nginx.

扩展:配置开机启动

如果需要开机启动服务,保存好 /etc/init.d/nginx文件后,执行以下命令:

[root@unique init.d]#chkconfig --add ningx
[root@unique init.d]#chkconfig --level nginx 2345 on

于是,我开始配置php和mysql,前方必然有坑。容我慢慢趟来……

CentOS下配置nginx conf/koi-win为同一文件的各类错误的更多相关文章

  1. centos下配置nginx遇到的一些基本的坑

    作为一个用.net的渣渣,常年混迹在window平台下,对Linux啥都不懂.随着.net core开源.跨平台后,也开始学习下linux. 在Desktop/Webs下放了一个index.html的 ...

  2. centos下配置nginx支持php

    添加nginx 默认主页index.php vim .../etc/nginx/conf.d/default.conf location / { root   /usr/share/nginx/htm ...

  3. centos下配置Nginx

    首先NGINX是一个高效的HTTP和反向代理的服务器,这里记录一下它的安装方式和文件结构方便以后查看.同时Linux系统具有灵活性,其他的东西可查看具体的官网信息:https://nginx.org/ ...

  4. CentOS下配置Nginx实现动静分离实例

    测试环境: CentOS Linux release 7.6 PHP 7.2.32 两台服务器:192.168.1.109(Nginx),192.168.1.118(Apache) 1. 安装配置19 ...

  5. 在CentOS/Windows下配置Nginx(以及踩坑)

    在CentOS/Windows下配置Nginx(以及踩坑) 1. 序言 因为这类文章网上比较多,实际操作起来也大同小异,所以我并不会着重于详细配置方面,而是将我配置时踩的坑写出来. 2. CentOS ...

  6. CentOS 7 下配置 Nginx + PHP7.1 + MariaDB 以及 Laravel 框架 2018.3.11

    CentOS 7 下配置 Nginx + PHP7.1 + MariaDB 以及 Laravel 框架 阿里云服务器的选择 当然是选择学生优惠啦.这里阿里云还提供了轻量级服务器这个选项,可以预装 LA ...

  7. CentOS 7 下配置 Nginx + PHP7.1 + MariaDB 以及 Laravel 框架

    <!doctype html> CentOS 7 下配置 Nginx + PHP7.1 + MariaDB 以及 Laravel 框架.mdhtml {overflow-x: initia ...

  8. CentOS 下 安装 nginx 执行配置命令 ./configure 报错

    CentOS 下 安装 nginx 执行配置命令 ./configure --prefix=/opt/nginx --sbin-path=/usr/bin/nginx 时提示以下错误: checkin ...

  9. centos下安装nginx和php-fpm

    安装这两个花了大约七个小时,简直呵呵,安装nginx就是直接 yum install nginx ,但发现一打开php文件就是直接下载该php文件,也就是不能识别php文件,解决这个花了好久,但其实看 ...

随机推荐

  1. Js运动框架

    <!DOCTYPE html> <html> <head> <title></title> </head> <body&g ...

  2. Windows 10 密钥分享

    Windows 10 Technical Preview for Enterprise:KEY:PBHCJ-Q2NYD-2PX34-T2TD6-233PKhttp://technet.microsof ...

  3. Paypal支付小记

    Paypal支付小记 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !impo ...

  4. spring入门(四)【面向切面编程】

    开发过程中很多时候会用到日志.事务等操作,这些操作如果要写在业务代码中会相当麻烦,这时就会用到面向切面编程(AOP),AOP作为一种编程思想,和OOP有着不同的侧重点,面向对象侧重于万事万物皆对象,而 ...

  5. jQuery元宵猜灯谜特效(元宵十五日猜一个字)

    在线体验:http://keleyi.com/keleyi/phtml/jqtexiao/35.htm jQuery元宵猜灯谜特效的HTML代码如下: <!DOCTYPE html> &l ...

  6. iOS UITableView的使用 (选自oschina)

    1.新手篇创建tableView   http://my.oschina.net/joanfen/blog/203041 2.进阶篇列表中行的操作   http://my.oschina.net/jo ...

  7. Android开发5:应用程序窗口小部件App Widgets的实现

    前言 本次主要是实现一个Android应用,实现静态广播.动态广播两种改变 widget内容的方法,即在上篇博文中实验的基础上进行修改,所以此次实验的重点是AppWidget小部件的实现啦~ 首先,我 ...

  8. sharepoint2013爬xls文件:Error initializing IFilter for extension的解决方案

    最近sharepoint2013爬网出现: error initializing IFilter for extension '.xls' (Error code is 0x80030002). Th ...

  9. iOS之微信支付

    前言:下面介绍微信支付的开发流程的细节,图文并茂,你可以按照我的随笔流程过一遍代码.包你也学会了微信支付.而且支付也是面试常问的内容. 正文: 1.首先在开始使用微信支付之前,有一些东西是开发者必须要 ...

  10. 深入理解JavaScript的闭包特性如何给循环中的对象添加事件

    初学者经常碰到的,即获取HTML元素集合,循环给元素添加事件.在事件响应函数中(event handler)获取对应的索引.但每次获取的都是最后一次循环的索引.原因是初学者并未理解JavaScript ...