{"id":651,"date":"2021-11-09T03:02:44","date_gmt":"2021-11-09T03:02:44","guid":{"rendered":"https:\/\/262235.xyz\/?p=651"},"modified":"2021-11-09T03:02:44","modified_gmt":"2021-11-09T03:02:44","slug":"651","status":"publish","type":"post","link":"https:\/\/lyvba.com\/index.php\/2021\/11\/09\/651\/","title":{"rendered":"Arch Linux \u5b89\u88c5\u7b80\u6613\u7248 For VirtualBox \u5b89\u88c5\u865a\u62df\u673a"},"content":{"rendered":"<h2>Arch Linux \u5b89\u88c5\u7b80\u6613\u7248 For VirtualBox \u5b89\u88c5\u865a\u62df\u673a<\/h2>\n<h3>\u542f\u52a8ssh\u670d\u52a1\uff0c\u4e34\u65f6\u4fee\u6539\u5149\u76d8\u7cfb\u7edf\u5bc6\u7801\uff0c\u65b9\u4fbfssh\u5ba2\u6237\u7aef\u8fdc\u7a0b\u767b\u9646\u5b89\u88c5\u7cfb\u7edf<\/h3>\n<pre><code>systemctl restart sshd\nip addr\npasswd<\/code><\/pre>\n<h3>\u786c\u76d8\u5206\u533a\uff0c\u4e00\u4e2a\u533a linux\u5206\u533a \u547d\u4ee4\u9009o\uff0c\u5efa\u7acbdos\u786c\u76d8\uff0c\u547d\u4ee4n\uff0c\u9ed8\u8ba4\u5efa\u7acblinux\u4e3b\u5206\u533a<\/h3>\n<pre><code>fdisk \/dev\/sda\nmkfs.ext4 \/dev\/sda1\nmount \/dev\/sda1 \/mnt<\/code><\/pre>\n<h3>\u5982\u679c\u662f\u56fd\u5185,\u9009\u62e9\u955c\u50cf\u63a8\u8350\u6e05\u534e\u4e2d\u79d1\u5927\uff0c<\/h3>\n<ul>\n<li>\n<p>vim\u7f16\u8f91\u627e\u5230China\u6e90  9yyggp <esc>:wq<\/p>\n<pre><code>vim \/etc\/pacman.d\/mirrorlist<\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>\u5b89\u88c5\u5fc5\u987b\u7684\u8f6f\u4ef6\u5305\u5230\u786c\u76d8\u4e2d\uff0c\u5982\u679c\u865a\u62df\u673a linux-firmware \u53ef\u4ee5\u4e0d\u88c5<\/h3>\n<pre><code>pacstrap \/mnt  base linux linux-firmware<\/code><\/pre>\n<h3>\u628a\u786c\u76d8UUID\u5199\u5230fstab\u91cc\uff0c\u4e0b\u6b21\u91cd\u542f\u80fd\u81ea\u52a8\u627e\u5230<\/h3>\n<pre><code>genfstab -U \/mnt &gt;&gt; \/mnt\/etc\/fstab<\/code><\/pre>\n<h3>\u628a\u6839\u76ee\u5f55\/  \u5207\u6362\u5230\u786c\u76d8\/dev\/sda1\uff0c\u63a5\u4e0b\u6765\u7684\u90fd\u5728\u786c\u76d8\u7cfb\u7edf\u64cd\u4f5c<\/h3>\n<pre><code>arch-chroot \/mnt<\/code><\/pre>\n<h3>\u8f6f\u4ef6\u5305\u66f4\u65b0\u6e90\uff0c\u5b89\u88c5\u5fc5\u8981\u8f6f\u4ef6<\/h3>\n<pre><code>pacman -Syy\npacman -S  dhcpcd  openssh  grub  vim htop wget curl tmux  fish  ca-certificates <\/code><\/pre>\n<h3>Arch\u914d\u7f6e\u540c\u5176\u4ed6linux\u4e0d\u540c\uff0c\u7528\u50bb\u74dcdhcpcd; \u542f\u7528ssh\u670d\u52a1<\/h3>\n<pre><code>systemctl enable dhcpcd\nsystemctl enable sshd<\/code><\/pre>\n<h3>\u5b89\u88c5grub\u5f15\u5bfc\u4fe1\u606f\u5230\u786c\u76d8\uff0c\u81ea\u52a8\u5efa\u7acbgrub.cfg<\/h3>\n<pre><code>grub-install --target=i386-pc \/dev\/sda\ngrub-mkconfig -o \/boot\/grub\/grub.cfg<\/code><\/pre>\n<h3>\u4fee\u6539\u7cfb\u7edfroot\u5bc6\u7801\uff0c\u5efa\u7acb\u4e00\u4e2avip\uff0c\u4e34\u65f6ssh\u8fdc\u7a0b\u7528<\/h3>\n<pre><code>passwd\nuseradd vip\npasswd  vip<\/code><\/pre>\n<h3>\u91cd\u542f\u7cfb\u7edf\uff0c\u7136\u540essh \u767b\u9646\uff0csu \u5207\u6362\u7ba1\u7406\u5458<\/h3>\n<pre><code>ssh vip@192.168.1.110\n# \u5efa\u7acb \/root\/.ssh\/authorized_keys \u5bc6\u94a5\u6587\u4ef6\u540e\u5c31\u53ef\u4ee5root\u767b\u9646\u4e86\nssh root@192.168.1.110<\/code><\/pre>\n<h3>arch \u5b89\u88c5\u547d\u4ee4\u53c2\u8003\u4e2d\u6587\u6587\u6863<\/h3>\n<ul>\n<li><a href=\"https:\/\/wiki.archlinux.org\/index.php\/Installation_guide_\">https:\/\/wiki.archlinux.org\/index.php\/Installation_guide_<\/a>(\u7b80\u4f53\u4e2d\u6587)<\/li>\n<\/ul>\n<h3>start_VM_Headless \u7b80\u6613 VirtualBox Headless \u6a21\u5f0f\u542f\u52a8\u5668<\/h3>\n<ul>\n<li>\n<p>VBoxManage.exe \u5efa\u7acb2\u4e2a\u5feb\u6377\u65b9\u5f0f\uff0c\u5206\u522b\u542f\u52a8\u548c\u5173\u95ed ArchLinux<\/p>\n<pre><code># Oracle VM VirtualBox \u9ed8\u8ba4\u5b89\u88c5\u76ee\u5f55   C:Program FilesOracleVirtualBox\\r\n\n\"C:Program FilesOracleVirtualBoxVBoxManage.exe\"  startvm   ArchLinux  --type headless\n\n\"C:Program FilesOracleVirtualBoxVBoxManage.exe\"  controlvm  ArchLinux  acpipowerbutton\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<hr \/>\n<h2>\u53e6\u5916\u4e00\u79cdArch Linux \u5b89\u88c5: \u4f7f\u7528gdisk\u5efa\u7acbEFI\u5206\u533a\u548cLinux\u5206\u533a<\/h2>\n<p>gdisk \/dev\/sda<\/p>\n<ul>\n<li>\u76f4\u63a5\u6253o\uff0c\u610f\u5473\u7740create a new empty GUID partition table (GPT)\uff0c\u56de\u8f66<\/li>\n<li>\u63a5\u4e0b\u6765\uff0c\u6253n\uff0c\u65b0\u5efa\u5206\u533a,EFI\u5206\u533a\u7528\u6765\u50a8\u5b58\u5f15\u5bfc\u6587\u4ef6,\u5206\u533a\u4ee3\u7801 EF00 \u8868\u793aefi\u5206\u533a<\/li>\n<li>\u518d\u5efa\u7acbLinux\u5206\u533a\uff0c\u76f4\u5230Hex code\u8fd9\u884c\uff0c\u62538300\uff0c8300\u662flinux\u7684\u6587\u4ef6\u7cfb\u7edf\u3002<\/li>\n<li>\n<p>\u68c0\u67e5,\u770b\u5230\u6587\u4ef6\u7cfb\u7edf GPT\uff0c2\u4e2a\u5206\u533a\u5206\u522b\u662fEFI system partition \u548c Linux filesystem<\/p>\n<pre><code># gdisk -l \/dev\/sda\n\nFound valid GPT with protective MBR; using GPT.\nDisk \/dev\/sda: 16777216 sectors, 8.0 GiB\nDisk identifier (GUID): B60E27F0-F574-4AAB-B0C1-BAEC5377DDFD\nNumber  Start (sector)    End (sector)  Size       Code  Name\n 1            2048         1050623   512.0 MiB   EF00  EFI system partition  # EFI\u5206\u533a\u4e3b\u8981\u653e\u5f15\u5bfc\u6587\u4ef6\u5176\u5b9e128M\u591f\u7528\u4e86\n 2         1050624        16777182   7.5 GiB     8300  Linux filesystem<\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>\u683c\u5f0f\u5316\u5206\u533a\u548c\u6302\u8f7d\u5206\u533a\u6709\u76f8\u5e94\u4fee\u6539\uff0c\u518d\u6309\u4e0a\u9762\u5b89\u88c5Arch\u7cfb\u7edf<\/h3>\n<pre><code>mkfs.vfat -F 32  \/dev\/sda1\nmkfs.ext4 \/dev\/sda2\nmount \/dev\/sda2 \/mnt\nmkdir -p  \/mnt\/boot\nmount \/dev\/sda1 \/mnt\/boot<\/code><\/pre>\n<h2>\u4e0d\u88c5GRUB\uff0c\u4f7f\u7528\u7cfb\u7edf\u81ea\u5e26\u7684systemd bootctl<\/h2>\n<pre><code>bootctl install<\/code><\/pre>\n<pre><code># vim \/boot\/loader\/loader.conf\n\ndefault arch\ntimeout 1\n\n#console-mode keep\ndefault 75ece990f54f40eba924862b4f752aa6-*<\/code><\/pre>\n<pre><code>vim \/boot\/loader\/entries\/arch.conf\n\ntitle   Arch Linux\nlinux   \/vmlinuz-linux\ninitrd  \/initramfs-linux.img\noptions root=PARTUUID=470b42a8-69bf-4822-ad1a-8164c741b17c rw<\/code><\/pre>\n<h3>\u67e5\u770b\u78c1\u76d8\u5206\u533aUUID\u53f7<\/h3>\n<pre><code>partx \/dev\/sda\nNR   START      END  SECTORS SIZE NAME                 UUID\n 1    2048  1050623  1048576 512M EFI system partition 0d180520-7c33-4899-9e8e-30272e072fb4\n 2 1050624 16777182 15726559 7.5G Linux filesystem     470b42a8-69bf-4822-ad1a-8164c741b17c\n<\/code><\/pre>\n<h2>Arch Linux \u5b89\u88c5 Nginx + PHP-FPM \u914d\u7f6e\u586b\u5751\u7b14\u8bb0<\/h2>\n<ul>\n<li>\n<p>\u5b89\u88c5nginx\u548cphp-fpm\u633a\u7b80\u5355\uff0c\u542f\u7528\u670d\u52a1 systemctl enable<\/p>\n<pre><code>pacman -S nginx php php-fpm\nsystemctl enable nginx\nsystemctl enable php-fpm\n\n# \u751f\u6210index.php\necho \"&lt;?php echo phpinfo(); ?&gt;\"   &gt;  \/usr\/share\/nginx\/html\/index.php\n\n# \u8c03\u8bd5\u914d\u7f6e\u6bd4\u8f83\u5751\uff0c\u4f1a\u7528\u5230\u91cd\u542f\u547d\u4ee4\nsystemctl restart nginx\nsystemctl restart php-fpm\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>\u7f51\u4e0a\u627e\u4e86N\u4e2a\u65b9\u6cd5\uff0c\u7ec8\u4e8e\u627e\u5230\u4e00\u4e2a\u80fd\u7528\u7684<\/h3>\n<pre><code> # pass PHP scripts to FastCGI server\nlocation ~ .php$ {\n    root           \/usr\/share\/nginx\/html;\n    fastcgi_pass   unix:\/run\/php-fpm\/php-fpm.sock;\n    fastcgi_index  index.php;\n    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;\n    include        fastcgi_params;\n}<\/code><\/pre>\n<h3>Arch Wiki \u627e\u5230\u7684\u914d\u7f6e,\u56e0\u4e3a nginx.conf \u9ed8\u8ba4\u914d\u7f6e root\u53d8\u91cf\u79fb\u5230\u4e86location\u7a7a\u95f4\u91cc\uff0c\u5bfc\u81f4SCRIPT_FILENAME\u5931\u6548<\/h3>\n<pre><code># vim \/etc\/nginx\/nginx.conf\n\n# \u9ed8\u8ba4 nginx.conf \u914d\u7f6e root\u53d8\u91cf\u79fb\u5230\u4e86location\u7a7a\u95f4\u91cc\nlocation \/ {\n   root   \/usr\/share\/nginx\/html;\n   index  index.html index.htm;\n}<\/code><\/pre>\n<hr \/>\n<ul>\n<li>\n<p>\u89e3\u51b3\u65b9\u6cd5 root \u79fb\u51fa\u6765\uff0c\u6216\u8005\u5728 php-fpm \u914d\u7f6e\u91cc\u590d\u5236\u4e00\u4efd<\/p>\n<pre><code># \u89e3\u51b3\u65b9\u6cd5 root \u79fb\u51fa\u6765\nroot \/usr\/share\/nginx\/html;\n\n # pass PHP scripts to FastCGI server\nlocation ~ .php$ {\n  # 404\n  try_files $fastcgi_script_name =404;\n\n#  root \/usr\/share\/nginx\/html;    ###  \u5728 php-fpm \u914d\u7f6e\u91cc\u590d\u5236\u4e00\u4efd root\n\n  # default fastcgi_params\n  include fastcgi_params;\n\n  # fastcgi settings\n  fastcgi_pass            unix:\/run\/php-fpm\/php-fpm.sock;\n  fastcgi_index            index.php;\n  fastcgi_buffers            8 16k;\n  fastcgi_buffer_size        32k;\n\n  # fastcgi params\n  fastcgi_param DOCUMENT_ROOT        $realpath_root;\n  fastcgi_param SCRIPT_FILENAME    $realpath_root$fastcgi_script_name;\n  #fastcgi_param PHP_ADMIN_VALUE    \"open_basedir=$base\/:\/usr\/lib\/php\/:\/tmp\/\";\n}<\/code><\/pre>\n<\/li>\n<li>\u53c2\u8003\u94fe\u63a5: <a href=\"https:\/\/wiki.archlinux.org\/index.php\/Nginx_\">https:\/\/wiki.archlinux.org\/index.php\/Nginx_<\/a>(\u7b80\u4f53\u4e2d\u6587)<\/li>\n<\/ul>\n<h3>\u8fd8\u6709\u4e00\u4e2a\u6bd4\u8f83\u5751\u7684 fastcgi_pass \u53d8\u91cf\u600e\u4e48\u8bbe\u7f6e\uff0c\u7f51\u4e0a\u6709N\u79cd\u914d\u7f6e<\/h3>\n<ul>\n<li>\n<p>\u7f51\u4e0a\u6709N\u79cd\u914d\u7f6e\uff0c\u4f60\u4e0d\u77e5\u9053\u600e\u4e48\u8bbe\u7f6e\u548c\u6d4b\u8bd5\uff1b\u6211\u4e5f\u662f\u82b1\u4e86N\u4e2a\u5c0f\u65f6\u6574\u7406\u51fa\u6765\u7684\u65b9\u6cd5\uff0c\u5e94\u8be5\u4e5f\u9002\u7528\u4e8edebian\u7cfb\u7edf<\/p>\n<\/li>\n<li>php  .\/index.php             # \u6d4b\u8bd5 php \u662f\u5426\u6b63\u786e<\/li>\n<li>systemctl status php-fpm     # \u68c0\u67e5 php-fpm \u662f\u5426\u542f\u52a8<\/li>\n<li>nginx -t                     # \u68c0\u67e5\u914d\u7f6e\u662f\u5426\u6709\u95ee\u9898<\/li>\n<li>vim  \/etc\/php\/php-fpm.conf\/  # \u627e\u5230 include=\/etc\/php\/php-fpm.d\/*.conf \u8fd9\u884c\uff0c\u5224\u65ad www.conf \u6240\u5728\u76ee\u5f55<\/li>\n<li>cd \/etc\/php\/php-fpm.d\/       # \u627e\u5230\u6587\u4ef6  \/etc\/php\/php-fpm.d\/www.conf<\/li>\n<li>cat www.conf | grep 'php-fpm'  # \u67e5\u5230 listen = \/run\/php-fpm\/php-fpm.sock  \u5224\u65ad php-fpm \u6b63\u786e\u7684\u76d1\u542c\u7aef\u53e3<\/li>\n<li>\u4fee\u6539nginx\u914d\u7f6e:  fastcgi_pass     unix:\/run\/php-fpm\/php-fpm.sock;     # \u5404\u4e2alinux \u9ed8\u8ba4\u5404\u4e0d\u76f8\u540c<\/li>\n<li>\n<p>systemctl restart nginx      #  \u91cd\u542fnginx \u6d4b\u8bd5\u662f\u5426\u80fd\u6b63\u786ephp\uff0c\u4e0d\u884c\u5c31\u7f51\u7edc\u67e5\u8d44\u6599\u518d\u6392\u67e5<\/p>\n<\/li>\n<\/ul>\n<h3>\u9644: Debian \u7cfb\u7edf Nginx \u9ed8\u8ba4\u914d\u7f6e\u6587\u4ef6:  \/etc\/nginx\/sites-enabled\/default<\/h3>\n<ul>\n<li>\n<p>\u4f5c\u4e3a\u53c2\u8003\u6bd4\u8f83\uff0c Debian Nginx + PHP-FPM \u8bbe\u7f6e\u597d\u50cf\u7b80\u5355\u70b9<\/p>\n<pre><code> # Add index.php to the list if you are using PHP\nindex index.html index.htm index.nginx-debian.html index.php;<\/code><\/pre>\n<pre><code>  # pass PHP scripts to FastCGI server\n  #\n  location ~ .php$ {\n          include snippets\/fastcgi-php.conf;\n  #\n  #       # With php-fpm (or other unix sockets):\n          fastcgi_pass unix:\/var\/run\/php\/php7.3-fpm.sock;  # \u6ce8\u610f\u7248\u672c\u53f7\u8981\u5bf9\u5e94\uff0c\u4e0d\u7136 520 \u7f51\u5173\u9519\u8bef\n  #       # With php-cgi (or other tcp sockets):\n  #       fastcgi_pass 127.0.0.1:9000;                     # apt \u5b89\u88c5\u7684 php-fpm \u76f4\u63a5\u5f00\u8fd9\u4e2a\u662f\u4e0d\u884c\u7684\n  }<\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>Debian \u7cfb\u7edf Nginx + PHP-FPM \u8bbe\u7f6e\u6392\u67e5\u65b9\u6848\u6b65\u9aa4<\/h3>\n<pre><code>1.  php  .\/index.php             # \u6d4b\u8bd5 php \u662f\u5426\u6b63\u786e\n2.  systemctl status php7.3-fpm  # \u68c0\u67e5 php-fpm \u662f\u5426\u542f\u52a8\n3.  vim \/etc\/nginx\/nginx.conf    # http\u7528\u6237\u540d user www-data; \u7ad9\u70b9\u914d\u7f6e include \/etc\/nginx\/sites-enabled\/*;\n    vim \/etc\/nginx\/sites-enabled\/default\n    nginx -t                     # \u68c0\u67e5\u914d\u7f6e\u662f\u5426\u6709\u95ee\u9898\n4.  vim \/etc\/php\/7.3\/fpm\/php-fpm.conf   # \u5224\u65ad www.conf \u6240\u5728\u76ee\u5f55\n5.  cd \/etc\/php\/php-fpm.d\/       # \u627e\u5230\u6587\u4ef6  \/etc\/php\/php-fpm.d\/www.conf\n6.  cat \/etc\/php\/7.3\/fpm\/pool.d\/www.conf | grep -e  'fpm.sock'\n    # \u67e5\u5230 listen = \/run\/php\/php7.3-fpm.sock  \u5224\u65ad php-fpm \u6b63\u786e\u7684\u76d1\u542c\u7aef\u53e3\n7.  \u4fee\u6539nginx\u914d\u7f6e:  fastcgi_pass  unix:\/run\/php\/php7.3-fpm.sock;\n8.  systemctl restart nginx      #  \u91cd\u542fnginx \u6d4b\u8bd5\u662f\u5426\u80fd\u6b63\u786ephp<\/code><\/pre>\n<h3>\u4fee\u6b63 Arch Linux locale \u7121\u6cd5 generate \u4ee5\u53ca tmux mosh \u51fa\u73fe\u932f\u8aa4<\/h3>\n<pre><code>pacman -S tmux\n\ntmux: invalid LC_ALL, LC_CTYPE or LANG\n\nlocale -a\nlocale: Cannot set LC_CTYPE to default locale: No such file or directory\nlocale: Cannot set LC_MESSAGES to default locale: No such file or directory\nlocale: Cannot set LC_COLLATE to default locale: No such file or directory<\/code><\/pre>\n<h3>\u89e3\u6cd5 \u6c92\u6709\u628a \/etc\/locale.gen \u5167\u7684 comment \u62ff\u6389<\/h3>\n<pre><code>vim \/etc\/locale.gen\n#en_US.UTF-8 UTF-8 \u5220\u9664 \u6ce8\u91ca#\n\nlocale-gen \"en_US.UTF-8\"\n\nGenerating locales...\n  en_US.UTF-8...\ndone<\/code><\/pre>\n<h3>Alpine Linux \u5b9e\u73b0\u5f00\u673a\u81ea\u542f\u811a\u672c<\/h3>\n<pre><code>cd \/etc\/local.d\n\nvi sskcp.start\n\n#!\/bin\/bash\nip link set eth0 up\nip addr add 192.168.1.111\/24 dev eth0\nip route add default via 192.168.1.1\nexec \/root\/sskcp.sh start\n\n\n# \u8d4b\u4e88\u811a\u672c\u53ef\u6267\u884c\u6743\u9650\uff1a\nchmod +x sskcp.start\n\n# \u8bbe\u7f6e local \u670d\u52a1\u5f00\u673a\u542f\u52a8\uff1a\nrc-update add local<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Arch Linux \u5b89\u88c5\u7b80\u6613\u7248 For VirtualBox \u5b89\u88c5\u865a\u62df\u673a \u542f\u52a8ssh\u670d\u52a1\uff0c\u4e34\u65f6\u4fee\u6539 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[23],"class_list":["post-651","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux"],"_links":{"self":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/651","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/comments?post=651"}],"version-history":[{"count":0,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/651\/revisions"}],"wp:attachment":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/media?parent=651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/categories?post=651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/tags?post=651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}