  We apply the path-integral formalism to compute the anomalies in general
orbifold gauge theories (including possible non-trivial Scherk-Schwarz boundary
conditions) where a gauge group G is broken down to subgroups H_f at the fixed
points y=y_f. Bulk and localized anomalies, proportional to \delta(y-y_f), do
generically appear from matter propagating in the bulk. The anomaly zero-mode
that survives in the four-dimensional effective theory should be canceled by
localized fermions (except possibly for mixed U(1) anomalies). We examine in
detail the possibility of canceling localized anomalies by the Green-Schwarz
mechanism involving two- and four-forms in the bulk. The four-form can only
cancel anomalies which do not survive in the 4D effective theory: they are
called globally vanishing anomalies. The two-form may cancel a specific class
of mixed U(1) anomalies. Only if these anomalies are present in the 4D theory
this mechanism spontaneously breaks the U(1) symmetry. The examples of five and
six-dimensional Z_N orbifolds are considered in great detail. In five
dimensions the Green-Schwarz four-form has no physical degrees of freedom and
is equivalent to canceling anomalies by a Chern-Simons term. In all other
cases, the Green-Schwarz forms have some physical degrees of freedom and leave
some non-renormalizable interactions in the low energy effective theory. In
general, localized anomaly cancellation imposes strong constraints on model
building.
