2014-10-21 19 views
7

Hôm qua tôi đã nâng cấp lên Yosemite và giờ đây cấu hình cục bộ của tôi để phát triển web không hoạt động nữa.Cấu hình Apache bị hỏng sau khi nâng cấp lên Yosemite

Tôi đã quản lý để thiết lập userdir theo /Users/user/public_html và tôi có thể truy cập tất cả các trang web qua localhost/~user/websitename. Không có gì đặc biệt, nhưng tôi mất một thời gian để cấu hình.

Tìm trong thư mục apache Tôi thấy rằng nhiều tệp đã được thay thế, giữ một bản sao lưu. Tôi đã thử đặt lại các tập tin với các thiết lập của tôi một lần nữa, nhưng vẫn không hoạt động. Có lẽ tôi đang thiếu một số tập tin mà tôi không nhớ.

Đây là httpd-userdir.conf:

# Settings for user home directories 
# 
# Required module: mod_userdir 

# 
# UserDir: The name of the directory that is appended onto a user's home 
# directory if a ~user request is received. Note that you must also set 
# the default access control for these directories, as in the example below. 
# 
UserDir public_html 

# 
# Users might not be in /Users/*/Sites, so use user-specific config files. 
# 
Include /private/etc/apache2/users/*.conf 
<IfModule bonjour_module> 
     RegisterUserSite customized-users 
</IfModule> 

<Directory "/Users/*/public_html/"> 
    AllowOverride FileInfo AuthConfig Limit Indexes 
     Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec 
     Order allow,deny 
     Allow from all 
</Directory> 

Sau đó, trong http.conf tôi đã kích hoạt một số module:

Include /private/etc/apache2/extra/httpd-userdir.conf 
LoadModule userdir_module libexec/apache2/mod_userdir.so 

và điều này:

DocumentRoot "/ Users/user/public_html "

Directory "/Users/user/public_html"> 
    # 
    # Possible values for the Options directive are "None", "All", 
    # or any combination of: 
    # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews 
    # 
    # Note that "MultiViews" must be named *explicitly* --- "Options All" 
    # doesn't give it to you. 
    # 
    # The Options directive is both complicated and important. Please see 
    # http://httpd.apache.org/docs/2.2/mod/core.html#options 
    # for more information. 
    # 
    Options Indexes FollowSymLinks MultiViews 

    # 
    # AllowOverride controls what directives may be placed in .htaccess files. 
    # It can be "All", "None", or any combination of the keywords: 
    # Options FileInfo AuthConfig Limit 
    # 
    AllowOverride all 

    # 
    # Controls who can get stuff from this server. 
    # 
    Order allow,deny 
    Allow from all 

</Directory> 

Nếu tôi chỉ đơn giản là cố gắng truy cập localhost, nó sẽ hiển thị thông báo "Nó hoạt động!". Nếu tôi truy cập localhost/user chỉ đơn giản là không tải và giống nhau nếu tôi cố truy cập một trong các trang web.

Tôi có bỏ lỡ bất kỳ tệp nào không? Trong nhật ký apache nó thậm chí không hiển thị bất kỳ lỗi nào.

+2

Nâng cấp Yosemite Apache từ 2,2 lên 2,4. Cấu hình đã thay đổi. Bạn đã bật mô-đun mod_userdir chưa? Ngoài ra, bạn sẽ muốn thay đổi chỉ thị "Đơn hàng" và "Cho phép" của mình. Bạn có thể muốn xem lại các nguyên tắc nâng cấp http://httpd.apache.org/docs/2.4/upgrading.html –

+1

Người đọc trong tương lai có thể muốn bắt đầu với [cài đặt Apache, PHP và MySQL trên Mac OS X Yosemite] (http: //jason.pureconcepts.net/2012/10/install-apache-php-mysql-mac-os-x/) cách * đúng cách *. –

+0

Ngoài ra, hãy đọc [https://discussions.apple.com/thread/6602475#26885389] (https://discussions.apple.com/thread/6602475#26885389) – luisnicg

Trả lời

18

OS X 10.10 Yosemite đi kèm với Apache 2.4 thay vì Apache 2.2 ở Mavericks.
Sự khác biệt lớn trong cấu hình là bạn phải thay thế ...

Order allow,deny 
Allow from all 

... với ...

Require all granted 

của Xem Apache doc thủ Upgrading to 2.4 from 2.2 để biết thêm chi tiết.

UPDATE:
Xin lưu ý rằng sau khi nâng cấp OS X bạn sẽ thường thấy tập tin cấu hình cũ của bạn như sao lưu bên cạnh ứng dụng mới được viết bởi Yosemite. Chúng được dán nhãn, ví dụ: httpd.conf.pre-update và/hoặc httpd.conf ~ trước đây và có thể được tìm thấy trong cùng đường dẫn với cấu hình mới (ví dụ: /private/etc/apache2).

+0

Bỏ ghi chú hai dòng này đề cập đến userdir trong httpd. conf, uncommenting Bao gồm trong httpd-userdir.conf và thực hiện thay đổi ở trên trong Guest.conf cuối cùng đã cố định các ~ Guest trang cho tôi. Cảm ơn! – lionello

+0

Tôi không thấy bất kỳ chuỗi 'Order' hoặc' Allow' nào trong bất kỳ tệp cấu hình Apache nào của tôi ... – Michael

+1

@Michael nếu bạn thực hiện cài đặt Apache 2.4 sạch sẽ, bạn sẽ không tìm thấy bất kỳ lệnh Order hoặc Allow nào. Nhưng nếu bạn tiếp quản một cấu hình hiện có từ Apache 2.2, bạn chắc chắn sẽ tìm thấy chúng trong httpd.conf (ví dụ như sau dòng chỉ thị DocumentRoot) cũng như trong httpd-vhosts.conf (nếu bạn sử dụng các máy chủ ảo). – Jpsy

1

Sau khi cố khắc phục sự cố này trong 6 giờ, tôi cuối cùng cũng có thể làm việc này. Tôi đã chỉnh sửa httpd.conf, httpd-userdir.conf, httpd-vhosts.conf, v.v. không có kết quả. Để lại tất cả các tệp này chưa được chỉnh sửa từ cấu hình yosemite, những gì cuối cùng làm việc cho tôi là chỉnh sửa httpd_server_app.conf tọa lạc tại /Library/Server/Web/Config/apache2/ bằng cách thêm những điều sau đây (cho mỗi trang web) như sau:

<Directory /> 
 
\t Options +FollowSymLinks 
 
\t AllowOverride All 
 
\t Order deny,allow 
 
\t Deny from all 
 
</Directory> 
 

 
<Directory "/Library/Server/Web/Data/Sites/Default/"> 
 
\t Options +Indexes +FollowSymLinks +MultiViews 
 
\t AllowOverride All 
 
\t Order allow,deny 
 
\t Allow from all 
 
</Directory> 
 

 
<Directory "/Library/Server/Web/Data/Sites/[OTHER SITE DIRECTORY]/"> 
 
\t Options +Indexes +FollowSymLinks +MultiViews 
 
\t AllowOverride All 
 
\t Order allow,deny 
 
\t Allow from all 
 
</Directory>

Hãy chắc chắn rằng nếu bạn sử dụng TextEdit để chỉnh sửa tập tin này, bạn hoàn tác chèn tự động báo giá nghiêng nếu không bạn sẽ nhận được một thông báo lỗi unicode.

Hy vọng điều này sẽ hữu ích!

Các vấn đề liên quan