在apache2服务器上,我最近从github克隆了一个应用程序'MyApp'。但是我无法通过url 133.29.22.57/MyApp/
访问它(ip地址是虚拟的)?我尝试将/var/www/
文件夹的权限设置为777,我还在myapp.conf
中创建了一个新文件etc/apache2/sites-available/
,然后我使用a2ensite
使其生效,然后重新启动服务器但是仍然无法访问该网站。请帮忙。
以下是我的myapp.conf
文件的内容:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/MyApp/
<Directory /var/www/MyApp/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
来自 apache2.conf
的一些(可能)相关信息Mutex file:${APACHE_LOCK_DIR} default
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
#
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
AccessFileName .htaccess
IncludeOptional conf-enabled/*.conf
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
更新
我在/var/log/apache2/access.log
...
169.149.128.75 - - [20/Mar/2017:12:30:49 +0000] "GET /MyApp HTTP/1.1" 404 497 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
169.149.128.75 - - [20/Mar/2017:12:31:01 +0000] "GET /MyApp/index.php HTTP/1.1" 404 507 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
169.149.128.75 - - [20/Mar/2017:12:31:05 +0000] "GET /MyApp/index.php HTTP/1.1" 404 506 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
169.149.128.75 - - [20/Mar/2017:12:31:40 +0000] "GET /MyApp/index.php HTTP/1.1" 404 507 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
::1 - - [20/Mar/2017:12:36:02 +0000] "OPTIONS * HTTP/1.0" 200 125 "-" "Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.21 (internal dummy connection)"
此外,
我尝试运行命令/usr/sbin/apache2 -V | grep SERVER_CONFIG_FILE
表示未定义以下变量:
${APACHE_LOCK_DIR} ${APACHE_PID_FILE } ${APACHE_RUN_GROUP } ${APACHE_LOG_DIR}
答案 0 :(得分:0)
将/var/www/
文件夹的权限设置为777
是非常糟糕的习惯。
将目录(递归)提供给Web服务器用户,通常是www-data
,例如&#34; chown -R www-data:www-data /var/www
&#34;
然后做一个单独的日志,比如&#34; mywebsite.error.log
&#34;和&#34; mywebsite.access.log
&#34;这样你就能快速看到正在发生的事情。
ErrorLog ${APACHE_LOG_DIR}/mywebsite.error.log
CustomLog ${APACHE_LOG_DIR}/mywebsite.access.log combined
然后更准确地告诉我们发生了什么,我会更新我的答案。