By wrapping the wire along a solenoid and connecting it to electricity
If you wrap a copper wire into coils and run an electrical current through it, you will create a magnetic field. If you rotate a permanent magnet as opposed to an item that has been magnetized inside a coil of copper wire, you can create an electrical current. The strength of magnetic field generated is proportional to the amount of current through the winding.