I have 2 points in 3d space, p1 and p2, and need to rotate a long object (long on x-axis) along its 3 axis (first x, then y and finally z) for it to be aligned to the p1-p2 line. Knowing both p1 and p2 coordinates, and the object's centre and rotation axis being exactly between p1 and p2, what would be rx, ry and rz ?
The rotation axis is a world axis and does not rotate with the object. Rotation applies first rx then ry then rz.


Given the world space joint axes are the ones being rotated around, you are basically solving $$M_1M_2M_3 v_1 = v_2$$ where $v_1$ is the position of whatever before rotation and $v_2$ the position after rotation and:
$$v_1 = \begin{bmatrix}{v_1}_x\\{v_1}_y\\{v_1}_z\end{bmatrix} \text{ and } v_2 = \begin{bmatrix}{v_2}_x\\{v_2}_y\\{v_2}_z\end{bmatrix}$$ and the matrices for rotation: $$M_1 =\begin{bmatrix}a_1&b_1&0\\-b_1&a_1&0\\0&0&1\end{bmatrix},M_2 =\begin{bmatrix}a_2&0&b_2\\0&1&0\\-b_2&0&a_2\end{bmatrix},M_3 =\begin{bmatrix}1&0&0\\0&a_3&b_3\\0&-b_3&a_3\end{bmatrix}$$ and $${a_i}^2 + {b_i}^2 = 1, i \in\{1,2,3\}$$
I am kind of sure this does not have any unique solution.
say the ortsvektors for $$P_2 = [3,5,7]^T\\ P_1 = [1,2,3]^T$$ then the $v_2$ to aim for should be $$v_2 = P_2-P_1 = [3-1,5-2,7-3]^T = [2,3,4]^T$$