centos下安装nginx
2015-08-20 12:03
1701 查看
centos下安装nginx
[root@iZ258gu0zkwZ tmp]# wget http://nginx.org/download/nginx-1.9.4.tar.gz
[root@iZ258gu0zkwZ tmp]# tar zxvf nginx-1.9.4.tar.gz
[root@iZ258gu0zkwZ tmp]# cd nginx-1.9.4
[root@iZ258gu0zkwZ nginx-1.9.4]# ./configure --prefix=/opt/nginx --with-http_stub_status_module
出错:
./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.
安装pcre,可提示已是最新版本:
[root@iZ258gu0zkwZ nginx-1.9.4]# yum install pcre
Loaded plugins: security
Setting up Install Process
Package pcre-6.6-9.el5.i386 already installed and latest version
Nothing to do
现在是需要1.7.11以上的支持多线程模型的nginx版本,直接用yum查看nginx版本是0.8几,如下处理:
[root@iZ258gu0zkwZ nginx-1.9.4]# rpm -ivh http://nginx.org/packages/centos/5/i386/RPMS/nginx-1.8.0-1.el5.ngx.i386.rpm
Retrieving http://nginx.org/packages/centos/5/i386/RPMS/nginx-1.8.0-1.el5.ngx.i386.rpm
warning: /var/tmp/rpm-xfer.Zua6AN: Header V3 RSA/SHA1 signature: NOKEY, key ID 7bd9bf62
Preparing... ########################################### [100%]
1:nginx ########################################### [100%]
----------------------------------------------------------------------
Thanks for using nginx!
Please find the official documentation for nginx here:
* http://nginx.org/en/docs/
Commercial subscriptions for nginx are available on:
* http://nginx.com/products/
----------------------------------------------------------------------
[root@iZ258gu0zkwZ nginx-1.9.4]# yum info nginx
Loaded plugins: security
Installed Packages
Name : nginx
Arch : i386
Version : 1.8.0
Release : 1.el5.ngx
Size : 746 k
Repo : installed
Summary : High performance web server
URL : http://nginx.org/
License : 2-clause BSD-like license
Description: nginx [engine x] is an HTTP and reverse proxy server, as well as
: a mail proxy server.
再执行安装:
[root@iZ258gu0zkwZ nginx-1.9.4]# yum install nginx
Loaded plugins: security
Setting up Install Process
Package matching nginx-0.8.55-6.el5.i386 already installed. Checking for update.
Nothing to do
先删除:
[root@iZ258gu0zkwZ nginx-1.9.4]# yum -y remove nginx
Loaded plugins: security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package nginx.i386 0:0.8.55-6.el5 set to be erased
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================
Removing:
nginx i386 0.8.55-6.el5 installed 936 k
Transaction Summary
==================================================================================================================================================================================
Remove 1 Package(s)
Reinstall 0 Package(s)
Downgrade 0 Package(s)
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing : nginx 1/1
Removed:
nginx.i386 0:0.8.55-6.el5
Complete!
重新安装,好像版本就对了:
[root@iZ258gu0zkwZ nginx-1.9.4]# whereis nginx
nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx
[root@iZ258gu0zkwZ nginx-1.9.4]# nginx -v
nginx version: nginx/1.8.0
修改nginx.conf文件,增加uwsgi的支持:
31 server {
32 listen 80;
33 server_name localhost;
34
35 #charset koi8-r;
36
37 #access_log logs/host.access.log main;
38
39 location / {
40 #root html;
41 #index index.html index.htm;
42 #aio threads;
43 include uwsgi_params;
44 uwsgi_pass 127.0.0.1:9000;
45 uwsgi_param UWSGI_CHDIR /var/www/apps/vpoker;
46 uwsgi_param UWSGI_SCRIPT webpy-vpoker;
47 }
48 }
************************************************************************************************************************************************************************************************************************************
安装uwsgi
************************************************************************************************************************************************************************************************************************************
安装pip
[root@iZ258gu0zkwZ tmp]# wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate
[root@iZ258gu0zkwZ tmp]# python get-pip.py
安装uwsgi
[root@iZ258gu0zkwZ tmp]# pip install uwsgi
[root@iZ258gu0zkwZ uwsgi]# uwsgi --version
2.0.11.1
启动uwsgi
[root@iZ258gu0zkwZ uwsgi]# uwsgi --socket :9000 --plugins=python --daemonize /var/log/uwsgi/uwsgi.log
open("./python_plugin.so"): No such file or directory [core/utils.c line 3675]
!!! UNABLE to load uWSGI plugin: ./python_plugin.so: cannot open shared object file: No such file or directory !!!
在浏览器中输入主机地址,可以正常通过webpy访问了!
************************************************************************************************************************************************************************************************************************************
编译安装nginx
************************************************************************************************************************************************************************************************************************************
[root@iZ258gu0zkwZ vpoker]# nginx -s reload
nginx: [emerg] "aio threads" is unsupported on this platform in /etc/nginx/nginx.conf:42
不支持多线程模式,而现在需要用到这个特性,不确定到底是不是系统问题,重新带参数编译一下nginx
[root@iZ258gu0zkwZ tmp]# wget http://nginx.org/download/nginx.1.9.4.tar.g
[root@iZ258gu0zkwZ tmp]# tar zxvf nginx-1.9.4.tar.gz
[root@iZ258gu0zkwZ tmp]# cd nginx-1.9.4
[root@iZ258gu0zkwZ nginx-1.9.4]# ./configure --prefix=/usr/local/nginx --with-threads --with-http_stub_status_module
出错:
./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.
解决:
[root@iZ258gu0zkwZ nginx-1.9.4]# yum -y install pcre-devel
再次执行./configure,成功:
Configuration summary
+ using threads
+ using system PCRE library
+ OpenSSL library is not used
+ md5: using system crypto library
+ sha1: using system crypto library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
编译安装:
make
make install
[root@iZ258gu0zkwZ nginx-1.9.4]# cd /usr/local/nginx/sbin
[root@iZ258gu0zkwZ sbin]# ./nginx -v
nginx vers
b028
ion: nginx/1.9.4
[root@iZ258gu0zkwZ sbin]# ./nginx -V
nginx version: nginx/1.9.4
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-55)
configure arguments: --prefix=/usr/local/nginx --with-threads --with-http_stub_status_module
这次在nginx.conf中增加aio threads,重新加载没有出错!
nginx配置状态,修改nginx.conf文件:
54 location /nginx_status
55 {
56 stub_status on;
57 access_log off;
58 #allow 127.0.0.1;
59 #deny all;
60 }
通过浏览器访问http://youip/nginx_status进行查看,如下:
Active connections: 2
server accepts handled requests
28 28 38
Reading: 0 Writing: 1 Waiting: 1
还可以用如下方式查看:
[root@iZ258gu0zkwZ sbin]# netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
ESTABLISHED 57
TIME_WAIT 4
ImportError: No module named webpy-vpoker
unable to load app 0 (mountpoint='') (callable not found or import error)
--- no python application found, check your startup logs for errors ---
[pid: 17394|app: -1|req: -1/3] 202.108.36.107 () {46 vars in 819 bytes} [Thu Aug 20 16:37:01 2015] GET /test => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
碰到这问题的时候一定要仔细看,一定是模块名字写错了!!!
[root@iZ258gu0zkwZ tmp]# wget http://nginx.org/download/nginx-1.9.4.tar.gz
[root@iZ258gu0zkwZ tmp]# tar zxvf nginx-1.9.4.tar.gz
[root@iZ258gu0zkwZ tmp]# cd nginx-1.9.4
[root@iZ258gu0zkwZ nginx-1.9.4]# ./configure --prefix=/opt/nginx --with-http_stub_status_module
出错:
./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.
安装pcre,可提示已是最新版本:
[root@iZ258gu0zkwZ nginx-1.9.4]# yum install pcre
Loaded plugins: security
Setting up Install Process
Package pcre-6.6-9.el5.i386 already installed and latest version
Nothing to do
现在是需要1.7.11以上的支持多线程模型的nginx版本,直接用yum查看nginx版本是0.8几,如下处理:
[root@iZ258gu0zkwZ nginx-1.9.4]# rpm -ivh http://nginx.org/packages/centos/5/i386/RPMS/nginx-1.8.0-1.el5.ngx.i386.rpm
Retrieving http://nginx.org/packages/centos/5/i386/RPMS/nginx-1.8.0-1.el5.ngx.i386.rpm
warning: /var/tmp/rpm-xfer.Zua6AN: Header V3 RSA/SHA1 signature: NOKEY, key ID 7bd9bf62
Preparing... ########################################### [100%]
1:nginx ########################################### [100%]
----------------------------------------------------------------------
Thanks for using nginx!
Please find the official documentation for nginx here:
* http://nginx.org/en/docs/
Commercial subscriptions for nginx are available on:
* http://nginx.com/products/
----------------------------------------------------------------------
[root@iZ258gu0zkwZ nginx-1.9.4]# yum info nginx
Loaded plugins: security
Installed Packages
Name : nginx
Arch : i386
Version : 1.8.0
Release : 1.el5.ngx
Size : 746 k
Repo : installed
Summary : High performance web server
URL : http://nginx.org/
License : 2-clause BSD-like license
Description: nginx [engine x] is an HTTP and reverse proxy server, as well as
: a mail proxy server.
再执行安装:
[root@iZ258gu0zkwZ nginx-1.9.4]# yum install nginx
Loaded plugins: security
Setting up Install Process
Package matching nginx-0.8.55-6.el5.i386 already installed. Checking for update.
Nothing to do
先删除:
[root@iZ258gu0zkwZ nginx-1.9.4]# yum -y remove nginx
Loaded plugins: security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package nginx.i386 0:0.8.55-6.el5 set to be erased
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================
Removing:
nginx i386 0.8.55-6.el5 installed 936 k
Transaction Summary
==================================================================================================================================================================================
Remove 1 Package(s)
Reinstall 0 Package(s)
Downgrade 0 Package(s)
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing : nginx 1/1
Removed:
nginx.i386 0:0.8.55-6.el5
Complete!
重新安装,好像版本就对了:
[root@iZ258gu0zkwZ nginx-1.9.4]# whereis nginx
nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx
[root@iZ258gu0zkwZ nginx-1.9.4]# nginx -v
nginx version: nginx/1.8.0
修改nginx.conf文件,增加uwsgi的支持:
31 server {
32 listen 80;
33 server_name localhost;
34
35 #charset koi8-r;
36
37 #access_log logs/host.access.log main;
38
39 location / {
40 #root html;
41 #index index.html index.htm;
42 #aio threads;
43 include uwsgi_params;
44 uwsgi_pass 127.0.0.1:9000;
45 uwsgi_param UWSGI_CHDIR /var/www/apps/vpoker;
46 uwsgi_param UWSGI_SCRIPT webpy-vpoker;
47 }
48 }
************************************************************************************************************************************************************************************************************************************
安装uwsgi
************************************************************************************************************************************************************************************************************************************
安装pip
[root@iZ258gu0zkwZ tmp]# wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate
[root@iZ258gu0zkwZ tmp]# python get-pip.py
安装uwsgi
[root@iZ258gu0zkwZ tmp]# pip install uwsgi
[root@iZ258gu0zkwZ uwsgi]# uwsgi --version
2.0.11.1
启动uwsgi
[root@iZ258gu0zkwZ uwsgi]# uwsgi --socket :9000 --plugins=python --daemonize /var/log/uwsgi/uwsgi.log
open("./python_plugin.so"): No such file or directory [core/utils.c line 3675]
!!! UNABLE to load uWSGI plugin: ./python_plugin.so: cannot open shared object file: No such file or directory !!!
在浏览器中输入主机地址,可以正常通过webpy访问了!
************************************************************************************************************************************************************************************************************************************
编译安装nginx
************************************************************************************************************************************************************************************************************************************
[root@iZ258gu0zkwZ vpoker]# nginx -s reload
nginx: [emerg] "aio threads" is unsupported on this platform in /etc/nginx/nginx.conf:42
不支持多线程模式,而现在需要用到这个特性,不确定到底是不是系统问题,重新带参数编译一下nginx
[root@iZ258gu0zkwZ tmp]# wget http://nginx.org/download/nginx.1.9.4.tar.g
[root@iZ258gu0zkwZ tmp]# tar zxvf nginx-1.9.4.tar.gz
[root@iZ258gu0zkwZ tmp]# cd nginx-1.9.4
[root@iZ258gu0zkwZ nginx-1.9.4]# ./configure --prefix=/usr/local/nginx --with-threads --with-http_stub_status_module
出错:
./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.
解决:
[root@iZ258gu0zkwZ nginx-1.9.4]# yum -y install pcre-devel
再次执行./configure,成功:
Configuration summary
+ using threads
+ using system PCRE library
+ OpenSSL library is not used
+ md5: using system crypto library
+ sha1: using system crypto library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
编译安装:
make
make install
[root@iZ258gu0zkwZ nginx-1.9.4]# cd /usr/local/nginx/sbin
[root@iZ258gu0zkwZ sbin]# ./nginx -v
nginx vers
b028
ion: nginx/1.9.4
[root@iZ258gu0zkwZ sbin]# ./nginx -V
nginx version: nginx/1.9.4
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-55)
configure arguments: --prefix=/usr/local/nginx --with-threads --with-http_stub_status_module
这次在nginx.conf中增加aio threads,重新加载没有出错!
nginx配置状态,修改nginx.conf文件:
54 location /nginx_status
55 {
56 stub_status on;
57 access_log off;
58 #allow 127.0.0.1;
59 #deny all;
60 }
通过浏览器访问http://youip/nginx_status进行查看,如下:
Active connections: 2
server accepts handled requests
28 28 38
Reading: 0 Writing: 1 Waiting: 1
还可以用如下方式查看:
[root@iZ258gu0zkwZ sbin]# netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
ESTABLISHED 57
TIME_WAIT 4
ImportError: No module named webpy-vpoker
unable to load app 0 (mountpoint='') (callable not found or import error)
--- no python application found, check your startup logs for errors ---
[pid: 17394|app: -1|req: -1/3] 202.108.36.107 () {46 vars in 819 bytes} [Thu Aug 20 16:37:01 2015] GET /test => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
碰到这问题的时候一定要仔细看,一定是模块名字写错了!!!
相关文章推荐
- Mac下将Nginx配置成开机启动服务
- nginx 部署
- Nginx 是前端工程师的好帮手
- Nginx 笔记与总结(14)expires 缓存设置
- Nginx原理和部署
- fastdfs5.0.5+nginx安装+tracker+storage
- nginx+FastCGI+c++
- 使用keepalived实现nginx的高可用性
- mac下安装nginx+uwsgi+webpy出错解决
- Nginx - Windows下Nginx基本安装和配置
- Nginx 的线程池与性能剖析
- nginx conf by linux kernel
- nginx安装
- 限制nginx、apache+php文件上传大小
- 实战Nginx与PHP(FastCGI)的安装、配置与优化
- nginx学习笔记
- linux下安装nginx
- nginx负载均衡
- Nginx 禁止直接使用IP或未绑定的域名访问Web服务器
- nginx禁止某个IP访问