{"id":31,"date":"2021-08-01T11:44:20","date_gmt":"2021-08-01T11:44:20","guid":{"rendered":"https:\/\/www.miie.net\/?p=31"},"modified":"2021-08-01T11:44:20","modified_gmt":"2021-08-01T11:44:20","slug":"debian10-install-apache-mysql-php","status":"publish","type":"post","link":"https:\/\/diji.net\/?p=31","title":{"rendered":"Debian10\u5b89\u88c5LAMP"},"content":{"rendered":"<p>LAMP\u4e00\u822c\u6307Linux\u4e0a\u7684Apache MySQL PHP\u5f00\u6e90\u8f6f\u4ef6\u5305\u3002 \u8be5\u672f\u8bed\u662f\u63cf\u8ff0Linux\u64cd\u4f5c\u7cfb\u7edf\uff0cApache Web\u670d\u52a1\u5668\uff0cMariaDB\u6570\u636e\u5e93\u548cPHP\u7f16\u7a0b\u7684\u9996\u5b57\u6bcd\u7f29\u5199\u3002\u5728Debian\u53d1\u884c\u7248\u4e2dMySQL\u5df2\u7528MariaDB\u66ff\u4ee3\u3002<br \/>\n<strong>\u25cf \u9ad8\u4eae\u884c\u8868\u793a\u8981\u8f93\u5165\u7684\u547d\u4ee4\u6216\u7cfb\u7edf\u7684\u4e3b\u8981\u63d0\u793a\u3002<\/strong><\/p>\n<p><strong>1.\u5b89\u88c5Apache<\/strong><\/p>\n<pre class=\"brush: plain; highlight: [1,16]; title: ; notranslate\" title=\"\">\nuser@debian:~$ sudo apt install apache2  \/\/\u8f93\u5165\u5b89\u88c5\u547d\u4ee4\u6309\u56de\u8f66\u952e\nReading package lists... Done\nBuilding dependency tree\nReading state information... Done\nThe following additional packages will be installed:\n  apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libcurl4\n  liblua5.2-0\nSuggested packages:\n  apache2-doc apache2-suexec-pristine | apache2-suexec-custom\nThe following NEW packages will be installed:\n  apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libcurl4\n  liblua5.2-0\n0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 2,632 kB of archives.\nAfter this operation, 8,713 kB of additional disk space will be used.\nDo you want to continue? &#x5B;Y\/n]   \/\/\u8f93\u5165Y\u6216yes\uff0c\u6309\u56de\u8f66\u952e\n<\/pre>\n<p>&quot;Apache2&quot;\u4e2d\u6709\u4e2a\u6570\u5b572\u8868\u793aApache\u7684\u7248\u672c2\uff0cApache\u7684\u7248\u672c1\u5df2\u7ecf\u5f88\u53e4\u8001\u4e86\uff0c\u73b0\u5728\u662f\u7248\u672c2\u4e86\u3002\u5728\u6709\u7684\u53d1\u884c\u7248\u4e2dApache\u53c8\u53ebhttpd,Linux\u7684\u4e16\u754c\u4e2d\u5404\u4e2a\u53d1\u884c\u7248\u7684\u8f6f\u4ef6\u5305\u4e94\u82b1\u516b\u95e8\uff0c\u6240\u4ee5\u4e2a\u4eba\u8fd8\u662f\u559c\u6b22Debian\u7684\u7edf\u4e00\u89c4\u8303\u3002<br \/>\nApache\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u5b89\u88c5\u7a0b\u5e8f\u5c06\u7acb\u5373\u89e6\u53d1systemd\u7cfb\u7edf\u548c\u670d\u52a1\u7ba1\u7406\u5668\u542f\u52a8Apache2\u670d\u52a1\uff0c\u5e76\u4f7f\u5176\u5728\u7cfb\u7edf\u5f15\u5bfc\u65f6\u81ea\u52a8\u542f\u52a8\u3002\u8981\u68c0\u67e5Apache\u670d\u52a1\u662f\u5426\u5df2\u542f\u52a8\u5e76\u6b63\u5e38\u8fd0\u884c\uff0c\u8bf7\u8fd0\u884c\u4ee5\u4e0bsystemctl\u547d\u4ee4\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,4]; title: ; notranslate\" title=\"\">\n user@debian:~$ systemctl status apache2 \/\/\u8f93\u5165\u547d\u4ee4\u6309\u56de\u8f66\u952e\n\u25cf apache2.service - The Apache HTTP Server\n   Loaded: loaded (\/lib\/systemd\/system\/apache2.service; enabled; vendor preset: enabled)\n   Active: active (running) since Sun 2021-08-01 19:51:51 CST; 57s ago\n     Docs: https:\/\/httpd.apache.org\/docs\/2.4\/\n Main PID: 1697 (apache2)\n    Tasks: 55 (limit: 4661)\n   Memory: 15.6M\n   CGroup: \/system.slice\/apache2.service\n           \u251c\u25001697 \/usr\/sbin\/apache2 -k start\n           \u251c\u25001699 \/usr\/sbin\/apache2 -k start\n           \u2514\u25001700 \/usr\/sbin\/apache2 -k start\n<\/pre>\n<p>\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0bsystemctl\u547d\u4ee4\u542f\u52a8\uff0c\u505c\u6b62\uff0c\u91cd\u65b0\u542f\u52a8\u5e76\u83b7\u53d6Apache Web\u670d\u52a1\u5668\u7684\u72b6\u6001\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# systemctl start apache2.service\n# systemctl restart apache2.service\n# systemctl stop apache2.service\n# systemctl reload apache2.service\n# systemctl status apache2.service\n<\/pre>\n<p>\u73b0\u5728\u60a8\u9700\u8981\u6d4b\u8bd5Apache\u662f\u5426\u5df2\u6b63\u786e\u5b89\u88c5\u5e76\u53ef\u4ee5\u63d0\u4f9bWeb\u9875\u9762\u3002 \u6253\u5f00Web\u6d4f\u89c8\u5668\u5e76\u4f7f\u7528\u4ee5\u4e0bURL\u8bbf\u95eeApache Debian\u9ed8\u8ba4\u9875\u9762\u3002<br \/>\n<a href=\"http:\/\/SERVER_IP\/\"><a href=\"http:\/\/SERVER_IP\/\">http:\/\/SERVER_IP\/<\/a><\/a><br \/>\n\u6216\u8005<br \/>\n<a href=\"http:\/\/localhost\/\"><a href=\"http:\/\/localhost\/\">http:\/\/localhost\/<\/a><\/a><\/p>\n<p><strong>2.\u5b89\u88c5MariaDB<\/strong><br \/>\nApache Web\u670d\u52a1\u5668\u542f\u52a8\u5e76\u8fd0\u884c\u540e\uff0c\u60a8\u9700\u8981\u5b89\u88c5\u6570\u636e\u5e93\u7cfb\u7edf\u624d\u80fd\u4fdd\u7559\u548c\u7ba1\u7406\u60a8\u7f51\u7ad9\u7684\u6570\u636e\u3002\u8981\u5b89\u88c5MariaDB\uff0c\u8bf7\u4f7f\u7528Debian\u7684apt\u5305\u7ba1\u7406\u5668\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,19]; title: ; notranslate\" title=\"\">\nuser@debian:~$ sudo apt install mariadb-server  \/\/\u8f93\u5165\u5b89\u88c5\u547d\u4ee4\u6309\u56de\u8f66\u952e\nReading package lists... Done\nBuilding dependency tree\nReading state information... Done\nThe following additional packages will be installed:\n  galera-3 gawk libaio1 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl\n  libfcgi-perl libhtml-template-perl libreadline5 libsigsegv2 libterm-readkey-perl mariadb-client-10.3\n  mariadb-client-core-10.3 mariadb-server-10.3 mariadb-server-core-10.3 rsync socat\nSuggested packages:\n  gawk-doc libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl libipc-sharedcache-perl mailx\n  mariadb-test netcat-openbsd tinyca\nThe following NEW packages will be installed:\n  galera-3 gawk libaio1 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl\n  libfcgi-perl libhtml-template-perl libreadline5 libsigsegv2 libterm-readkey-perl mariadb-client-10.3\n  mariadb-client-core-10.3 mariadb-server mariadb-server-10.3 mariadb-server-core-10.3 rsync socat\n0 upgraded, 20 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 20.9 MB of archives.\nAfter this operation, 167 MB of additional disk space will be used.\nDo you want to continue? &#x5B;Y\/n]   \/\/\u8f93\u5165Y\u6216yes\uff0c\u6309\u56de\u8f66\u952e\n<\/pre>\n<p>\u5b89\u88c5MariaDB\u540e\uff0c\u5efa\u8bae\u8fd0\u884c\u5b89\u5168\u811a\u672cmysql_secure_installation\uff0c\u8be5\u811a\u672c\u5c06\u5220\u9664\u4e00\u4e9b\u4e0d\u5b89\u5168\u7684\u9ed8\u8ba4\u8bbe\u7f6e\u5e76\u7981\u7528\u5bf9\u6570\u636e\u5e93\u7cfb\u7edf\u7684\u8bbf\u95ee\u3002\u5b89\u5168\u811a\u672c\u5c06\u5f15\u5bfc\u60a8\u5b8c\u6210\u4ee5\u4e0b\u4e00\u7cfb\u5217\u95ee\u9898\uff0c\u60a8\u53ef\u4ee5\u5728\u5176\u4e2d\u5bf9MariaDB\u8bbe\u7f6e\u8fdb\u884c\u4e00\u4e9b\u66f4\u6539\u3002\u5207\u6362\u5230root\u7528\u6237\u518d\u6267\u884c\uff0c\u5b8c\u6210\u540e\u9000\u51faroot\u7528\u6237\uff0c\u4f7f\u7528sudo\u4e5f\u53ef\u4ee5\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,11,17,18,19,31,37,44,53]; title: ; notranslate\" title=\"\">\nuser@debian:~$ sudo mysql_secure_installation\n\nNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB\n      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!\n\nIn order to log into MariaDB to secure it, we'll need the current\npassword for the root user.  If you've just installed MariaDB, and\nyou haven't set the root password yet, the password will be blank,\nso you should just press enter here.\n\nEnter current password for root (enter for none):   \/\/\u63d0\u793a\u8f93\u5165\u5f53\u524dMariaDB(MySQL)root\u5bc6\u7801\uff0c\u76f4\u63a5\u6309\u56de\u8f66\u952e\nOK, successfully used password, moving on...\n\nSetting the root password ensures that nobody can log into the MariaDB\nroot user without the proper authorisation.\n\nSet root password? &#x5B;Y\/n] Y    \/\/\u662f\u5426\u8bbe\u7f6eMariaDB(MySQL)root\u7684\u5bc6\u7801\uff0c\u8f93\u5165Y\u6309\u56de\u8f66\u952e\u3002\nNew password:    \/\/\u8f93\u5165MariaDB(MySQL)root\u7684\u5bc6\u7801\nRe-enter new password:    \/\/\u518d\u6b21\u8f93\u5165MariaDB(MySQL)root\u7684\u5bc6\u7801\nPassword updated successfully!\nReloading privilege tables..\n ... Success!\n\n\nBy default, a MariaDB installation has an anonymous user, allowing anyone\nto log into MariaDB without having to have a user account created for\nthem.  This is intended only for testing, and to make the installation\ngo a bit smoother.  You should remove them before moving into a\nproduction environment.\n\nRemove anonymous users? &#x5B;Y\/n] Y    \/\/\u662f\u5426\u5220\u9664\u533f\u540d\u7528\u6237\uff0c\u8f93\u5165Y\u6309\u56de\u8f66\u952e\n ... Success!\n\nNormally, root should only be allowed to connect from 'localhost'.  This\nensures that someone cannot guess at the root password from the network.\n\nDisallow root login remotely? &#x5B;Y\/n] Y    \/\/\u662f\u5426\u7981\u7528root\u8fdc\u7a0b\u767b\u5f55\uff0c\u8f93\u5165Y\u6309\u56de\u8f66\u952e\n ... Success!\n\nBy default, MariaDB comes with a database named 'test' that anyone can\naccess.  This is also intended only for testing, and should be removed\nbefore moving into a production environment.\n\nRemove test database and access to it? &#x5B;Y\/n] Y    \/\/\u662f\u5426\u5220\u9664\u6d4b\u8bd5\u6570\u636e\u5e93\uff0c\u8f93\u5165Y\u6309\u56de\u8f66\u952e\n - Dropping test database...\n ... Success!\n - Removing privileges on test database...\n ... Success!\n\nReloading the privilege tables will ensure that all changes made so far\nwill take effect immediately.\n\nReload privilege tables now? &#x5B;Y\/n] Y    \/\/\u662f\u5426\u5728\u4e0d\u91cd\u542f\u7684\u524d\u63d0\u4e0b\u66f4\u65b0\u8bbe\u7f6e\uff0c\u8f93\u5165Y\u6309\u56de\u8f66\u952e\n ... Success!\n\nCleaning up...\n\nAll done!  If you've completed all of the above steps, your MariaDB\ninstallation should now be secure.\n\nThanks for using MariaDB!\n<\/pre>\n<\/p>\n<p>\u521b\u5efa\u540d\u4e3a\u201ct_db\u201d\u7684\u6570\u636e\u5e93\u548c\u540d\u4e3a\u201ct\u201d\u4e14\u5177\u6709\u6570\u636e\u5e93\u5b8c\u5168\u6743\u9650\u7684\u7528\u6237\uff0c\u8bf7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u3002<br \/>\n\u5728MariaDB(MySQL)\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\uff0c\u8bed\u53e5\u7ed3\u5c3e\u5fc5\u987b\u52a0\u4e0a\u5206\u53f7\u540e\u6309\u56de\u8f66\u952e\u624d\u80fd\u6267\u884c\uff0c\u5426\u8005\u4e0d\u6267\u884c\u8bed\u53e5\u3002\u5982\u679c\u6ca1\u52a0\u5206\u53f7\u6309\u4e86\u56de\u8f66\u952e\uff0c\u6ca1\u5173\u7cfb\uff0c\u5728\u4e0b\u4e00\u884c\u91cc\u8f93\u5165\u5206\u53f7\u6309\u56de\u8f66\u952e\u4e5f\u4f1a\u6267\u884c\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,2,11,14,17,20]; title: ; notranslate\" title=\"\">\nuser@debian:~$ sudo mysql -uroot -p\nEnter password:    \/\/\u8f93\u5165\u521a\u521a\u8bbe\u7f6e\u7684MariaDB(MySQL)root\u7684\u5bc6\u7801\uff0c\u4e0d\u662fDebian\u7684root\u5bc6\u7801\u3002\nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\nYour MariaDB connection id is 62\nServer version: 10.3.29-MariaDB-0+deb10u1 Debian 10\n\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nMariaDB &#x5B;(none)]&gt; CREATE DATABASE t_db;    \/\/\u521b\u5efa\u6570\u636e\u5e93\nQuery OK, 1 row affected (0.000 sec)\n\nMariaDB &#x5B;(none)]&gt; GRANT ALL ON t_db.* TO 't'@'localhost' IDENTIFIED BY '123' WITH GRANT OPTION;    \/\/\u521b\u5efa\u7528\u6237\u5e76\u6388\u4e88\u7ba1\u7406\u6743\u9650\nQuery OK, 0 rows affected (0.000 sec)     \n\nMariaDB &#x5B;(none)]&gt; FLUSH PRIVILEGES;        \/\/\u66f4\u65b0\u6570\u636e\u5e93\u8bbe\u7f6e\nQuery OK, 0 rows affected (0.000 sec)\n\nMariaDB &#x5B;(none)]&gt; exit;    \/\/\u9000\u51faMariaDB(MySQL)\nBye\n<\/pre>\n<p>\u7528\u521a\u521a\u521b\u5efa\u7684\u7528\u6237\u767b\u5f55MariaDB\u6765\u786e\u8ba4\u65b0\u7528\u6237\u662f\u5426\u5177\u6709\u6570\u636e\u5e93\u7684\u5b8c\u5168\u6743\u9650\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,2,11,20,22,25]; title: ; notranslate\" title=\"\">\nuser@debian:~$ mysql -ut -p\nEnter password:    \/\/\u8f93\u5165\u7528\u6237t\u7684\u5bc6\u7801\nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\nYour MariaDB connection id is 63\nServer version: 10.3.29-MariaDB-0+deb10u1 Debian 10\n\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nMariaDB &#x5B;(none)]&gt; SHOW DATABASES;\n+--------------------+\n| Database           |\n+--------------------+\n| information_schema |\n| t_db               |\n+--------------------+\n2 rows in set (0.000 sec)\n\nMariaDB &#x5B;(none)]&gt; USE t_db;\nDatabase changed\nMariaDB &#x5B;t_db]&gt; SHOW TABLES;\nEmpty set (0.000 sec)\n\nMariaDB &#x5B;t_db]&gt; exit;\nBye\n<\/pre>\n<\/p>\n<p><strong>3.\u5b89\u88c5PHP<\/strong><br \/>\nPHP\uff08\u8d85\u6587\u672c\u9884\u5904\u7406\u5668\uff09\u662f\u4e00\u79cd\u6d41\u884c\u7684\u811a\u672c\u8bed\u8a00\uff0c\u7528\u4e8e\u6784\u5efa\u7528\u4e8e\u663e\u793aWeb\u5185\u5bb9\u548c\u7528\u6237\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92\u7684\u903b\u8f91\u3002<br \/>\n\u5b89\u88c5PHP\u65f6\uff0c\u987a\u4fbf\u628a\u9700\u8981\u7684PHP\u6a21\u5757\u4e00\u8d77\u5b89\u88c5\u4e86\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\nuser@debian:~$ sudo apt install php libapache2-mod-php php-mysql php-mbstring php-xml \/\/\u524d\u4e09\u4e2a\u662fAMP\u8fd0\u884c\u7684\u4e3b\u7a0b\u5e8f\u57fa\u672c\u6a21\u5757\uff0c\u540e\u4e24\u4e2a\u662fphpMyAdmin\u8fd0\u884c\u6240\u9700\u6a21\u5757\nReading package lists... Done\nBuilding dependency tree\nReading state information... Done\nThe following additional packages will be installed:\n  libapache2-mod-php7.3 php-common php7.3 php7.3-cli php7.3-common php7.3-json php7.3-mbstring php7.3-mysql\n  php7.3-opcache php7.3-readline php7.3-xml\nSuggested packages:\n  php-pear\nThe following NEW packages will be installed:\n  libapache2-mod-php libapache2-mod-php7.3 php php-common php-mbstring php-mysql php-xml php7.3 php7.3-cli\n  php7.3-common php7.3-json php7.3-mbstring php7.3-mysql php7.3-opcache php7.3-readline php7.3-xml\n0 upgraded, 16 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 4,790 kB of archives.\nAfter this operation, 20.1 MB of additional disk space will be used.\nDo you want to continue? &#x5B;Y\/n]Y    \/\/\u8f93\u5165Y\u6216yes\uff0c\u6309\u56de\u8f66\u952e\n<\/pre>\n<p>\u5982\u679c\u8981\u5b89\u88c5\u5176\u4ed6PHP\u6a21\u5757\uff0c\u53ef\u4ee5\u4f7f\u7528apt-cache\u547d\u4ee4\u548cgrep\u547d\u4ee4\u7684\u7ec4\u5408\u8fdb\u884c\u641c\u7d22\u548c\u5b89\u88c5\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\nuser@debian:~$ apt-cache search php | egrep 'module' | grep default\nlibapache2-mod-php - server-side, HTML-embedded scripting language (Apache 2 module) (default)\nphp-bcmath - Bcmath module for PHP &#x5B;default]\nphp-bz2 - bzip2 module for PHP &#x5B;default]\nphp-curl - CURL module for PHP &#x5B;default]\nphp-dev - Files for PHP module development (default)\nphp-enchant - Enchant module for PHP &#x5B;default]\nphp-gd - GD module for PHP &#x5B;default]\nphp-gmp - GMP module for PHP &#x5B;default]\nphp-imap - IMAP module for PHP &#x5B;default]\nphp-interbase - Interbase module for PHP &#x5B;default]\nphp-intl - Internationalisation module for PHP &#x5B;default]\nphp-json - JSON module for PHP &#x5B;default]\nphp-ldap - LDAP module for PHP &#x5B;default]\nphp-mbstring - MBSTRING module for PHP &#x5B;default]\nphp-mysql - MySQL module for PHP &#x5B;default]\nphp-odbc - ODBC module for PHP &#x5B;default]\nphp-pgsql - PostgreSQL module for PHP &#x5B;default]\nphp-pspell - pspell module for PHP &#x5B;default]\nphp-readline - readline module for PHP &#x5B;default]\nphp-recode - recode module for PHP &#x5B;default]\nphp-snmp - SNMP module for PHP &#x5B;default]\nphp-soap - SOAP module for PHP &#x5B;default]\nphp-sqlite3 - SQLite3 module for PHP &#x5B;default]\nphp-sybase - Sybase module for PHP &#x5B;default]\nphp-tidy - tidy module for PHP &#x5B;default]\nphp-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP &#x5B;default]\nphp-xmlrpc - XMLRPC-EPI module for PHP &#x5B;default]\nphp-zip - Zip module for PHP &#x5B;default]\n<\/pre>\n<p>\u91cd\u65b0\u52a0\u8f7dApache\u7684\u914d\u7f6e\u5e76\u68c0\u67e5Apache\u8fd0\u884c\u72b6\u6001\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,5,7,10]; title: ; notranslate\" title=\"\">\nuser@debian:~$ systemctl reload apache2\n==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===\nAuthentication is required to reload 'apache2.service'.\nAuthenticating as: root\nPassword:    \/\/\u8f93\u5165Debian\u7684root\u7684\u5bc6\u7801\uff0c\u5728\u547d\u4ee4\u524d\u52a0sudo\u540e\u53ef\u4ee5\u4e0d\u7528\u8f93\u5165\u5bc6\u7801\n==== AUTHENTICATION COMPLETE ===\nuser@debian:~$ systemctl status apache2\n\u25cf apache2.service - The Apache HTTP Server\n   Loaded: loaded (\/lib\/systemd\/system\/apache2.service; enabled; vendor preset: enabled)\n   Active: active (running) since Sun 2021-08-01 20:34:39 CST; 5min ago\n     Docs: https:\/\/httpd.apache.org\/docs\/2.4\/\n  Process: 12666 ExecStart=\/usr\/sbin\/apachectl start (code=exited, status=0\/SUCCESS)\n  Process: 12886 ExecReload=\/usr\/sbin\/apachectl graceful (code=exited, status=0\/SUCCESS)\n Main PID: 12670 (apache2)\n    Tasks: 6 (limit: 4661)\n   Memory: 14.3M\n   CGroup: \/system.slice\/apache2.service\n           \u251c\u250012670 \/usr\/sbin\/apache2 -k start\n           \u251c\u250012890 \/usr\/sbin\/apache2 -k start\n           \u251c\u250012891 \/usr\/sbin\/apache2 -k start\n           \u251c\u250012892 \/usr\/sbin\/apache2 -k start\n           \u251c\u250012893 \/usr\/sbin\/apache2 -k start\n           \u2514\u250012894 \/usr\/sbin\/apache2 -k start\n<\/pre>\n<\/p>\n<p>\u6d4b\u8bd5\u529f\u80fd\u662f\u5426\u6b63\u5e38\u3002\u5728Apache\u4e0a\u6d4b\u8bd5PHP\uff0c\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684PHP\u811a\u672c\u6765\u9a8c\u8bc1Apache\u662f\u5426\u53ef\u4ee5\u5904\u7406PHP\u6587\u4ef6\u7684\u8bf7\u6c42\u3002<br \/>\n\u5728\/var\/www\/html\/\u6587\u4ef6\u5939\u91cc\u521b\u5efa\u4e00\u4e2ainfo.php\u6587\u4ef6\uff0c\u8f93\u5165\u4ee3\u7801\uff1a<code>&lt;?php phpinfo(); ?&gt;<\/code>\uff0c\u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6\u3002<br \/>\n\u5982\u679c\u521b\u5efa\u4e0d\u6210\u529f\u8bf7\u5207\u6362\u5230root\u7528\u6237\u518d\u8bd5\u8bd5\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,3,4,5]; title: ; notranslate\" title=\"\">\nuser@debian:~$ sudo echo &quot;&lt;?php phpinfo(); ?&gt;&quot; &gt; \/var\/www\/html\/info.php\n-bash: \/var\/www\/html\/info.php: Permission denied\nuser@debian:~$ su\nPassword:\nroot@debian:\/home\/x# echo &quot;&lt;?php phpinfo(); ?&gt;&quot; &gt; \/var\/www\/html\/info.php\nroot@debian:\/home\/x#\n<\/pre>\n<\/p>\n<p>\u73b0\u5728\u6253\u5f00\u6d4f\u89c8\u5668\u5e76\u952e\u5165\u4ee5\u4e0b\u5730\u5740\uff0c\u4ee5\u67e5\u770bWeb\u670d\u52a1\u5668\u662f\u5426\u53ef\u4ee5\u663e\u793a\u7531\u6b64PHP\u811a\u672c\u521b\u5efa\u7684\u5185\u5bb9\u3002<br \/>\n<a href=\"http:\/\/SERVER_IP\/info.php\"><a href=\"http:\/\/SERVER_IP\/info.php\">http:\/\/SERVER_IP\/info.php<\/a><\/a><br \/>\n\u6216\u8005<br \/>\n<a href=\"http:\/\/localhost\/info.php\"><a href=\"http:\/\/localhost\/info.php\">http:\/\/localhost\/info.php<\/a><\/a><br \/>\n\u5982\u679c\u60a8\u5728Web\u6d4f\u89c8\u5668\u4e2d\u770b\u5230\u4e0a\u9762\u7684\u9875\u9762\uff0c\u90a3\u4e48PHP\u5b89\u88c5\u6b63\u5728\u6309\u9884\u671f\u5de5\u4f5c\u3002 \u6b64\u5916\uff0c\u6b64\u9875\u9762\u663e\u793a\u4e86\u6709\u5173PHP\u5b89\u88c5\u7684\u4e00\u4e9b\u57fa\u672c\u8be6\u7ec6\u4fe1\u606f\uff0c\u5b83\u5bf9\u4e8e\u8c03\u8bd5\u975e\u5e38\u6709\u7528\uff0c\u4f46\u540c\u65f6\u5b83\u8fd8\u4f1a\u663e\u793a\u6709\u5173PHP\u7684\u4e00\u4e9b\u654f\u611f\u4fe1\u606f\u3002<\/p>\n<p><strong>4.\u5b89\u88c5phpMyAdmin<\/strong><br \/>\nphpMyAdmin\u7684\u5b98\u65b9\u7f51\u5740\u662fhttps:\/\/www.phpmyadmin.net\u3002<br \/>\n\u53ef\u4ee5\u81ea\u5df1\u4e0b\u8f7dphpMyAdmin\u4e0a\u4f20\u5230\/var\/www\/html\/\u6587\u4ef6\u5939\uff0c\u4e5f\u53ef\u4ee5wget\u4e0b\u8f7d\u89e3\u538b\u7f29\u5230\/var\/www\/html\/\u6587\u4ef6\u5939\uff0c\u65b9\u6cd5\u5f88\u591a\uff0c\u8bf7\u81ea\u884c \u63a2\u7d22\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,13,15]; title: ; notranslate\" title=\"\">\nuser@debian:~$ wget https:\/\/files.phpmyadmin.net\/phpMyAdmin\/5.1.1\/phpMyAdmin-5.1.1-all-languages.zip\n--2021-08-01 20:54:03--  https:\/\/files.phpmyadmin.net\/phpMyAdmin\/5.1.1\/phpMyAdmin-5.1.1-all-languages.zip\nResolving files.phpmyadmin.net (files.phpmyadmin.net)... 89.187.187.15, 2a02:6ea0:c800::7\nConnecting to files.phpmyadmin.net (files.phpmyadmin.net)|89.187.187.15|:443... connected.\nHTTP request sent, awaiting response... 200 OK\nLength: 14801905 (14M) &#x5B;application\/zip]\nSaving to: \u2018phpMyAdmin-5.1.1-all-languages.zip\u2019\n\nphpMyAdmin-5.1.1-all-language 100%&#x5B;=================================================&gt;]  14.12M  5.69MB\/s    in 2.5s\n\n2021-08-01 20:54:07 (5.69 MB\/s) - \u2018phpMyAdmin-5.1.1-all-languages.zip\u2019 saved &#x5B;14801905\/14801905]\n\nuser@debian:~$ ls     \/\/\u67e5\u770bphpMyAdmin\u538b\u7f29\u5305\u6587\u4ef6\u540d\uff0c\u90a3\u4e48\u957f\u61d2\u5f97\u4e00\u4e2a\u4e00\u4e2a\u6572\u3002\nDesktop  Documents  Downloads  Music  phpMyAdmin-5.1.1-all-languages.zip  Pictures  Public  Templates  Videos\nuser@debian:~$ sudo unzip phpMyAdmin-5.1.1-all-languages.zip -d \/var\/www\/html\/  \/\/\u89e3\u538b\u5230\u6307\u5b9a\u6587\u4ef6\u5939\nArchive:  phpMyAdmin-5.1.1-all-languages.zip\n   creating: \/var\/www\/html\/phpMyAdmin-5.1.1-all-languages\/\n  inflating: \/var\/www\/html\/phpMyAdmin-5.1.1-all-languages\/CONTRIBUTING.md\n  inflating: \/var\/www\/html\/phpMyAdmin-5.1.1-all-languages\/ChangeLog\n.......\n<\/pre>\n<p>\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u5728\u7f51\u5740\u4e2d\u8f93\u5165http:\/\/localhost\/\/phpMyAdmin-5.1.1-all-languages\/\u5373\u53ef\u770b\u5230\u767b\u5f55\u9875\u9762\u3002\u4f7f\u7528\u521a\u521a\u521b\u5efa\u7684\u7528\u6237t\u548c\u5bc6\u7801\u767b\u5f55phpMyAdmin\u5c31\u53ef\u4ee5\u7ba1\u7406MariaDB(MySQL)\u6570\u636e\u5e93\u3002<\/p>\n<p><strong>5.\u6700\u540e<\/strong><br \/>\n\u5728\u672c\u6587\u4e2d\uff0c\u5df2\u7ecf\u89e3\u91ca\u4e86\u5982\u4f55\u5728Debian 10\u670d\u52a1\u5668\u4e0a\u5b89\u88c5Linux\uff0cApache\uff0cMariaDB\u548cPHP\uff08LAMP\uff09\u3002<br \/>\n\u8fd9\u53ea\u662f\u5728\u5355\u673a\u5b89\u88c5LAMP\uff0c\u4ec5\u4f9b\u5b66\u4e60\u7528\u3002\u5b9e\u9645\u4e2d\u56e0\u5404\u79cd\u5b89\u5168\u95ee\u9898\u4ecd\u9700\u505a\u5927\u91cf\u5de5\u4f5c\u3002<br \/>\n\u5982\u679c\u60a8\u5bf9\u672c\u6587\u6709\u7591\u95ee\uff0c\u8bf7\u968f\u65f6\u5728\u8bc4\u8bba\u90e8\u5206\u8be2\u95ee\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>LAMP\u4e00\u822c\u6307Linux\u4e0a\u7684Apache MySQL PHP\u5f00\u6e90\u8f6f\u4ef6\u5305\u3002 \u8be5\u672f\u8bed\u662f\u63cf\u8ff0Linux\u64cd\u4f5c\u7cfb\u7edf\uff0cApache Web\u670d\u52a1\u5668\uff0cMariaDB\u6570\u636e\u5e93\u548cPHP\u7f16\u7a0b\u7684\u9996\u5b57\u6bcd\u7f29\u5199\u3002\u5728Debian\u53d1\u884c\u7248\u4e2dMySQL\u5df2\u7528MariaDB\u66ff\u4ee3\u3002 \u25cf \u9ad8\u4eae\u884c\u8868\u793a\u8981\u8f93\u5165\u7684\u547d\u4ee4\u6216\u7cfb\u7edf\u7684\u4e3b\u8981\u63d0\u793a\u3002 1.\u5b89\u88c5Apache user@debian:~$ sudo apt install apache2 \/\/\u8f93\u5165\u5b89\u88c5\u547d\u4ee4\u6309\u56de\u8f66\u952e Reading package lists&#8230; Done Building dependency tree Reading state information&#8230; Done The following additional packages will be installed: apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libcurl4 liblua5.2-0 Suggested packages: apache2-doc apache2-suexec-pristine | apache2-suexec-custom The following NEW packages will be installed: apache2 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-31","post","type-post","status-publish","format-standard","hentry","category-debian"],"_links":{"self":[{"href":"https:\/\/diji.net\/index.php?rest_route=\/wp\/v2\/posts\/31","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/diji.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/diji.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/diji.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/diji.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=31"}],"version-history":[{"count":0,"href":"https:\/\/diji.net\/index.php?rest_route=\/wp\/v2\/posts\/31\/revisions"}],"wp:attachment":[{"href":"https:\/\/diji.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=31"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/diji.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=31"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/diji.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=31"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}