﻿{"id":12525,"date":"2022-01-31T08:26:46","date_gmt":"2022-01-31T00:26:46","guid":{"rendered":"https:\/\/www.linuxmi.com\/?p=12525"},"modified":"2022-01-30T12:15:26","modified_gmt":"2022-01-30T04:15:26","slug":"ubuntu-angular-cli-pm2-run-angular","status":"publish","type":"post","link":"https:\/\/www.linuxmi.com\/ubuntu-angular-cli-pm2-run-angular.html","title":{"rendered":"Ubuntu \u4e0b\u5b89\u88c5 Angular CLI \u548c PM2 \u8fd0\u884c Angular \u5e94\u7528"},"content":{"rendered":"<p>Angular CLI \u662f\u4e00\u4e2aAngular\u6846\u67b6\u7684\u547d\u4ee4\u884c\u754c\u9762\u5de5\u5177\uff0c\u53ef\u7528\u4e8e\u76f4\u63a5\u4ece\u547d\u4ee4 Shell \u521d\u59cb\u5316\u3001\u5f00\u53d1\u3001\u6784\u5efa\u548c\u7ef4\u62a4 Angular \u5e94\u7528\u7a0b\u5e8f\u3002\u4e3b\u8981\u7248\u672c\u7684 Angular CLI \u9075\u5faa\u652f\u6301\u7684\u4e3b\u8981\u7248\u672c Angular\uff0c\u4f46\u6b21\u8981\u7248\u672c\u53ef\u4ee5\u5355\u72ec\u53d1\u5e03\u3002<\/p>\n<p>\u5b83\u65e8\u5728\u5728\u5f00\u53d1\u670d\u52a1\u5668\u4e0a\u6784\u5efa\u548c\u6d4b\u8bd5Angular\u9879\u76ee\u3002\u4f46\u662f\uff0c\u5982\u679c\u8981\u5728\u751f\u4ea7\u4e2d\u6c38\u4e45\u8fd0\u884c\/\u4fdd\u6301\u5e94\u7528\u7a0b\u5e8f\u5904\u4e8e\u6d3b\u52a8\u72b6\u6001\uff0c\u5219\u9700\u8981Node.js\u6d41\u7a0b\u7ba1\u7406\u5668\uff0c\u4f8b\u5982PM2\u3002<\/p>\n<p>PM2\u662fNode.js\u5e94\u7528\u7a0b\u5e8f\u7684\u6d41\u884c\uff0c\u9ad8\u7ea7\u4e14\u529f\u80fd\u4e30\u5bcc\u7684\u751f\u4ea7\u6d41\u7a0b\u7ba1\u7406\u5668\uff0c\u5177\u6709\u5185\u7f6e\u8d1f\u8f7d\u5747\u8861\u5668\u3002\u5176\u529f\u80fd\u96c6\u5305\u62ec\u5bf9\u5e94\u7528\u7a0b\u5e8f\u76d1\u89c6\uff0c\u5fae\u670d\u52a1\/\u8fdb\u7a0b\u7684\u9ad8\u6548\u7ba1\u7406\uff0c\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u96c6\u7fa4\u6a21\u5f0f\u4ee5\u53ca\u5e94\u7528\u7a0b\u5e8f\u7684\u6b63\u5e38\u91cd\u542f\u548c\u5173\u95ed\u7684\u652f\u6301\u3002\u6b64\u5916\uff0c\u5b83\u8fd8\u652f\u6301\u8f7b\u677e\u7ba1\u7406\u5e94\u7528\u7a0b\u5e8f\u65e5\u5fd7\u7b49\u7b49\u3002<\/p>\n<p>Node.js \u662f\u4e00\u4e2a\u57fa\u4e8e Chrome V8 \u5f15\u64ce\u7684 JavaScript \u8fd0\u884c\u65f6\u3002<\/p>\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u5411\u60a8\u5c55\u793a\u5982\u4f55\u4f7f\u7528 Angular CLI \u548c PM2 Node.js \u6d41\u7a0b\u7ba1\u7406\u5668\u8fd0\u884c Angular \u5e94\u7528\u7a0b\u5e8f\u3002\u8fd9\u5141\u8bb8\u60a8\u5728\u5f00\u53d1\u671f\u95f4\u8fde\u7eed\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p><strong>\u8981\u6c42<\/strong><\/p>\n<p>\u60a8\u5fc5\u987b\u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5\u4ee5\u4e0b\u8f6f\u4ef6\u5305\u624d\u80fd\u7ee7\u7eed\uff1a<\/p>\n<ul>\n<li>Node.js\u548cNPM<\/li>\n<li>AngularCLI<\/li>\n<li>PM2<\/li>\n<\/ul>\n<p>\u6ce8\u610f\uff1a\u5982\u679c\u60a8\u5df2\u5728Linux\u7cfb\u7edf\uff08\u672c\u6587\u4e3a Ubuntu 20.04.2\uff09\u4e0a\u5b89\u88c5\u4e86Node.js\u548cNPM\uff0c\u8bf7\u8df3\u81f3\u6b65\u9aa42\u3002<\/p>\n<h3>\u7b2c1\u6b65\uff1a\u5728Linux\u4e2d\u5b89\u88c5Node.js<\/h3>\n<p>\u8981\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684Node.js\uff0c\u9996\u5148\u5728\u7cfb\u7edf\u4e0a\u6dfb\u52a0NodeSource\u5b58\u50a8\u5e93\uff0c\u5982\u56fe\u6240\u793a\uff0c\u7136\u540e\u5b89\u88c5\u8be5\u8f6f\u4ef6\u5305\u3002\u4e0d\u8981\u5fd8\u8bb0\u4e3a\u8981\u5728Linux\u53d1\u884c\u7248\u4e0a\u5b89\u88c5\u7684Node.js\u7248\u672c\u8fd0\u884c\u6b63\u786e\u7684\u547d\u4ee4\u3002\uff08node \u4e0e npm \u7248\u672c\u5bf9\u7167\uff1ahttps:\/\/nodejs.org\/zh-cn\/download\/releases\/\uff09<\/p>\n<p><strong>\u5728Ubuntu\u4e0a\u5b89\u88c5Node.js.<\/strong><\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">curl -sL https:\/\/deb.nodesource.com\/setup_16.x | sudo -E bash &#8211;\u00a0 \u00a0 \u00a0 \u00a0 #\u5bf9\u4e8e Node.js version 16<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12533\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2022\/01\/ubuntu-angular-cli-pm2-run-angular-1.png\" alt=\"\" width=\"946\" height=\"377\" \/><br \/>\n&#8230;&#8230;\u7b49\u7b49\u7b49\u7b49\u7b49\u7b49<br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">curl -sL https:\/\/deb.nodesource.com\/setup_15.x | sudo -E bash &#8211;\u00a0 \u00a0 \u00a0 \u00a0 #\u5bf9\u4e8e Node.js version 15<\/span><br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">curl -sL https:\/\/deb.nodesource.com\/setup_14.x | sudo -E bash &#8211;\u00a0 \u00a0 \u00a0 \u00a0 #\u5bf9\u4e8e Node.js version 14<\/span><br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo apt-get install -y nodejs<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12534\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2022\/01\/ubuntu-angular-cli-pm2-run-angular-2.png\" alt=\"\" width=\"946\" height=\"653\" \/><\/p>\n<p><strong>\u5728Debian\u4e0a\u5b89\u88c5Node.js\u3002<\/strong><\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">curl -sL https:\/\/deb.nodesource.com\/setup_16.x | bash &#8211;<\/span>\u00a0 \u00a0 #\u5bf9\u4e8e Node.js version 16<br \/>\n&#8230;&#8230;\u7b49\u7b49\u7b49\u7b49\u7b49\u7b49<br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">curl -sL https:\/\/deb.nodesource.com\/setup_15.x | bash &#8211;<\/span>\u00a0 \u00a0 #\u5bf9\u4e8e Node.js version 15<br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">curl -sL https:\/\/deb.nodesource.com\/setup_14.x | bash &#8211;<\/span>\u00a0 \u00a0 #\u5bf9\u4e8e Node.js version 14<br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo apt install -y nodejs<\/span><\/p>\n<p><strong>\u5728CentOS\uff0cRHEL\u548cFedora\u4e0a\u5b89\u88c5Node.js<\/strong><\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">curl -sL https:\/\/rpm.nodesource.com\/setup_16.x | bash &#8211;\u00a0<\/span> \u00a0 #\u5bf9\u4e8e Node.js version 16<br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">curl -sL https:\/\/rpm.nodesource.com\/setup_15.x | bash &#8211;\u00a0<\/span> \u00a0 #\u5bf9\u4e8e Node.js version 15<br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">curl -sL https:\/\/rpm.nodesource.com\/setup_14.x | bash &#8211;\u00a0<\/span> \u00a0 #\u5bf9\u4e8e Node.js version 14<br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo yum -y install nodejs<\/span><br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo dnf -y install nodejs<\/span>\u00a0 [\u5728 RHEL 8 \u548c Fedora 22\u53ca\u4ee5\u4e0a\u7248\u672c]<\/p>\n<p>\u6b64\u5916\uff0c\u8fd8\u8981\u5728\u7cfb\u7edf\u4e0a\u5b89\u88c5\u5f00\u53d1\u5de5\u5177\uff0c\u4ee5\u4fbf\u4eceNPM\u7f16\u8bd1\u548c\u5b89\u88c5\u539f\u751f\u63d2\u4ef6\u3002<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo apt install build-essential<\/span>\u00a0\u00a0 [\u5728 Debian\/Ubuntu]<br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo yum install gcc-c++ make<\/span>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 [\u5728 CentOS\/RHEL]<br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo dnf install gcc-c++ make<\/span>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 [\u5728 Fedora]<\/p>\n<p><strong>\u5b89\u88c5Node.js\u548cNPM\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5\u5176\u7248\u672c\u3002<\/strong><\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">npm -v<\/span><br \/>\n8.3.1<br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">node -v<\/span><br \/>\nv17.4.0<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12530\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2022\/01\/ubuntu-angular-cli-pm2-run-angular-13.png\" alt=\"\" width=\"946\" height=\"262\" \/><\/p>\n<h3>\u7b2c2\u6b65\uff1a\u5b89\u88c5Angular CLI\u548cPM2<\/h3>\n<p>\u63a5\u4e0b\u6765\uff0c\u4f7f\u7528npm\u5305\u7ba1\u7406\u5668\u5b89\u88c5Angular CLI\u548cPM2\uff0c\u5982\u56fe\u6240\u793a\u3002 \u5728\u4ee5\u4e0b\u547d\u4ee4\u4e2d\uff0c-g\u9009\u9879\u8868\u793a\u5168\u5c40\u5b89\u88c5\u8f6f\u4ef6\u5305 &#8211; \u53ef\u4f9b\u6240\u6709\u7cfb\u7edf\u7528\u6237\u4f7f\u7528\u3002<\/p>\n<p>linuxmi@linuxmi:~\/linuxmi.com$ <span style=\"color: #ff0000;\">sudo npm install -g @angular\/cli \u00a0<\/span>\u00a0\u00a0 \u00a0 \u00a0 #\u5b89\u88c5Angular CLI<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">[sudo] linuxmi \u7684\u5bc6\u7801\uff1a\r\n\r\nadded 187 packages, and audited 188 packages in 33s\r\n\r\n23 packages are looking for funding\r\nrun `npm fund` for details\r\n\r\nfound 0 vulnerabilities\r\nnpm notice\r\nnpm notice New minor version of npm available! 8.3.1 -&gt; 8.4.0\r\nnpm notice Changelog: https:\/\/github.com\/npm\/cli\/releases\/tag\/v8.4.0\r\nnpm notice Run npm install -g npm@8.4.0 to update!\r\nnpm notice<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12531\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2022\/01\/ubuntu-angular-cli-pm2-run-angular-14.png\" alt=\"\" width=\"946\" height=\"492\" \/><\/p>\n<p>linuxmi@linuxmi:~\/linuxmi.com$ <span style=\"color: #ff0000;\">sudo npm install -g pm2<\/span>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 #\u5b89\u88c5 PM2<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https:\/\/v8.dev\/blog\/math-random for details.\r\n\r\nadded 181 packages, and audited 182 packages in 24s\r\n\r\n12 packages are looking for funding\r\nrun `npm fund` for details\r\n\r\nfound 0 vulnerabilities<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12532\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2022\/01\/ubuntu-angular-cli-pm2-run-angular-15.png\" alt=\"\" width=\"946\" height=\"377\" \/><\/p>\n<h3>\u7b2c3\u6b65\uff1a\u4f7f\u7528Angular CLI\u521b\u5efaAngular\u9879\u76ee<\/h3>\n<p>\u73b0\u5728\u8fdb\u5165\u670d\u52a1\u5668\u7684webroot\u76ee\u5f55\uff0c\u7136\u540e\u4f7f\u7528Angular CLI\u521b\u5efa\uff0c\u6784\u5efa\u548c\u63d0\u4f9bAngular\u5e94\u7528\u7a0b\u5e8f\uff08\u79f0\u4e3asysmon-app\uff0c\u5c06\u5176\u66ff\u6362\u4e3a\u5e94\u7528\u7a0b\u5e8f\u7684\u540d\u79f0\uff09\u3002<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">cd \/www.linuxmi.com\/www\/<\/span><br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com\/www$ <span style=\"color: #ff0000;\">sudo ng new linuxmi-app<\/span>\u00a0 \u00a0 \u00a0 \u00a0 #\u6309\u7167\u63d0\u793a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">[sudo] linuxmi \u7684\u5bc6\u7801\uff1a\r\nNode.js version v17.4.0 detected.\r\nOdd numbered Node.js versions will not enter LTS status and should not be used for production. For more information, please see https:\/\/nodejs.org\/en\/about\/releases\/.\r\n? Would you like to add Angular routing? <span style=\"color: #ff0000;\">Yes<\/span>\r\n? Which stylesheet format would you like to use? <span style=\"color: #ff0000;\">CSS<\/span>\r\n\r\n\u2714 Packages installed successfully.\r\n\r\n*** \u8bf7\u544a\u8bc9\u6211\u4f60\u662f\u8c01\u3002\r\n\r\n\u8fd0\u884c\r\n\r\ngit config --global user.email \"you@example.com\"\r\ngit config --global user.name \"Your Name\"\r\n\r\n\u6765\u8bbe\u7f6e\u60a8\u8d26\u53f7\u7684\u7f3a\u7701\u8eab\u4efd\u6807\u8bc6\u3002\r\n\u5982\u679c\u4ec5\u5728\u672c\u4ed3\u5e93\u8bbe\u7f6e\u8eab\u4efd\u6807\u8bc6\uff0c\u5219\u7701\u7565 --global \u53c2\u6570\u3002\r\n\r\nfatal: \u65e0\u6cd5\u81ea\u52a8\u63a2\u6d4b\u90ae\u4ef6\u5730\u5740\uff08\u5f97\u5230 'root@linuxmi.(none)'\uff09\r\nNothing to be done.<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12536\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2022\/01\/ubuntu-angular-cli-pm2-run-angular-17.png\" alt=\"\" width=\"946\" height=\"653\" \/><\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u8fdb\u5165\u521a\u521a\u521b\u5efa\u7684\u5e94\u7528\u7a0b\u5e8f\uff08\u5b8c\u6574\u8def\u5f84\u4e3a\/\/www.linuxmi.com\/www\/linuxmi-app\uff09\u76ee\u5f55\uff0c\u5e76\u5982\u56fe\u6240\u793a\u4e3a\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u670d\u52a1\u3002<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com\/www$ <span style=\"color: #ff0000;\">cd linuxmi-app<\/span><br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com\/www\/linuxmi-app$ <span style=\"color: #ff0000;\">sudo ng serve<\/span><\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">[sudo] linuxmi \u7684\u5bc6\u7801\uff1a \r\nNode.js version v17.4.0 detected.\r\nOdd numbered Node.js versions will not enter LTS status and should not be used for production. For more information, please see https:\/\/nodejs.org\/en\/about\/releases\/.\r\n\u2714 Browser application bundle generation complete.\r\n\r\nInitial Chunk Files   | Names         |  Raw Size\r\nvendor.js             | vendor        |   1.96 MB | \r\npolyfills.js          | polyfills     | 299.91 kB | \r\nstyles.css, styles.js | styles        | 173.23 kB | \r\nmain.js               | main          |  53.20 kB | \r\nruntime.js            | runtime       |   6.52 kB | \r\n\r\n                      | Initial Total |   2.49 MB\r\n\r\nBuild at: 2022-01-30T03:30:36.345Z - Hash: 093ec58348b27abc - Time: 10300ms\r\n\r\n** Angular Live Development Server is listening on localhost:4200, open your browser on http:\/\/localhost:4200\/ **\r\n\r\n\r\n\u2714 Compiled successfully.\r\n<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12538\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2022\/01\/ubuntu-angular-cli-pm2-run-angular-18-1.png\" alt=\"\" width=\"946\" height=\"699\" \/><\/p>\n<p>\u4eceng serve\u547d\u4ee4\u7684\u8f93\u51fa\u4e2d\uff0c\u60a8\u53ef\u4ee5\u770b\u5230Angular\u5e94\u7528\u7a0b\u5e8f\u672a\u5728\u540e\u53f0\u8fd0\u884c\uff0c\u60a8\u65e0\u6cd5\u518d\u8bbf\u95ee\u547d\u4ee4\u63d0\u793a\u7b26\u3002 \u56e0\u6b64\uff0c\u5728\u8fd0\u884c\u65f6\u4e0d\u80fd\u6267\u884c\u4efb\u4f55\u5176\u4ed6\u547d\u4ee4\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u60a8\u9700\u8981\u4e00\u4e2a\u6d41\u7a0b\u7ba1\u7406\u5668\u6765\u63a7\u5236\u548c\u7ba1\u7406\u5e94\u7528\u7a0b\u5e8f\uff1a\u8fde\u7eed\uff08\u6c38\u4e45\u5730\uff09\u8fd0\u884c\u5b83\uff0c\u5e76\u4f7f\u5176\u80fd\u591f\u5728\u7cfb\u7edf\u542f\u52a8\u65f6\u81ea\u52a8\u542f\u52a8\uff0c\u5982\u4e0b\u4e00\u8282\u6240\u8ff0\u3002<\/p>\n<p>\u5728\u8f6c\u5230\u4e0b\u4e00\u90e8\u5206\u4e4b\u524d\uff0c\u6309[Ctl + C]\u4ee5\u91ca\u653e\u547d\u4ee4\u63d0\u793a\u7b26\u6765\u7ec8\u6b62\u8be5\u8fc7\u7a0b\u3002<\/p>\n<h3>\u7b2c4\u6b65\uff1a\u4f7f\u7528PM2\u6c38\u8fdc\u8fd0\u884cAngular\u9879\u76ee<\/h3>\n<p>\u8981\u4f7f\u65b0\u5e94\u7528\u7a0b\u5e8f\u5728\u540e\u53f0\u8fd0\u884c\uff0c\u8bf7\u91ca\u653e\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u4f7f\u7528PM2\u4e3a\u5176\u63d0\u4f9b\u670d\u52a1\uff0c\u5982\u56fe\u6240\u793a\u3002 PM2\u8fd8\u53ef\u4ee5\u5e2e\u52a9\u6267\u884c\u5e38\u89c1\u7684\u7cfb\u7edf\u7ba1\u7406\u4efb\u52a1\uff0c\u4f8b\u5982\u5728\u6545\u969c\u65f6\u91cd\u65b0\u542f\u52a8\uff0c\u505c\u6b62\uff0c\u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\u800c\u65e0\u9700\u505c\u673a\u7b49\u7b49\u3002<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com\/www$ <span style=\"color: #ff0000;\">pm2 start &#8220;ng serve&#8221; &#8211;name linuxmi-app<\/span><\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">linuxmi@linuxmi:~\/www.linuxmi.com\/www$ pm2 start \"ng serve\" --name linuxmi-app\r\n\r\n                        -------------\r\n\r\n__\/\\\\\\\\\\\\\\\\\\\\\\\\\\____\/\\\\\\\\____________\/\\\\\\\\____\/\\\\\\\\\\\\\\\\\\_____\r\n _\\\/\\\\\\\/\/\/\/\/\/\/\/\/\\\\\\_\\\/\\\\\\\\\\\\________\/\\\\\\\\\\\\__\/\\\\\\\/\/\/\/\/\/\/\\\\\\___\r\n  _\\\/\\\\\\_______\\\/\\\\\\_\\\/\\\\\\\/\/\\\\\\____\/\\\\\\\/\/\\\\\\_\\\/\/\/______\\\/\/\\\\\\__\r\n   _\\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\/__\\\/\\\\\\\\\/\/\/\\\\\\\/\\\\\\\/_\\\/\\\\\\___________\/\\\\\\\/___\r\n    _\\\/\\\\\\\/\/\/\/\/\/\/\/\/____\\\/\\\\\\__\\\/\/\/\\\\\\\/___\\\/\\\\\\________\/\\\\\\\/\/_____\r\n     _\\\/\\\\\\_____________\\\/\\\\\\____\\\/\/\/_____\\\/\\\\\\_____\/\\\\\\\/\/________\r\n      _\\\/\\\\\\_____________\\\/\\\\\\_____________\\\/\\\\\\___\/\\\\\\\/___________\r\n       _\\\/\\\\\\_____________\\\/\\\\\\_____________\\\/\\\\\\__\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\_\r\n        _\\\/\/\/______________\\\/\/\/______________\\\/\/\/__\\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/__\r\n\r\n\r\n                          Runtime Edition\r\n\r\n        PM2 is a Production Process Manager for Node.js applications\r\n                     with a built-in Load Balancer.\r\n\r\n                Start and Daemonize any application:\r\n                $ pm2 start app.js\r\n\r\n                Load Balance 4 instances of api.js:\r\n                $ pm2 start api.js -i 4\r\n\r\n                Monitor in production:\r\n                $ pm2 monitor\r\n\r\n                Make pm2 auto-boot at server restart:\r\n                $ pm2 startup\r\n\r\n                To go further checkout:\r\n                http:\/\/pm2.io\/\r\n\r\n\r\n                        -------------\r\n\r\n[PM2] Spawning PM2 daemon with pm2_home=\/home\/linuxmi\/.pm2\r\n[PM2] PM2 Successfully daemonized\r\n[PM2] Starting \/usr\/bin\/bash in fork_mode (1 instance)\r\n[PM2] Done.\r\n\u250c\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2502 id \u2502 name               \u2502 mode     \u2502 \u21ba    \u2502 status    \u2502 cpu      \u2502 memory   \u2502\r\n\u251c\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\r\n\u2502 0  \u2502 linuxmi-app        \u2502 fork     \u2502 0    \u2502 online    \u2502 0%       \u2502 18.6mb   \u2502\r\n\u2514\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\nlinuxmi@linuxmi:~\/www.linuxmi.com\/www$ <\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12541\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2022\/01\/ubuntu-angular-cli-pm2-run-angular-19.png\" alt=\"\" width=\"946\" height=\"1205\" \/><\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u8981\u8bbf\u95ee\u5e94\u7528\u7a0b\u5e8f\u7684Web\u754c\u9762\uff0c\u8bf7\u6253\u5f00\u6d4f\u89c8\u5668\u5e76\u4f7f\u7528\u5730\u5740http:\/\/localhost:4200\u8fdb\u884c\u5bfc\u822a\uff0c\u5982\u4ee5\u4e0b\u5c4f\u5e55\u622a\u56fe\u6240\u793a\u3002<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12542\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2022\/01\/ubuntu-angular-cli-pm2-run-angular-20.png\" alt=\"\" width=\"1920\" height=\"1200\" \/><\/p>\n<p>Angular \u7248\u672c\u67e5\u770b\uff1a<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">ng version<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12545\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2022\/01\/Angular.png\" alt=\"\" width=\"946\" height=\"837\" \/><\/p>\n<p>Angular CLI\u4e3b\u9875\uff1ahttps:\/\/angular.io\/cli<br \/>\nPM2\u4e3b\u9875\uff1ahttp:\/\/pm2.keymetrics.io\/<\/p>\n<p>\u5728\u672c\u6307\u5357\u4e2d\uff0c\u6211\u4eec\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528Angular CLI\u548cPM2\u6d41\u7a0b\u7ba1\u7406\u5668\u8fd0\u884cAngular\u5e94\u7528\u7a0b\u5e8f\u3002 \u5982\u679c\u60a8\u6709\u4efb\u4f55\u5176\u4ed6\u60f3\u6cd5\u53ef\u4ee5\u5206\u4eab\u6216\u63d0\u51fa\u95ee\u9898\uff0c\u8bf7\u901a\u8fc7\u4e0b\u9762\u7684\u7559\u8a00\u680f\u8054\u7cfb\u6211\u4eec\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Angular CLI \u662f\u4e00\u4e2aAngular\u6846\u67b6\u7684\u547d\u4ee4\u884c\u754c\u9762\u5de5\u5177\uff0c\u53ef\u7528\u4e8e\u76f4\u63a5\u4ece\u547d\u4ee4 Shell \u521d\u59cb &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3],"tags":[920,921,922],"class_list":["post-12525","post","type-post","status-publish","format-standard","hentry","category-linux","tag-angular","tag-angular-cli","tag-pm2"],"aioseo_notices":[],"views":778,"_links":{"self":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/12525","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/comments?post=12525"}],"version-history":[{"count":10,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/12525\/revisions"}],"predecessor-version":[{"id":12546,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/12525\/revisions\/12546"}],"wp:attachment":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/media?parent=12525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/categories?post=12525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/tags?post=12525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}