Variation of a field action The field action in flat spacetime is
$$ S = \int d^4x\, \mathcal{L}(\phi,\partial_\mu\phi).\tag{1} $$
The variation in $S$ leads to
$$ \delta S = \int d^4x\, \delta \mathcal{L}. \tag{2} $$
Proceeding this way, one gets the Euler-Lagrange thing upon integration by parts
$$ \delta \mathcal{L} = \frac{\partial\mathcal{L}}{\partial\phi}\delta\phi + \frac{\partial\mathcal{L}}{\partial(\partial\phi)}\delta(\partial\phi).\tag{3}  $$
But in many places, people also write
$$ \delta S = \int d^4x \frac{\delta S}{\delta \phi} \delta\phi. \tag{4} $$
I am confused by this way of writing. How is it consistent with the second equation? Also on the RHS, isn't $$\frac{\delta S}{\delta \phi} \delta\phi=\delta S~?\tag{5} $$  So what is the integral sign doing here?
 A: I guess the confusion is caused by (implicitly) different variables and their associated derivatives. I'll stick to the action of a single classical scalar real field in the following, and try a heuristic explanation.


*

*In a global view,  the action is a function of the field, $S\!\left(\phi\right)$. Here, $\phi$ denotes the 'complete' field, i.e. the function
$$\phi: \mathbb{R}^4\to \mathbb{R}$$
(or potentially a subset of $\mathbb{R}^n$, and $\mathbb{C}$ on the right). Hence, $\phi$ is a single variable, but taken from an infinite-dimensional space, and we can think about the derivative
$$\frac{\delta S(\phi)}{\delta \phi}\,,$$
measuring how much $S$ varies as $\phi$ is changed. This is again a number for each field $\phi$, i.e. a function on the space of fields. We're using $\delta$'s here to point out that it is not a simple partial derivative (this is historical, similar to the use of square brackets and the name 'functional'). Note that at this point, it doesn't make much sense to put coordinates on the $\phi$, nor to separately differentiate with respect to derivatives of $\phi$ - if the function $\phi$ is given, its derivatives are fixed.

