Apache 将端口映射到公共目录

Apache 将端口映射到公共目录

我在虚拟机中有这个目录

/www/app1

我希望能够访问http://192.168.1.1:7778该目录

如何使用 CentOS 7 最小安装进行配置?我刚刚经历过 LAMP。

答案1

我想你的 apache 配置文件中有这一行:

listen: 80

在此行之后添加以下内容:

listen:7778

然后在虚拟主机定义下方添加以下内容

<VirtualHost *:7778>
  ServerAdmin someone@somehost
  DocumentRoot /www/app1
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
  Require all granted
</VirtualHost>

重新启动阿帕奇服务器

注意:这是一个最小的配置集,请注意,您必须注意虚拟主机中的几个安全指令

注2:apache配置文件可能是单个文件(即:)/etc/apache2/apache2.conf,也可能是经常位于以下位置的文件数组{apache_path}/sites-enabled/

答案2

root@machine1 httpd]# systemctl status httpd.service httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled) Active: failed (Result: exit-code) since Wed 2015-12-02 14:26:52 WET; 55s ago Process: 3257 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE) Process: 3256 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE) Main PID: 3256 (code=exited, status=1/FAILURE)

Dec 02 14:26:52 develop.wsclabs.com systemd[1]: Starting The Apache HTTP Server... Dec 02 14:26:52 machine1.domain.com httpd[3256]: AH00526: Syntax error on line 6 of /etc/httpd/sites-enabled/vh-test.conf: Dec 02 14:26:52 machine1.domain.com httpd[3256]: Require not allowed here Dec 02 14:26:52 machine1.domain.com systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE Dec 02 14:26:52 machine1.domain.com kill[3257]: kill: cannot find process "" Dec 02 14:26:52 machine1.domain.com systemd[1]: httpd.service: control process exited, code=exited status=1 Dec 02 14:26:52 machine1.domain.com systemd[1]: Failed to start The Apache HTTP Server. Dec 02 14:26:52 machine1.domain.com systemd[1]: Unit httpd.service entered failed state.

所以我编辑了 vh-test.conf 并评论了 require 行我现在收到此错误 httpd[3364]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80

试图解决这个问题

相关内容