ubuntu 在本地设置域名

自己学习,记录下来,仅供参考,高手就跳过吧
第一步:
sudo vim /etc/hosts
127.0.0.1   localhost
127.0.1.1   allen
#本地调试用的

127.0.0.1   www.example.com(你想要的域名)
# The following lines are desirable for IPv6 capablehosts
::1     ip6-localhostip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

sudo /etc/init.d/networking restart

第二步:
首先 看看我的nginx配置
user   allen allen;
worker_processes   1;
error_log   logs/error.log;
error_log   logs/error.log  notice;
error_log   logs/error.log  info;
pid         logs/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include      mime.types;
    default_type  application/octet-stream;
    log_format  main   '$remote_addr -$remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent"$http_referer" '
                      '"$http_user_agent""$http_x_forwarded_for"';
    access_log  logs/access.log   main;
    sendfile        on;
    #tcp_nopush    on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    gzip  on;
    //虚拟主机的配置,这样vhosts文件夹包含一个个文件,每一个文件都是一个站点
    include vhosts/*;
}
如下 example.conf
server {
        listen       80;
        server_name  www.example.com;
        location / {
        root     /data/www/wwwroot/typecho/;
            indexindex.php   index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root  html;
        }

        location ~ \.php* {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index   index.php;
            fastcgi_param   SCRIPT_FILENAME  /data/www/wwwroot/typecho$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
这样设置就是我把本地typecho应用的域名设置www.example.com

转自:http://blog.csdn.net/shujuliu818/article/details/47065917
Ubuntu设置代理转发有多种方式,以下是其中两种常见的方法: 1. 使用 SSH 动态端口转发 如果你有一台可以访问互联网的服务器,并且该服务器可以通过 SSH 访问到需要代理的目标主机,那么可以使用 SSH 动态端口转发来实现代理转发。具体步骤如下: 1. 在本地 Ubuntu 主机上安装 SSH 客户端,如果没有安装可以使用以下命令安装: ``` sudo apt update sudo apt install openssh-client ``` 2. 在远程服务器上安装 SSH 服务端,如果没有安装可以使用以下命令安装: ``` sudo apt update sudo apt install openssh-server ``` 3. 在本地主机上通过 SSH 连接到远程服务器,并启动动态端口转发: ``` ssh -D 1080 user@remote_server ``` 其中 `user` 是远程服务器的用户名,`remote_server` 是远程服务器的 IP 地址或域名,`1080` 是本地主机上的代理端口号,你可以根据需要修改。 4. 在本地主机上设置代理服务器,将代理服务器地址设置为 `127.0.0.1`,端口号设置为 `1080`,具体方法取决于使用的应用程序。 2. 使用 Privoxy 另一种常见的方式是使用 Privoxy,它是一个可以将 HTTP 和 HTTPS 流量转发到代理服务器的代理转发工具。具体步骤如下: 1. 在本地 Ubuntu 主机上安装 Privoxy: ``` sudo apt update sudo apt install privoxy ``` 2. 修改 Privoxy 配置文件 `/etc/privoxy/config`,将以下两行取消注释并修改: ``` listen-address 127.0.0.1:8118 forward-socks5t / 127.0.0.1:1080 . ``` 其中 `127.0.0.1:8118` 是本地主机上的代理端口号,`127.0.0.1:1080` 是代理服务器的地址和端口号,你可以根据需要修改。 3. 启动 Privoxy 服务: ``` sudo service privoxy start ``` 4. 在本地主机上设置代理服务器,将代理服务器地址设置为 `127.0.0.1`,端口号设置为 `8118`,具体方法取决于使用的应用程序。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值