Nginx("engine x")是一款是由俄罗斯的程序设计师Igor Sysoev所开发高性能的 Web和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。
在高连接并发的情况下,Nginx是Apache服务器不错的替代品。
安装依赖:
yum install gcc
yum install pcre-devel
yum install zlib zlib-devel
yum install openssl openssl-devel
一键安装四个依赖
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
安装Nginx:
Nginx 一般有两个版本,分别是稳定版和开发版,您可以根据您的目的来选择这两个版本的其中一个,下面是把 Nginx 安装到 /usr/local/nginx 目录下的详细步骤:
cd /usr/local/src
wget http://nginx.org/download/nginx-1.1.10.tar.gz
tar -zxvf nginx-1.1.10.tar.gz
cd nginx-1.1.10
./configure
make
make install
配置文件:
启动端口配置文件位置linux修改路径/usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
启动:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
停止:
ps -ef|grep nginx
然后kill进程号
或者强制停止
pkill -9 nginx
重启:
在启动命令-c前加-t
/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
或者
可执行目录sbin下,输入命令
./nginx -s reload
部署文件:
/usr/local/nginx/html/
亦可参考:
http://www.nginx.cn/install
http://www.nginx.cn/doc/
官网:
http://nginx.org/en/
结束。