首页 / NGINX / Linux下nginx安装教程
Linux下nginx安装教程
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Linux下nginx安装教程,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2524字,纯文字阅读大概需要4分钟。
内容图文
![Linux下nginx安装教程](/upload/InfoBanner/zyjiaocheng/931/4082bf84f5564f98bb0ae533dac99691.jpg)
一、准备工作
Nginx安装版本:nginx-1.8.1.tar.gz
Linux环境:
二、安装nginx
1、把nginx-1.8.1.tar.gz放到/usr/locad/下
2、解压安装包:tar -xvf nginx-1.8.1.tar.gz
3、修改安装包名称:mv nginx-1.8.1 nginx
4、进入nginx目录:cd nginx
5、配置./configure
6、编译安装make && make install
三、验证是否成功启动
1、在/usr/local/nginx/sbin目录执行./nginx -r reload启动nginx
2、在浏览器中输入http://ip:80出现如下界面,表示启动成功
四、安装过程遇见问题
1、问题1,执行./configure报错
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
解决办法:
执行:yum -y install pcre-devel命令即可
2、问题2,./nginx -s reload重启时报错
nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: No such file or directory)
解决方法:
提示没有这个文件,是因为在nginx目录下没有logs文件夹,创建一个在启动即可
cd /usr/local/nginx
mkdir logs
cd sbin
./nginx -s reload
3、问题3,目录为同一级
make[1]: Leaving directory `/usr/local/nginx'
make -f objs/Makefile install
make[1]: Entering directory `/usr/local/nginx'
test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
test -d '/usr/local/nginx/sbin' || mkdir -p '/usr/local/nginx/sbin'
test ! -f '/usr/local/nginx/sbin/nginx' || mv '/usr/local/nginx/sbin/nginx' '/usr/local/nginx/sbin/nginx.old'
cp objs/nginx '/usr/local/nginx/sbin/nginx'
test -d '/usr/local/nginx/conf' || mkdir -p '/usr/local/nginx/conf'
cp conf/koi-win '/usr/local/nginx/conf'
cp: "conf/koi-win" 与"/usr/local/nginx/conf/koi-win" 为同一文件
make[1]: *** [install] 错误 1
make[1]: Leaving directory `/usr/local/nginx'
make: *** [install] 错误 2
这是因为编译安装过一次,再次编译安装是,sbin等文件夹已经存在所以会包这个错误,可以删除该文件夹再次安装,或者忽略该错误
4、问题4,解决 nginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"
使用/usr/local/nginx/sbin/nginx -s reload 重新读取配置文件出错
[root@localhost nginx]/usr/local/nginx/sbin/nginx -s reload
提示 nginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"
[root@localhost nginx]# cd logs
[root@localhost logs]# ls
access.log error.log nginx-access.log nginx_error.log
果然没有/usr/local/nginx/logs/nginx.pid 文件
解决方法:用指定文件加载nginx配置文件
[root@localhost nginx]/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
内容总结
以上是互联网集市为您收集整理的Linux下nginx安装教程全部内容,希望文章能够帮你解决Linux下nginx安装教程所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。