{"id":14,"date":"2022-03-21T11:55:39","date_gmt":"2022-03-21T03:55:39","guid":{"rendered":"http:\/\/47.118.40.97:8082\/?p=14"},"modified":"2023-09-22T14:04:09","modified_gmt":"2023-09-22T06:04:09","slug":"ubuntu-lamp%e7%8e%af%e5%a2%83%e9%83%a8%e7%bd%b2","status":"publish","type":"post","link":"http:\/\/danielw.top\/?p=14","title":{"rendered":"Ubuntu\u2014LAMP\u73af\u5883\u90e8\u7f72"},"content":{"rendered":"<h5>\u5173\u95ed\u9632\u706b\u5899<\/h5>\n<p>\u8fd0\u884c ufw status\uff08Linux\u4f7f\u7528systemctl status firewalld\uff09\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u9632\u706b\u5899\u7684\u72b6\u6001<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321101531525.png\" alt=\"image-20220321101531525\" \/><\/p>\n<ul>\n<li>\u5982\u679c\u9632\u706b\u5899\u7684\u72b6\u6001\u53c2\u6570\u662finactive\uff0c\u5219\u9632\u706b\u5899\u4e3a\u5173\u95ed\u72b6\u6001\uff1b\u5982\u679c\u9632\u706b\u5899\u7684\u72b6\u6001\u53c2\u6570\u662factive\uff0c\u5219\u9632\u706b\u5899\u4e3a\u5f00\u542f\u72b6\u6001\uff0c\u9700\u8981\u8fdb\u884c\u5173\u95ed\n<ul>\n<li>\u4e34\u65f6\u5173\u95ed\u9632\u706b\u5899\uff0c\u8fd0\u884c\u547d\u4ee4systemctl stop firewalld<\/li>\n<li>\u6c38\u4e45\u5173\u95ed\u9632\u706b\u5899\uff0c\u8fd0\u884c\u547d\u4ee4systemctl disable firewalld<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h5>\u5173\u95edSELinux\uff08\u4ec5CentOS\u548cRed Hat\uff09<\/h5>\n<p>\u8fd0\u884cgetenforce\u547d\u4ee4\u67e5\u770bSELinux\u7684\u5f53\u524d\u72b6\u6001<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321100505071.png\" alt=\"image-20220321100505071\" \/><\/p>\n<ul>\n<li>\u5982\u679cSELinux\u72b6\u6001\u53c2\u6570\u662fDisabled\uff0c \u5219SELinux\u4e3a\u5173\u95ed\u72b6\u6001\uff1b\u5982\u679cSELinux\u72b6\u6001\u53c2\u6570\u662fEnforcing\uff0c\u5219SELinux\u4e3a\u5f00\u542f\u72b6\u6001\uff0c\u9700\u8981\u8fdb\u884c\u5173\u95ed\n<ul>\n<li>\u4e34\u65f6\u5173\u95edSELinux\uff0c\u8fd0\u884c\u547d\u4ee4<code>setenforce 0<\/code><\/li>\n<li>\u6c38\u4e45\u5173\u95edSELinux\uff0c\u8fd0\u884c\u547d\u4ee4vi \/etc\/selinux\/config\u7f16\u8f91SELinux\u914d\u7f6e\u6587\u4ef6\u3002\u56de\u8f66\u540e\uff0c\u628a\u5149\u6807\u79fb\u52a8\u5230<code>SELINUX=enforcing<\/code>\u8fd9\u4e00\u884c\uff0c\u6309i\u952e\uff0c\u5c06\u5176\u4fee\u6539\u4e3a<code>SELINUX=disabled<\/code>\uff0c \u6309Esc\u952e\uff0c\u7136\u540e\u8f93\u5165:wq\u5e76\u56de\u8f66\u4ee5\u4fdd\u5b58\u5e76\u5173\u95edSELinux\u914d\u7f6e\u6587\u4ef6\u3002 \u6700\u540e\u91cd\u542f\u7cfb\u7edf\u4f7f\u8bbe\u7f6e\u751f\u6548<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321100744564.png\" alt=\"image-20220321100744564\" \/><\/p>\n<p>\u6ce8\uff1a\u8fd9\u91cc\u7684SELinux\u53ea\u5728CentOS\u548cRed Hat\u4e2d\u5b58\u5728\uff0cUbuntu\u4e2d\u4e0d\u5b58\u5728<\/p>\n<h4>\u5b89\u88c5Apache<\/h4>\n<h5>\u66f4\u65b0\u8f6f\u4ef6\u5305<\/h5>\n<pre><code class=\"language-shell\">apt-get update<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321101952554.png\" alt=\"image-20220321101952554\" \/><\/p>\n<h5>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Apache<\/h5>\n<pre><code class=\"language-shell\">apt-get -y install apache2<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321102105765.png\" alt=\"image-20220321102105765\" \/><\/p>\n<h5>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770bApache\u7248\u672c<\/h5>\n<pre><code class=\"language-shell\">apache2 -v<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321102137223.png\" alt=\"image-20220321102137223\" \/><\/p>\n<h5>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u542f\u52a8Apache\u670d\u52a1\u5e76\u8bbe\u7f6e\u670d\u52a1\u5f00\u673a\u81ea\u542f\u52a8<\/h5>\n<pre><code class=\"language-shell\">systemctl start apache2<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321102244472.png\" alt=\"image-20220321102244472\" \/><\/p>\n<h5>\u5728\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95ee\u672c\u673a\u5730\u5740\uff08127.0.0.1\uff09\u51fa\u73b0\u5982\u4e0b\u754c\u9762\u5219\u8868\u793aApache\u670d\u52a1\u5904\u4e8e\u6b63\u5e38\u8fd0\u884c\u72b6\u6001<\/h5>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321102437961.png\" alt=\"image-20220321102437961\" \/><\/p>\n<h4>\u5b89\u88c5\u914d\u7f6eMySQL<\/h4>\n<h5>\u5b89\u88c5MySQL<\/h5>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5b89\u88c5MySQL<\/p>\n<pre><code class=\"language-shell\">apt-get -y install mysql-server<\/code><\/pre>\n<p>\u5728\u6267\u884c\u547d\u4ee4\u65f6\u53ef\u80fd\u4f1a\u9047\u5230\u5982\u4e0b\u62a5\u9519<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321105223743.png\" alt=\"image-20220321105223743\" \/><\/p>\n<ul>\n<li>\u6253\u5f00\u7ec8\u7aef\u8f93\u5165\u5982\u4e0b\u547d\u4ee4<\/li>\n<\/ul>\n<pre><code class=\"language-shell\">curl -OL https:\/\/dev.mysql.com\/get\/mysql-apt-config_0.8.22-1_all.deb <\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321105446730.png\" alt=\"image-20220321105446730\" \/><\/p>\n<ul>\n<li>\u4e0b\u8f7d\u597d\u540e\u8fd0\u884c<\/li>\n<\/ul>\n<pre><code class=\"language-shell\">dpkg -i mysql-apt-config*<\/code><\/pre>\n<p>\u5728\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u4f1a\u51fa\u73b0\u4ee5\u4e0b\u754c\u9762\uff0c\u6309\u7167\u5982\u56fe\u64cd\u4f5c<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321104238033.png\" alt=\"image-20220321104238033\" \/><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321104330329.png\" alt=\"image-20220321104330329\" \/><\/p>\n<p>\u9009\u62e9MySQL\u7248\u672c<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321104402149.png\" alt=\"image-20220321104402149\" \/><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321104444231.png\" alt=\"image-20220321104444231\" \/><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321105116746.png\" alt=\"image-20220321105116746\" \/><\/p>\n<p>\u51fa\u73b0OK\u4ee3\u8868\u6210\u529f<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321105536732.png\" alt=\"image-20220321105536732\" \/><\/p>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5MySQL\u5373\u53ef<\/p>\n<pre><code class=\"language-shell\">apt-get update\napt-get -y install mysql-server(\u8fd0\u884c\u8be5\u547d\u4ee4\u65f6\u4f1a\u51fa\u73b0\u4e0b\u56fe\u5185\u5bb9\uff0c\u9009\u62e9\u786e\u5b9a\u5373\u53ef)<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321105133535.png\" alt=\"image-20220321105133535\" \/><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321110041770.png\" alt=\"image-20220321110041770\" \/><\/p>\n<h5>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770bMySQL\u7248\u672c<\/h5>\n<pre><code class=\"language-shell\">mysql -V<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321110206691.png\" alt=\"image-20220321110206691\" \/><\/p>\n<h5>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u542f\u52a8MySQL\u670d\u52a1<\/h5>\n<pre><code class=\"language-shell\">systemctl start mysql<\/code><\/pre>\n<p>\u5982\u679c\u9047\u5230\u62a5\u9519<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321110815150.png\" alt=\"image-20220321110815150\" \/><\/p>\n<p>\u89e3\u51b3\u65b9\u6848<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321110926760.png\" alt=\"image-20220321110926760\" \/><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321110938665.png\" alt=\"image-20220321110938665\" \/><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321111001488.png\" alt=\"image-20220321111001488\" \/><\/p>\n<p>\u518d\u8fdb\u884c\u542f\u52a8\u5373\u53ef<\/p>\n<h5>\u914d\u7f6eMySQL<\/h5>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5bf9MySQL\u8fdb\u884c\u5b89\u5168\u6027\u914d\u7f6e<\/p>\n<pre><code class=\"language-shell\">mysql_secure_installation<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/MySQL1.png\" alt=\"MySQL1\" \/><\/p>\n<h5>\u6d4b\u8bd5\u767b\u5f55MySQL\u6570\u636e\u5e93<\/h5>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u767b\u5f55MySQL\u6570\u636e\u5e93\uff0c\u5728\u547d\u4ee4\u884c\u56de\u663e\u7684Enter password:\u540e\u8f93\u5165\u5df2\u8bbe\u7f6e\u7684\u6570\u636e\u5e93\u5bc6\u7801<\/p>\n<pre><code class=\"language-shell\">mysql -uroot -p<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321113020470.png\" alt=\"image-20220321113020470\" \/><\/p>\n<h4>\u5b89\u88c5PHP<\/h4>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5b89\u88c5PHP<\/p>\n<pre><code class=\"language-shell\">apt-get -y install php-fpm<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321114107097.png\" alt=\"image-20220321114107097\" \/><\/p>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770bPHP\u7248\u672c<\/p>\n<pre><code class=\"language-shell\">php -v<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321114158730.png\" alt=\"image-20220321114158730\" \/><\/p>\n<h4>\u521b\u5efa\u5e76\u8bbf\u95ee\u6d4b\u8bd5\u7f51\u9875<\/h4>\n<h5>\u5728Apache\u7f51\u7ad9\u6839\u76ee\u5f55\u4e2d\uff0c\u521b\u5efa\u6d4b\u8bd5\u7f51\u9875<\/h5>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u67e5\u770bApache\u7f51\u7ad9\u6839\u76ee\u5f55\u7684\u8def\u5f84\u4fe1\u606f<\/p>\n<pre><code class=\"language-shell\">cat \/etc\/apache2\/sites-available\/000-default.conf<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321114359087.png\" alt=\"image-20220321114359087\" \/><\/p>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5728\u7f51\u7ad9\u6839\u76ee\u5f55\u521b\u5efa\u6d4b\u8bd5\u7f51\u9875\uff0c\u5e76\u628a<code>phpinfo()<\/code>\u51fd\u6570\u6dfb\u52a0\u81f3\u7f51\u9875\u5185\u5bb9\u4e2d\uff0c<code>phpinfo()<\/code>\u51fd\u6570\u4f1a\u5c55\u793aPHP\u7684\u6240\u6709\u914d\u7f6e\u4fe1\u606f<\/p>\n<pre><code class=\"language-shell\">echo &quot;&lt;?php phpinfo(); ?&gt;&quot; &gt; \/var\/www\/html\/phpinfo.php<\/code><\/pre>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u91cd\u542fApache\u670d\u52a1<\/p>\n<pre><code class=\"language-shell\">systemctl restart apache2<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321114545268.png\" alt=\"image-20220321114545268\" \/><\/p>\n<p>\u5728\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95ee  <a href=\"http:\/\/127.0.0.1\/phpinfo.php\" target=\"_blank\"  rel=\"nofollow\" >http:\/\/127.0.0.1\/phpinfo.php<\/a> \u770b\u5230PHP\u914d\u7f6e\u9875\u9762\u4fe1\u606f\uff0c\u8868\u793aLAMP\u73af\u5883\u90e8\u7f72\u6210\u529f<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321114800869.png\" alt=\"image-20220321114800869\" \/><\/p>\n<h5>\u6d4b\u8bd5MySQL\u8fde\u63a5<\/h5>\n<pre><code class=\"language-php\">&lt;?php\n    $servername=&quot;127.0.0.1&quot;;\n    $username=&quot;\u7528\u6237\u540d&quot;;\n    $password=&quot;\u5bc6\u7801&quot;;\n    $conn=new mysqli($servername,$username,$password);\n    if(!$conn){\n        echo &#039;ERROR&#039;;\n    }\n    else{\n        echo &#039;SUCCESS&#039;;\n    }\n?&gt;<\/code><\/pre>\n<h5>\u6d4f\u89c8\u5668\u8bbf\u95ee\u67e5\u770b\u7ed3\u679c<\/h5>\n<p><img decoding=\"async\" src=\"http:\/\/img.danielw.top\/image-20220321170809657.png\" alt=\"image-20220321170809657\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5173\u95ed\u9632\u706b\u5899 \u8fd0\u884c ufw status\uff08Linux\u4f7f\u7528systemctl status firewalld\uff09\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u9632\u706b\u5899\u7684\u72b6 &#8230;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-14","post","type-post","status-publish","format-standard","hentry","category-4"],"_links":{"self":[{"href":"http:\/\/danielw.top\/index.php?rest_route=\/wp\/v2\/posts\/14","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/danielw.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/danielw.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/danielw.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/danielw.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14"}],"version-history":[{"count":3,"href":"http:\/\/danielw.top\/index.php?rest_route=\/wp\/v2\/posts\/14\/revisions"}],"predecessor-version":[{"id":142,"href":"http:\/\/danielw.top\/index.php?rest_route=\/wp\/v2\/posts\/14\/revisions\/142"}],"wp:attachment":[{"href":"http:\/\/danielw.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/danielw.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/danielw.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}