简体   繁体   English

Apache httpd安装后缺少var目录

[英]Missing var directory after Apache httpd installation

I installed apache httpd on my linux vm and wanted to start it's service. 我在我的linux vm上安装了apache httpd,并希望启动它的服务。 BUt I'm getting error (13)Permission denied. Error retrieving pid file run/httpd.pid BUt我收到错误(13)Permission denied. Error retrieving pid file run/httpd.pid (13)Permission denied. Error retrieving pid file run/httpd.pid I realised that I do not have this file. (13)Permission denied. Error retrieving pid file run/httpd.pid我意识到我没有这个文件。 Not even a var directory. 甚至不是var目录。 Any solutions for this? 对此有何解决方案? Pardon me, this is my first time touching servers. 请原谅,这是我第一次接触服务器。

I installed the apache like this: 我像这样安装了apache:

gzip -d httpd-2.2.21.tar.gz

tar xvf httpd-2.2.21.tar

./configure --prefix=/home/Hend/Desktop/Server

make

make install

You have several alternatives for this: 你有几种选择:

Install apache in user directory, run as non-root user 在用户目录中安装apache,以非root用户身份运行

This is the way you started doing that. 这是你开始这样做的方式。 But then you'll have to: 但是你必须:

  • Add some customizations to the start script, or at least pass it enough environment variables to tell him where configuration / pidfile / etc. are 向启动脚本添加一些自定义,或者至少传递足够的环境变量以告诉他配置/ pidfile /等在哪里
  • Modify the whole apache configuration, since the default uses directories to which you don't have access. 修改整个apache配置,因为默认使用您无权访问的目录。 For example, you should put your DocumentRoot somewhere else thant /var/www 例如,您应该将DocumentRoot放在/var/www
  • Run the server on a non-standard port. 在非标准端口上运行服务器。 Since unprivileged users cannot run services on ports lower than 1024, you must run apache on another port, such as 8000 instead of 80 . 由于非特权用户无法在低于1024的端口上运行服务,因此必须在另一个端口上运行apache,例如8000而不是80 But this way, all your URLs will look like http://example.com:8000 instead of http://example.com . 但是这样,您的所有网址都会显示为http://example.com:8000而不是http://example.com

Install apache from sources, into /usr/local 从源安装apache到/usr/local

You can install apache in the default path for non-part-of-distro stuff, that is /usr/local instead of /usr/ . 您可以在非分区发布内容的默认路径中安装apache,即/usr/local而不是/usr/ That is, use --prefix=/usr/local/ when running configure . 也就是说,在运行configure时使用--prefix=/usr/local/ This way, things should be much simpler. 这样,事情应该简单得多。 In any case, you'll have to run the webserver from root, and configure it to change user only after socket is opened. 在任何情况下,您都必须从root运行Web服务器,并将其配置为仅在打开套接字后更改用户。

Install apache from sources, into /usr/ 从源代码安装apache到/usr/

You can also install apache in its default location, usint --prefix=/usr/ . 您还可以在其默认位置usint --prefix=/usr/安装apache。 This way things should be much simpler, it should install init scripts in the usual location /etc/init.d/apache2 or /etc/init.d/httpd , configuration in /etc/apache2 etc. Beware that doing this all the apache installed files will conflict with the ones of the version provided by your linux distribution! 这样事情应该简单得多,它应该在通常的位置/etc/init.d/apache2/etc/init.d/httpd /etc/apache2配置/etc/apache2安装init脚本。请注意这样做所有的apache安装的文件将与您的Linux发行版提供的版本冲突!

Install apache from your distribution package manager 从分发包管理器安装apache

A part from the case in which you want particular setups (for example with non-standard patches), particular non-packaged versions (not recommended, since usually versions packaged with distros are guaranteed to be stable, others are not). 您需要特定设置(例如非标准补丁)的情况下的部分,特别是非打包版本(不推荐,因为通常与发行版打包的版本保证稳定,而其他版本不保证)。

Benefits of doing this: 这样做的好处:

  • Avoid huge setup + configuration process to make it work 避免巨大的设置+配置过程使其工作
  • Versions from your distro should be "guaranteed" to be stable and tested with all the other programs shipped with it. 您的发行版中的版本应该“保证”稳定并使用随附的所有其他程序进行测试。 Not always the latest version is better. 并不总是最新版本更好。
  • Each time a new release is updated (or more importantly, there is a security update), you can upgrade it semi-automatically by running a single upgrade command, without worrying about things going wrong during update. 每次更新新版本时(或者更重要的是,有安全更新),您可以通过运行单个升级命令半自动升级它,而无需担心更新期间出现问题。
  • This way the whole installation is just matter of a couple commands. 这样整个安装只需要几个命令。

For example, on debian: 例如,在debian上:

apt-get install apache2

On fedora: 关于fedora:

yum install httpd

etc. 等等

Then, if the service is not already started by package manager, you can start it with 然后,如果包管理器尚未启动该服务,则可以启动它

/etc/init.d/apache2 start

or 要么

/etc/init.d/httpd start

Job done. 任务完成。 Now just put stuff in /var/www/ (or equivalent directory, depends on distro) and see it through you web server. 现在只需将内容放入/var/www/ (或等效目录,取决于发行版)并通过您的Web服务器查看。

You have to start apache as root 你必须以root身份启动apache

Have you read the docs in the source distribution? 您是否阅读过源代码分发中的文档?

ie INSTALL 即安装

less INSTALL

  For complete installation documentation, see [ht]docs/manual/install.html or
  http://httpd.apache.org/docs/2.2/install.html

     $ ./configure --prefix=PREFIX
     $ make
     $ make install
     $ PREFIX/bin/apachectl start

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM