ÉèÖÃLinuxϵͳÒÔÖ§³Ö±ßÑØÅÌËãºÍÖÇÄÜ×°±¸¿ª·¢
ÉèÖÃlinuxϵͳÒÔÖ§³Ö±ßÑØÅÌËãºÍÖÇÄÜ×°±¸¿ª·¢
Ëæ×űßÑØÅÌËãºÍÖÇÄÜ×°±¸µÄ¿ìËÙÉú³¤£¬Ô½À´Ô½¶àµÄ¿ª·¢Õß×îÏȽ«×¢ÖØÁ¦×ªÏòÔõÑùÔÚLinuxϵͳÉϾÙÐбßÑØÅÌËãºÍÖÇÄÜ×°±¸¿ª·¢¡£±¾ÎĽ«ÏÈÈÝÔõÑùÉèÖÃLinuxϵͳÒÔÖ§³ÖÕâÁ½¸ö·½ÃæµÄ¿ª·¢£¬²¢ÌṩһЩ´úÂëʾÀý¡£
Ò»¡¢×°ÖÃLinuxϵͳ
Ê×ÏÈ£¬ÎÒÃÇÐèҪѡÔñÊʺϱßÑØÅÌËãºÍÖÇÄÜ×°±¸¿ª·¢µÄLinux¿¯Ðа棬ÀýÈçUbuntu»òDebian¡£¿ÉÒÔ´Ó¹Ù·½ÍøÕ¾ÉÏÏÂÔؾµÏñÎļþ£¬²¢Æ¾Ö¤¹Ù·½Ö¸ÄϾÙÐÐ×°Öá£ÔÚ×°ÖÃÀú³ÌÖУ¬¿ÉÒÔÑ¡ÔñÌØÊâ×°ÖÃһЩ¿ª·¢¹¤¾ß¼¯¡£
¶þ¡¢¸üÐÂLinuxϵͳ
×°ÖÃÍê³Éºó£¬ÎÒÃÇÐèҪȷ±£LinuxϵͳÊÇ×îеġ£Ö´ÐÐÒÔÏÂÏÂÁî¿ÉÒÔ¸üÐÂϵͳÈí¼þ°ü£º
sudo apt update sudo apt upgrade
µÇ¼ºó¸´ÖÆ
Õ⽫¸üÐÂϵͳÉϵÄËùÓÐÈí¼þ°üÖÁ×îа汾¡£
Èý¡¢×°Öÿª·¢¹¤¾ß
½ÓÏÂÀ´£¬ÎÒÃÇÐèҪװÖÃһЩÐëÒªµÄ¿ª·¢¹¤¾ß¡£ÒÔÏÂÊÇһЩ³£ÓõĿª·¢¹¤¾ß£º
GNU¹¤¾ßÁ´£ºÔÚLinuxϵͳÉϾÙÐÐǶÈëʽ¿ª·¢±Ø²»¿ÉÉٵŤ¾ßÁ´£¬°üÀ¨gcc¡¢g++¡¢makeµÈ¡£Ö´ÐÐÒÔÏÂÏÂÁî×°Öãº
sudo apt install build-essential
µÇ¼ºó¸´ÖÆ
CMake£ºÓÃÓÚ¹¹½¨¿çƽ̨µÄÏîÄ¿£¬ÔÊÐí¿ª·¢ÕßʹÓÃ×ÔÁ¦ÓÚ²Ù×÷ϵͳºÍ±àÒëÆ÷µÄ×°±¸ÉèÖá£Ö´ÐÐÒÔÏÂÏÂÁî×°Öãº
sudo apt install cmake
µÇ¼ºó¸´ÖÆ
Python¿ª·¢¹¤¾ß°ü£ºÐí¶à±ßÑØÅÌËãºÍÖÇÄÜ×°±¸¿ª·¢¶¼Ê¹ÓÃPython±à³ÌÓïÑÔ¡£Ö´ÐÐÒÔÏÂÏÂÁî×°Öãº
sudo apt install python-dev python-pip
µÇ¼ºó¸´ÖÆ
Ìض¨Ó²¼þµÄSDK£ºÈôÊÇÄãÕýÔÚʹÓÃÌض¨µÄÖÇÄÜ×°±¸¾ÙÐпª·¢£¬Í¨³£»áÓÐÌض¨Ó²¼þµÄSDK¹©¿ª·¢ÕßʹÓá£Äã¿ÉÒÔ´Ó×°±¸¹Ù·½ÍøÕ¾ÉÏÏÂÔز¢Æ¾Ìý˵Ã÷¾ÙÐÐ×°Öá£
ËÄ¡¢ÉèÖÃÇéÐαäÁ¿
Íê³ÉÒÔÉÏ°ì·¨ºó£¬ÎÒÃÇÐèÒªÉèÖÃÇéÐαäÁ¿£¬ÒÔ±ãÔÚÖÕ¶ËÖÐÄܹ»Õý³£»á¼û¿ª·¢¹¤¾ß¡£
·¿ªÖնˣ¬Ö´ÐÐÒÔÏÂÏÂÁ
nano ~/.bashrc
µÇ¼ºó¸´ÖÆ
ÔÚ·¿ªµÄÎļþÖУ¬Ìí¼ÓÒÔÏÂÄÚÈÝ£º
export PATH=$PATH:/usr/local/bin
µÇ¼ºó¸´ÖÆ
°´Ctrl+XÉúÑIJ¢Í˳ö¡£
Ö´ÐÐÒÔÏÂÏÂÁîʹ¸ü¸ÄÉúЧ£º
source ~/.bashrc
µÇ¼ºó¸´ÖÆ
Îå¡¢´úÂëʾÀý
ÒÔÏÂÊÇÒ»¸ö¼òÆӵĴúÂëʾÀý£¬Õ¹Ê¾ÔõÑùÔÚLinuxϵͳÉÏͨ¹ýPythonʵÏÖÒ»¸ö»ù´¡µÄ±ßÑØÅÌËãʹÃü¡£ÔÚÕâ¸öʾÀýÖУ¬ÎÒÃǽ«Ê¹ÓÃPythonµÄsocketÄ£¿éÀ´½¨ÉèÒ»¸ö¼òÆÓµÄЧÀÍÆ÷£¬²¢¼àÌý¶Ë¿ÚÒÔÎüÊÕÀ´×Ô¿Í»§¶ËµÄÇëÇó¡£
import socket def main(): # ½¨Éèsocket¹¤¾ß server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # °ó¶¨IPµØµãºÍ¶Ë¿Ú server_socket.bind(('0.0.0.0', 8080)) # ¼àÌý¶Ë¿Ú£¬×î´óÅþÁ¬ÊýΪ5 server_socket.listen(5) while True: # ½ÓÊÜ¿Í»§¶ËÅþÁ¬ client_socket, client_address = server_socket.accept() # ÎüÊÕ¿Í»§¶ËÇëÇó data = client_socket.recv(1024) # ´¦ÀíÇëÇó response = 'Hello, World!' # ·¢ËÍÏìÓ¦ client_socket.sendall(response.encode()) # ¹Ø±ÕÅþÁ¬ client_socket.close() if __name__ == '__main__': main()
µÇ¼ºó¸´ÖÆ
ÒÔÉÏ´úÂ뽨ÉèÁËÒ»¸ö¼òÆÓµÄЧÀÍÆ÷£¬¼àÌýIPµØµãΪ0.0.0.0¡¢¶Ë¿ÚΪ8080µÄÅþÁ¬£¬²¢ÔÚÊÕµ½¿Í»§¶ËÇëÇóºó·µ»ØÒ»¸ö¼òÆÓµÄÏìÓ¦¡£
Áù¡¢×ܽá
ͨ¹ý±¾ÎĵÄÉèÖúʹúÂëʾÀý£¬Äã¿ÉÒÔÔÚLinuxϵͳÉÏÇáËɵؾÙÐбßÑØÅÌËãºÍÖÇÄÜ×°±¸¿ª·¢¡£ËäÈ»£¬ÕâƪÎÄÕÂÖ»ÊǸø³öÁËһЩ»ù±¾µÄÉèÖúÍʾÀý£¬ÏÖʵµÄ¿ª·¢Àú³Ì¿ÉÄÜÉæ¼°¸ü¶àµÄ¹¤¾ßºÍÊÖÒÕ¡£Ï£Íû±¾ÎÄÄܶÔÄãÔÚLinuxÉϾÙÐбßÑØÅÌËãºÍÖÇÄÜ×°±¸¿ª·¢ÌṩһЩ×ÊÖú¡£
ÒÔÉϾÍÊÇÉèÖÃLinuxϵͳÒÔÖ§³Ö±ßÑØÅÌËãºÍÖÇÄÜ×°±¸¿ª·¢µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