Here is a locally Noetherian separated counterexample. I also give some motivation for this construction afterwards.

**Definition.** Let $Z$ be an infinite chain of affine lines: $Z = Z_1 \amalg_{p_1} Z_2 \amalg_{p_2} \ldots$, where $Z_i \cong \mathbf A^1_{\mathbf C}$ and $p_i$ is the point $1$ in $Z_i$ and the point $0$ in $Z_{i+1}$. Let $Y = \mathbf P^2_Z$, which is clearly projective over $Z$. Write $Y_i = Z_i \times_Z Y$ for the irreducible component of $Y$ above $Z_i$, with structure map $g_i \colon \mathbf A^1 \times \mathbf P^2 \cong Y_i \to Z_i \cong \mathbf A^1$.

Finally, let $X$ be obtained by blowing up $Y_i$ at $i$ collinear points $W_i \subseteq \mathbf A^1 \times \mathbf P^2$ in the fibre $g_i^{-1}(2)$ for all $i$ (the only thing that matters is that we choose a point $2$ that is not one of the glueing points $0$ and $1$). Then $f \colon X \to Y$ is projective because $X \subseteq \mathbf P(\mathcal I_W)$ is a closed immersion, where $W = \bigcup_i W_i \subseteq Y$ is the closed subvariety we're blowing up and $\mathcal I_W$ its ideal sheaf (which is of finite type because that's a local condition).

**Notation.** Write $h = g \circ f \colon X \to Z$, and once again write $X_i = Z_i \times_Z X$ for the irreducible component of $X$ above $Z_i$. Denote the maps $X_i \to Y_i$ and $X_i \to Z_i$ by $g_i$ and $h_i$ respectively.

**Proposition.** *The map $X \to Z$ is not projective.*

We will show that there is no $h$-ample line bundle on $X$ by computing all line bundles on $X$. Note that for any open $U \subseteq Z_i \cong \mathbf A^1$, we have $\operatorname{Pic}(U \times \mathbf P^2) \cong \operatorname{Pic}(\mathbf P^2)$ by pullback.

**Lemma.** *The projection $\pi \colon Y = X \times \mathbf P^2 \to \mathbf P^2$ induces an isomorphism
$$\pi^* \colon \operatorname{Pic}(\mathbf P^2) \stackrel\sim\to \operatorname{Pic}(Y).$$*

*Proof.* Indeed, $\pi^*$ is injective since $\pi$ has a section. Every $\mathscr L$ on $Y$ restricts to some $\mathcal O_{Y_i}(n_i)$ on each $Y_i$, which has to be the same $n_i = n$ for all $i$ by restricting to $Y_i \cap Y_{i+1} = p_i \times \mathbf P^2$. We can choose identifications $\mathscr L|_{Y_i} \cong \mathcal O_{Y_i}(n)$ compatibly for all $i$ starting with $i = 1$ and moving through the chain. At any stage we might have to modify the chosen identification on $Y_{i+1}$ by an element of $\operatorname{Aut}(\mathscr L|_{p_i \times \mathbf P^2}) = \mathbf C^\times$, which is harmless because there are no loops. $\square$

By the same reasoning, any line bundle on $X$ is pulled back from $\mathbf P^2$ away from $\bigcup_i h_i^{-1}(2)$, so it suffices to glue line bundles on the open covering consisting of the locus $U = X \setminus \bigcup_i h_i^{-1}(2)$ where $f \colon X \to Y$ is an isomorphism, and the opens
$$U_i = X_i \setminus h_i^{-1}\Big(\{p_{i-1},p_i\}\Big)\cong \operatorname{Bl}_{W_i} \bigg(\left(\mathbf A^1 \setminus \{0,1\} \right) \times \mathbf P^2\bigg)$$
consisting of $X_i$ minus its intersections with $X_{i-1}$ and $X_{i+1}$.

**Corollary.** *We have
$$\operatorname{Pic}(X) \cong \operatorname{Pic}(\mathbf P^2) \times \prod_{i=1}^{\infty} \prod_{r = 1}^i \mathbf Z E_{i,r}.$$*

*Proof.* We have $\operatorname{Pic}(U_i) \cong \operatorname{Pic}(\mathbf P^2) \times \prod_{r = 1}^i \mathbf Z E_{i,r}$ where the $E_{i,r}$ are the exceptional divisors above the $i$ points of $W_i$. The result now from the description above by glueing on $U$ and the $U_i$, since there is no compatibility condition between the coefficients in $E_{i,r}$ and $E_{i',r'}$ if $i \neq i'$. $\square$

*Proof of Proposition.* Now suppose $\mathscr L = (n,n_{i,r}) \in \operatorname{Pic}(X)$ is $h$-ample. In particular this implies that $\mathscr L|_{h^{-1}(z)}$ is ample for each $z \in Z$. Apply this to $z = 2 \in Z_i$ to get $nH + \sum_{r = 1}^i n_{i,r}E_{i,r}$ ample on $h_i^{-1}(2)$. But the fibre $h_i^{-1}(2)$ contains the strict transform $\operatorname{Bl}_{W_i}(\mathbf P^2)$ of the fibre $g_i^{-1}(2) \cong \mathbf P^2$ as a closed subvariety, and the restriction of $E_{i,r}$ to $\operatorname{Bl}_{W_i}(\mathbf P^2)$ is the $r^{\text{th}}$ exceptional divisor $E_r$ of $\operatorname{Bl}_{W_i}(\mathbf P^2) \to \mathbf P^2$.

So $nH + \sum_{r = 1}^i n_{i,r}E_r$ has to be ample on $\operatorname{Bl}_{W_i}(\mathbf P^2)$. Since $E_r \cdot E_{r'} = -\delta_{r,r'}$ and $E_r \cdot H = 0$, we must have $n_{i,r} < 0$. If $\ell$ is the strict transform of the line through $W_i$ (which are collinear by assumption), then $\ell \cdot E_r = 1$ and $\ell \cdot H = 1$. Hence, $(nH + \sum n_{i,r}E_r)\cdot \ell > 0$ forces $n > -\sum n_{i,r} \geq i$. Since $i$ is arbitrary, this is impossible. $\square$

**Motivation.** The idea behind the construction is as follows. As I commented above, if $Z$ is affine, $\mathscr L$ is $f$-ample on $X$ and $\mathscr M$ is $g$-ample on $Y$, there is some $a$ such that $\mathscr L \otimes f^* \mathscr M^{\otimes a}$ is $(g \circ f)$-ample by Tag 0C4K. For $Z$ quasi-compact, you can choose this $a$ uniformly over all affines, but in general you might need a bigger and bigger $a$.

The first thing you try is $Z$ an infinite disjoint union of points, where you need a bigger and bigger $a$ on each component (for example when you blow up more and more collinear points in $\mathbf P^2$). But this doesn't work because in a disjoint union you have too much freedom to choose a completely different line bundle on $X$ that does the job ("you can choose a different $a_i$ per component").

However, if you put yourself in a situation where

- you can compute $\operatorname{Pic}(X)$, and
- there is a reason why all the $a_i$ have to be the same for
*any* line bundle on $X$,

then you can make this into an argument leading to a contradiction.