*From a local/Lagrangean point of view, we also assume that the action is given by a single spacetime integral as 
$$S(\phi)=\int \text{d}^4x\,\mathscr{L}\!\left(\phi(x),\partial_\mu\phi(x)\right)\,.$$
Here $\mathscr{L}$ is a function of $\phi$ and its derivatives, all evaluated at the same point $x$ (that's locality, basically). In other words, $\mathscr{L}$ can be thought of as a function of five real numbers (the field and four derivatives). Now the variation of the action can be expressed more explicitly as
$$\frac{\delta S(\phi)}{\delta \phi}=\int \text{d}^4x\, \left(\frac{\partial\mathscr{L}\!\left(\phi(x),\partial_\mu\phi(x)\right)}{\partial(\phi(x))}  - \partial_\mu\frac{\partial\mathscr{L}\!\left(\phi(x),\partial_\mu\phi(x)\right)}{\partial(\partial_\mu \phi(x))}\right)\,.$$
Here, the derivative in the integral are simple partial derivatives of the function $\mathscr{L}$ with respect to its five arguments. 

*Finally, we can have a mixed viewpoint, basically a variation of the first one: We consider the field $\phi$ to be a collection of uncountably many field values $\phi(x)$, so that $x$ is just a label (similar to how a function of a vector $\vec{v}$ can be regarded as a function of $d$ numbers $v_i$ labelled by the index $i$). Now we can even differentiate $S$ with respect to field values at given points. For an action given by the integral of a Lagrangean, we have
$$\frac{\delta S(\phi)}{\delta \phi(x)}=\frac{\partial\mathscr{L}\!\left(\phi(x),\partial_\mu\phi(x)\right)}{\partial(\phi(x))}  - \partial_\mu\frac{\partial\mathscr{L}\!\left(\phi(x),\partial_\mu\phi(x)\right)}{\partial(\partial_\mu \phi(x))}\,,$$
i.e. the derivative wrt $\phi(x)$ is an expression localised at $x$.
Combining this expression and the previous one, we can write the variation of the action as 
$$\delta S= \int \text{d}^4x\,\frac{\delta S(\phi)}{\delta \phi(x)} \delta \phi(x)\,.$$
When you drop the $x$'s, this looks almost like the first expression - but you still integrate over $x$, so the argument is a function of spacetime.


The different notions of variables, $\delta$'s and $\partial$'s  (and later $\mathscr{D}$'s!) can be confusing, but usually it becomes clear from the context what is meant.
A: I think its best to first remember the finite-dimensional case and then we generalize.

*

*Consider a function of a single variable $f(\phi)$. Note here that $\phi$ is a real number, NOT a function. I am using this notation so I can generalize later. Its variation is given by
$$
\delta f = f'(\phi) \delta \phi \tag{1}
$$

*Now lets generalize to a function of multiple variables $f(\phi_1 , \cdots , \phi_n)$. Its variation is given by
$$
\delta f = \sum_{i=1}^n \frac{ \partial f }{ \partial \phi_i} \delta \phi_i \tag{2}
$$

*We can now generalize to infinitely many variables. In this case, the function becomes what we call a "functional" $f[\phi(x)]$. Here, we are thinking of $\phi(x)$ as collectively describing infinitely many variables -- one variable for each $x$. Then, the sum over $i$ in (2) becomes an integral over $x$ so we have
$$
\delta f = \sum_{i=1}^n \frac{ \partial f }{ \partial \phi_i} \delta \phi_i \quad \longrightarrow \quad \int dx \frac{ \partial f }{ \partial \phi(x)} \delta \phi(x) . \tag{3} 
$$

*Finally, we can generalize to functionals which depend on functions of multiple variables so $f[\phi(x_1,\cdots ,x_n) ]$. In this case, we have
$$
\delta f = \int d^n x \frac{ \partial f }{ \partial \phi(x)} \delta \phi(x) . \tag{4}
$$
Also, please look at the notation very carefully. On the LHS, we have a variation denoted by $\delta$ whereas on the RHS, we have a partial derivative w.r.t. $\phi$ - not a variational derivative. If the function $f$ depends on $\phi$ AND ${\partial_\mu \phi}$, then the formula further generalizes
$$
\delta f = \int d^n x \left[ \frac{ \partial f }{ \partial \phi(x)} \delta \phi(x) + \frac{ \partial f }{ \partial ( \partial_\mu \phi(x) ) } \partial_\mu  \delta  \phi(x) \right] .
$$
A: According to Ortin, Gravity & Strings (Chapter 2), we define 
$$\dfrac{\delta S}{\delta \phi} \equiv \dfrac{\partial \mathcal{L}}{\partial \phi} - \partial_\mu \bigg(\dfrac{\partial \mathcal{L}}{\partial(\partial_\mu\phi)}\bigg)$$
Now, as you can easily see, 
$$\delta S = \displaystyle\int d^4x \bigg(\dfrac{\partial \mathcal{L}}{\partial \phi} \delta \phi - \dfrac{\partial \mathcal{L}}{\partial(\partial_\mu\phi)} \delta (\partial_\mu \phi)\bigg) $$
$$= \displaystyle\int d^4x  \bigg(\dfrac{\partial \mathcal{L}}{\partial \phi} - \partial_\mu \bigg(\dfrac{\partial \mathcal{L}}{\partial(\partial_\mu\phi)}\bigg)\bigg) \delta \phi $$
$$=\displaystyle\int d^4x \dfrac{\delta S}{\delta \phi} \delta \phi$$
Edit From this answer, I realize that we don't really need to define an explicit $\dfrac{\delta S}{\delta \phi}$. Rather, we can derive it from the definition of $S$ as it should be the case. Based on the answer linked above, I derive here $\dfrac{\delta S}{\delta \phi}$ in the simplest manner apparent to me. The key is to realize that there is an implicit label associated with $\phi$ which decides what $\phi$ we are talking about - the label is the coordinates $x$. 
$$S=\displaystyle\int d^4x \mathcal{L}(\phi(x), \partial_\mu \phi(x)) $$
$$\delta S = \displaystyle\int d^4x \bigg(\dfrac{\partial \mathcal{L}}{\partial \phi (x)} \delta \phi(x) - \dfrac{\partial \mathcal{L}}{\partial(\partial_\mu\phi(x))} \delta (\partial_\mu \phi(x))\bigg) $$
$$= \displaystyle\int d^4x  \bigg(\dfrac{\partial \mathcal{L}}{\partial \phi(x)} - \partial_\mu \bigg(\dfrac{\partial \mathcal{L}}{\partial(\partial_\mu\phi(x))}\bigg)\bigg) \delta \phi(x) $$
Now, since $x$ is already used in the integration and it runs over all of spacetime, we should use a different variable for coordinate label when we want to define $\dfrac{\delta S}{\delta \phi}$ which is the variation of action with respect to variation in the field at any point in spacetime. Let's use $y$ to denote coordinates of this point where we vary the field and notice the variation in action. 
$$\dfrac{\delta S}{\delta \phi} = \dfrac{\delta S}{\delta \phi (y)}$$
$$= \displaystyle\int d^4x  \bigg(\dfrac{\partial \mathcal{L}}{\partial \phi(x)} - \partial_\mu \bigg(\dfrac{\partial \mathcal{L}}{\partial(\partial_\mu\phi(x))}\bigg)\bigg) \dfrac{\delta \phi(x)}{\delta \phi(y)} $$
$$= \displaystyle\int d^4x  \bigg(\dfrac{\partial \mathcal{L}}{\partial \phi(x)} - \partial_\mu \bigg(\dfrac{\partial \mathcal{L}}{\partial(\partial_\mu\phi(x))}\bigg)\bigg) \delta (x -y) $$
$$=\dfrac{\partial \mathcal{L}}{\partial \phi(y)} - \partial_\mu \bigg(\dfrac{\partial \mathcal{L}}{\partial(\partial_\mu\phi(y))}\bigg)$$
So, $$\dfrac{\delta S}{\delta \phi(y)} = \dfrac{\partial \mathcal{L}}{\partial \phi} - \partial_\mu \bigg(\dfrac{\partial \mathcal{L}}{\partial(\partial_\mu\phi)}\bigg)$$
And, thus, $$\delta S = \displaystyle\int d^4x  \bigg(\dfrac{\partial \mathcal{L}}{\partial \phi(x)} - \partial_\mu \bigg(\dfrac{\partial \mathcal{L}}{\partial(\partial_\mu\phi(x))}\bigg)\bigg) \delta \phi(x) $$
$$=\displaystyle\int d^4x \dfrac{\delta S}{\delta \phi(x)} \delta \phi(x)$$
Or, concisely, ${\delta S} = \displaystyle \int d^4x \dfrac{\delta S}{\delta \phi} \delta \phi$.
