MAC OS comes with OpenSSL, so you don't have to compile the same source code as shit. You can use OpenSSL directly on the command line.
Open the command-line tool and enter OpenSSL to open OpenSSL, and then just three commands to get it done. The first command generates the private key; the second command converts the RSA private key to the PKCS8 format, and the password is empty; The third command generates the public key.
Sticker Code No Nonsense
wangbindemacbook-pro:~ wangbin$ OpenSSL
Openssl> Genrsa-out Rsa_private_key.pem Here if the number of non-digits is 512 by default
Generating RSA private key, modulus bit long
.. ++++++++++++
.++++++++++++
E is 65537 (0x10001)
openssl> Genrsa-out RSA_PRIVATE_KEY.PEM 1024
Generating RSA private key, 1024x768 bit long modulus
.. ++++++
.......................++++++
E is 65537 (0x10001)
openssl> pkcs8-topk8-inform pem-in rsa_private_key.pem-outform pem-nocrypt Convert to Pkcs8
-----BEGIN PRIVATE KEY-----
Miicdgibadanbgkqhkig9w0baqefaascamawggjcageaaogbanrjczcxjgygmrbz
4xyg8yhyeb/fvchwmay0urxnnbpq1l53rfquglo/zm16o3bxx5ulgrl+wqkbmhpx
Uzazspcng5vzjxitinq8gzms9ogus8ozxbopsxrcfo1evlmfeht4hg0vjq2b6xd3
Kxdj/tr4hisizdai6reb3kvhhv7hagmbaaecgybyq6bkuqoojmdfks14gdpcsswp
Uu37ug+dhko2upps2ulpfpnmh145l7zouclcrczuplvq6xx77odh81upj/cui/t0
Cwnsobecp4qsfncihpkjeezjtcgxcuwhyz2eyeop/szb9rlk6ohjoa3h+xi1i2i2
Tzzjiotmevprlf/uaqjbaplk2vu9msadcook5rrbj57ghzdayurbpuoaaoampyzf
Uhn5srkzkdehmi2ihgxvwqi9ilgsr5ut2q4wogapflecqqdagfrhg2csuusahd48
Bzaxoryz08l2utpoyzttv7c3+e8s2n+xlvsx+ckupt8sfxjvn5mvq8h6xtemosw0
T+urakaxjnjetji+vomobps+chqv4f3hi/z8+jejgex/lhcs/ub+u/cl06nmrhtc
L/llk6w9cmwwjdywlozdoqq7y3hhakaguo5f4alg0b9dsnycuedtumfcatc4eobd
62qu6pefeqqnxhxqqje6n+fspvunfd6qbq63hrmhigyctaukxbxbakeaxdpbfb3b
Mkyjvoxolvijotiny1e78bk4vokr4htlq8cubg1vwukogelhbg24jprgs3krsobk
5pyow+dhtbftyw==
-----END PRIVATE KEY-----
openssl> rsa-in rsa_private_key.pem-pubout-out RSA_PUBLIC_KEY.PEM output Public key
Writing RSA Key
Openssl>
The above describes the Mac using OpenSSL to generate public and private keys, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.