如何在Ubuntu上安装Apache Http服务器

有两种方法可以在Ubuntu上安装Apache Http服务器:

  1. 使用apt命令自动安装。
  2. 配置和构建源代码,然后手动安装。

1.自动安装

1.使用“ apt-cache search”命令搜索Apache软件包

apt-cache search apache

2.获得Apache软件包名称“ apache2”,发出“ apt-get”安装命令。 您需要“ sudo”特权才能进行此安装。

sudo apt-get install apache2

3.完成后,运行您喜欢的Internet浏览器,例如firefox或IE。 在浏览器的URL文本框中输入“ http:// localhost ”。

4.如果看到“有效”字样。 在您的浏览器中,这意味着Apache已成功安装在Ubuntu上。

Apache Http服务器安装在哪里?
发出“ find ”命令以显示所有Apache文件夹和文件的位置。

mkyong@mkyong-desktop:~$ sudo find / -name apache2
/var/lock/apache2
/var/run/apache2
/var/log/apache2
/var/cache/apache2
/usr/sbin/apache2
/usr/lib/apache2
/usr/share/doc/apache2
/usr/share/doc/apache2.2-common/examples/apache2
/usr/share/apache2
/usr/share/bug/apache2
/etc/default/apache2
/etc/logrotate.d/apache2
/etc/cron.daily/apache2
/etc/init.d/apache2
/etc/apache2

2.手动安装

1.从Apache网站(例如httpd-2.2.13.tar.gz)下载Apache Http服务器 。

2.使用“ tar”命令将其解压缩。

tar xvfz httpd-2.2.13.tar.gz

3.使用“ ./configure”命令配置文件夹位置。

./configure --prefix=/usr/local/apache --enable-shared=max

注意
选项–prefix表示服务器将安装的路径,并且–enable-shared激活了负载模块支持,最好在安装阶段将其打开,以备将来扩展或自定义功能而无需重新编译服务器。

4.使用“ make”命令进行构建。

make

5.使用“ install”命令安装它,此安装需要“ sudo”特权。

sudo make install

6.完成后,所有Apache http服务器的文件和文件夹都位于/ usr / local / apache。

您应该手动还是自动安装?

这实际上取决于您的需求以及您的专业知识。 “ apt-get”命令正确分配所有文件夹结构,在init.d文件中创建启动脚本,并自动配置许多安装后设置。 如果您懒惰并且不关心文件夹结构,那么绝对是最佳选择。

但是,如果要在安装过程中自定义Apache文件夹结构,并且需要完全控制计算机中发生的情况,则需要手动方式。 对我来说..懒惰的apt-get安装是更快的方法way

翻译自: https://mkyong.com/apache/how-to-install-apache-http-server-in-ubuntu/

你可能感兴趣的:(如何在Ubuntu上安装Apache Http服务器)