linux下编译安装nginx
1.首先下载稳定版nginx1.10.2 使用wget命令下载
wgethttp://nginx.org/download/nginx-1.10.2.tar.gz
2.然后解压
tar -zxvfnginx-1.10.2.tar.gz
cd nginx-1.10.2
3.安装依赖库
sudo apt-get install libpcre3-dev aptitude libssl-dev
sudo apt-get install openssl
sudo apt-get install libssl0.9.8
sudo apt-get install libssl-dev
4.编译
./configure
成功会输出:
Configuration summary
+ using system PCRE library
.....
make && make install
make[1]: Leaving directory `/root/nginx' 成功
5.加入系统变量
打开 /etc/profile文件
sudo vi /etc/profile
加入或修改path
export PATH=$PATH:/usr/local/nginx/sbin
让修改生效
source /etc/profile
启动nginx
sudo nginx
停止nginx
sudo nginx -s stop
重启nginx
sudo nginx -s reload
nginx编译安装完毕
nginx配置文件在/usr/local/nginx/conf/nginx.conf
http配置端口转发和tcp转发
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
server {
server_name www.wedwedwed.tk;
listen 80;
location / {
proxy_pass http://localhost:88;
}
}}
stream {
server {
listen 11111;
proxy_pass localhost:22222;
}
}