我在 HP550 笔记本电脑上安装 ubuntu 服务器版本 12.04 时遇到问题,当我尝试时sudo apt-get install <programname>
,apache2
它无法工作,显示E: Unable to locate package apache2
。
我尝试查看/编辑源代码。但它们不起作用,命令gedit
也坏了,我正在尝试gedit /etc/apt/sources.list
解决那些疑惑,这是计算机网络配置不正确的情况吗?虽然它在安装过程中很容易下载语言包。我该如何解决这个问题?如能尽快回复,我将不胜感激。
答案1
在尝试安装软件包之前尝试运行sudo apt-get update
。安装后系统没有最新的软件包列表,因此您将无法找到该软件包。
完成此操作后,您就可以正常安装。
答案2
检查你的 /etc/apt/sources.list
这是一例子sources.list 文件。我曾使用过该程序网络选择-apt为我选择最快的镜像。另外请注意,这是12.04/精确。
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirror.symnds.com/ubuntu/ precise main restricted
deb-src http://mirror.symnds.com/ubuntu/ precise main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirror.symnds.com/ubuntu/ precise-updates main restricted
deb-src http://mirror.symnds.com/ubuntu/ precise-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirror.symnds.com/ubuntu/ precise universe
deb-src http://mirror.symnds.com/ubuntu/ precise universe
deb http://mirror.symnds.com/ubuntu/ precise-updates universe
deb-src http://mirror.symnds.com/ubuntu/ precise-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirror.symnds.com/ubuntu/ precise multiverse
deb-src http://mirror.symnds.com/ubuntu/ precise multiverse
deb http://mirror.symnds.com/ubuntu/ precise-updates multiverse
deb-src http://mirror.symnds.com/ubuntu/ precise-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirror.symnds.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirror.symnds.com/ubuntu/ precise-backports main restricted universe multiverse
deb http://mirror.symnds.com/ubuntu/ precise-security main restricted
deb-src http://mirror.symnds.com/ubuntu/ precise-security main restricted
deb http://mirror.symnds.com/ubuntu/ precise-security universe
deb-src http://mirror.symnds.com/ubuntu/ precise-security universe
deb http://mirror.symnds.com/ubuntu/ precise-security multiverse
deb-src http://mirror.symnds.com/ubuntu/ precise-security multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
deb http://archive.canonical.com/ubuntu precise partner
deb-src http://archive.canonical.com/ubuntu precise partner
## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
deb http://extras.ubuntu.com/ubuntu precise main
deb-src http://extras.ubuntu.com/ubuntu precise main
更新您的 apt
sudo apt-get update
检查 apt 是否可以找到 apache2
sudo apt-cache search apache2
安装 apache2
sudo apt-get install apache2
可选的附加存储库
以下是一些选修的你可以继续添加到你的来源列表。
#Chromium
deb http://ppa.launchpad.net/chromium-daily/stable/ubuntu precise main
deb-src http://ppa.launchpad.net/chromium-daily/stable/ubuntu precise main
答案3
是的,尝试写入sudo apt-get update
这将下载源包列表。apache2 将出现在更新的列表中
答案4
我也遇到过这个问题,提示说需要先下载程序依赖包或者“包”才能在 Ubuntu 上安装该程序,你可以先试一下sudo apt-get update
。
我认为 Apache 是第三方供应商,因此这可能是 Ubuntu 找不到该软件包的原因。尝试访问 Apache 网站本身,并查找可以下载并使用 Ubuntu 打开的适用于 Ubuntu 或 Linux 的软件包。然后尝试sudo apt-get install <program>
希望这可以帮助。