Linux Nginx安装过程
安装nginx
wget http://nginx.org/download/nginx-1.9.3.tar.gz
tar -zxvf nginx-1.9.3.tar.gz
cd nginx-1.9.3
./configure --prefix=/usr/local/nginx \
--sbin-path=/usr/local/nginx/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--with-http_ssl_module \
--with-pcre=/lab/re/pcre-8.36 \
--with-zlib=/lab/re/zlib-1.2.8 \
--with-openssl=/lab/re/openssl-1.0.2d
#pcre zlib openssl源码目录,而不是编译安装后的目录。
make
make install
apache也是使用的80端口,所以需要修改一下apache端口
sudo vi /usr/local/apache2/conf/httpd.conf
Listen 8099 #改成8099
apachectl restart
启动nginx
/usr/local/nginx/nginx
检查80端口
netstat -ano|grep 80
访问一下试试
curl 127.0.0.1
配置nginx
vi /usr/local/nginx/nginx.conf
添加以下内容
server {
listen 80;
server_name svn.crabdave.org;
location / {
#如果nginx的监听端口不是默认的80端口,改为其他端口 如8099端口。$host:8099
#如果不配置,则后端服务器中request.getServerPort()无法获得正确的端口,返回的仍然是80;
proxy_set_header Host $host:8099;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8099;
}
}
注意:添加一些超时、缓存的配置(放在 location 配置段里)
client_max_body_size 100m;
client_body_buffer_size 128k;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 6000;
proxy_buffer_size 32k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 512k;
测试一下配置文件
/data/re/nginx/nginx -t
重新加载配置
/usr/local/nginx/nginx -s reload
修改hosts
设置svn.crabdave.org解析到你的nginx服务器ip
windows 运行drivers 修改hosts文件
192.168.1.104 www.crabdave.org
192.168.1.104 svn.crabdave.org
运行 cmd
ipconfig /flushdns来刷新dns缓存
访问http://svn.crabdave.org
Linux
vi /etc/hosts
添加
127.0.0.1 www.crabdave.org
127.0.0.1 svn.crabdave.org
重启网卡
/etc/init.d/network restart
curl svn.crabdave.org
配置开机自启动
vi /etc/init.d/nginx (输入下面的代码)
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
# It has a lot of features, but it's not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/nginx/nginx
nginx_config=/usr/local/nginx/nginx.conf
nginx_pid=/var/run/nginx.pid
RETVAL=0
prog="nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
echo "nginx already running...."
exit 1
fi
echo -n $"Starting $prog: "
daemon $nginxd -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
return $RETVAL
}
# Stop nginx daemons functions.
stop() {
echo -n $"Stopping $prog: "
killproc $nginxd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx $nginx_pid
}
# reload nginx service functions.
reload() {
echo -n $"Reloading $prog: "
#kill -HUP `cat ${nginx_pid}`
killproc $nginxd -HUP
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
exit 1
esac
exit $RETVAL
:wq 保存并退出
设置权限
chmod a+x /etc/init.d/nginx (a+x ==> all user can execute 所有用户可执行)
vi /etc/rc.local
加入一行 /etc/init.d/nginx start 保存并退出
相关推荐
本人多年的工作经验,完善了一套linux安装nginx的全过程,有了这个文档,连小白用户都可以轻松安装了,不再需要依赖其他的安装文档了。文档还包括设置开机自启。
Linux环境Nginx1.22.0版本,解压即用。 解压后使用./nginx -V可查看版本和编译信息。
该包是Linux下安装Nginx所需要的所有软件包,包含:pcre-8.38.tar.bz2, zlib-1.2.8.tar.gz, openssl-1.1.0-pre1.tar.gz, nginx-1.10.3.tar.gz
Linux Nginx1.14.0的具体安装详情,以及安装过程中会遇到的问题都一一解读了,不过Nginx的具体配置我没写,我希望配置文件还是要熟练的,否则光会安装并没有什么了不起的,不要积分 就是大家安装起来方便有个参考。
linux系统中详细安装过程헤问题解决办法
nginx=”/usr/local/nginx/sbin/nginx” //修改成nginx执行程序的路径。 NGINX_CONF_FILE=”/usr/local/nginx/conf/nginx.conf” //修改成nginx.conf文件的路径。 保存后设置文件的执行权限 [root@localhost ~]# ...
1、最新版 nginx-http-flv-module(linux程序)-(程序版本:nginx1.21.6 & http-flv-module1.2.10) 2、内含说明文档,请下载查看。 3、请勿放置于中文路径下,否则无法启动
自己安装nginx花了不少时间,特定把自己的过程或碰到的问题一一列在这个文档上,希望能给大家带来便利。欢迎吐嘈。
这里记录一下自己在centos7操作系统下安装nginx的过程,以便之后学习时查阅。笔者这里的Linux服务器使用的是腾讯云服务器,本人是一名Java程序员也是Linux的初学者有什么不对的地方请多指教,以后还会有更多的关于...
1. 里面有nginx安装是各种依赖的包 2. 内附详细的安装过程
linux 32位系统下nginx可以执行程序,支持rtmp推流,拉流
linux 的nginx打包好的程序,可以直接运行。 Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点(俄文:...
LNMP一键安装包是一个用Linux Shell编写的可以为CentOS/RadHat/Fedora、Debian/Ubuntu/Raspbian VPS(VDS)或独立主机安装LNMP(Nginx/MySQL/PHP)、LNMPA(Nginx/MySQL/PHP/Apache)、LAMP(Apache/MySQL/PHP)生产环境的...
Linux操作系统下安装Nginx,以及安装过程出现的错误。
详细描述了如何在linux(rhel)下搭建nginx web服务器的过程,并附有如何开启php功能。对于初学者,是很不错的参考资料。
linux下nginx-tomcat集群及session共享,亲测成功,下载的文件包含了所有需要的jar包及nginx,memcached安装,配置,由于试了很多种方法,下了很多包,有些也需要积分,所以这里下载要些积分留着用,不好意思了,...
超详细的lnmp的配置文档, Nginx是一个高性能的HTTP和反向代理服务器,同时还是IMAP/POP3/SMTP代理服务器,该程序由...所以我们要学会运用Nginx还是非常有必要的,下面我们一起来看一下Nginx是如何在Linux平台上搭建的
主要介绍了linux上nginx安装部署及使用过程,非常不错,具有一定的参考借鉴价值,需要的朋友参考下吧
linux内网离线安装nginx教程 步骤详细 附安装文件 完整安装 不需额外下载文件
Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点(俄文:Рамблер)开发的,第一个公开版本0.1.0发布于2004年10月4日。 其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、示例...