37 lines
1.5 KiB
Markdown
37 lines
1.5 KiB
Markdown
要在Ubuntu上使用代理服务器来进行apt操作,可以按照以下步骤进行配置:
|
||
|
||
1. 打开终端,并进入`/etc/apt`目录:
|
||
```shell
|
||
cd /etc/apt
|
||
```
|
||
|
||
2. 创建一个新的文件或编辑已有的文件,例如`apt.conf.d/99proxy`:
|
||
```shell
|
||
sudo nano apt.conf.d/99proxy
|
||
```
|
||
|
||
3. 在打开的文件中添加以下内容,将代理服务器的地址和端口替换为实际的代理服务器信息:
|
||
```shell
|
||
Acquire::http::Proxy "http://proxy-server-address:proxy-port";
|
||
Acquire::https::Proxy "http://proxy-server-address:proxy-port";
|
||
```
|
||
|
||
4. 保存并关闭文件(使用Ctrl + X,然后按Y确认保存)。
|
||
|
||
5. 现在,您可以尝试运行任何apt命令,例如更新软件包列表:
|
||
```shell
|
||
sudo apt update
|
||
```
|
||
|
||
注意:如果代理服务器需要用户名和密码进行身份验证,您还需要添加额外的配置。在步骤3中,将http和https行更改为如下所示,并替换`username`和`password`为实际的凭据:
|
||
```shell
|
||
Acquire::http::Proxy "http://username:password@proxy-server-address:proxy-port";
|
||
Acquire::https::Proxy "http://username:password@proxy-server-address:proxy-port";
|
||
```
|
||
|
||
这样就完成了在Ubuntu上使用代理服务器进行apt操作的配置。确保替换`proxy-server-address`和`proxy-port`为实际的代理服务器地址和端口,并根据需要进行身份验证的配置。
|
||
|
||
```shell
|
||
Acquire::http::Proxy "http://192.168.8.102:10811";
|
||
Acquire::https::Proxy "http://192.168.8.102:10811";
|
||
``` |