{"id":161,"date":"2012-08-10T13:18:08","date_gmt":"2012-08-10T05:18:08","guid":{"rendered":"http:\/\/www.80.my\/?p=140"},"modified":"2012-08-10T13:18:08","modified_gmt":"2012-08-10T05:18:08","slug":"debian-6-lamp","status":"publish","type":"post","link":"https:\/\/www.lnlog.cn\/index.php\/2012\/08\/10\/debian-6-lamp\/","title":{"rendered":"Debian 6.0.4\u5b89\u88c5\u914d\u7f6elamp\uff08Apache+MySQL+PHP\uff09"},"content":{"rendered":"<p><strong>\u51c6\u5907\u7bc7\uff1a<\/strong><br \/>\n<strong>1\u3001\u914d\u7f6e\u9632\u706b\u5899\uff0c\u5f00\u542f80\u7aef\u53e3\u30013306\u7aef\u53e3<\/strong><br \/>\n\u8bf4\u660e\uff1adebian\u9ed8\u8ba4\u5b89\u88c5\u662f\u6ca1\u6709\u5f00\u542f\u4efb\u4f55\u9632\u706b\u5899\u7684\uff0c\u4e3a\u4e86\u670d\u52a1\u5668\u7684\u5b89\u5168\uff0c\u5efa\u8bae\u5927\u5bb6\u5b89\u88c5\u542f\u7528\u9632\u706b\u5899\u8bbe\u7f6e\uff0c\u8fd9\u91cc\u63a8\u8350\u4f7f\u7528iptables\u9632\u706b\u5899\u3002<br \/>\nwhereis iptables\u00a0\u00a0 #\u67e5\u770b\u7cfb\u7edf\u662f\u5426\u5b89\u88c5\u9632\u706b\u5899<br \/>\niptables: \/sbin\/iptables \/usr\/share\/iptables \/usr\/share\/man\/man8\/iptables.8.gz\u00a0 #\u8868\u793a\u5df2\u7ecf\u5b89\u88c5iptables<br \/>\napt-get install iptables\u00a0\u00a0 #\u5982\u679c\u9ed8\u8ba4\u6ca1\u6709\u5b89\u88c5\uff0c\u8bf7\u8fd0\u884c\u6b64\u547d\u4ee4\u5b89\u88c5\u9632\u706b\u5899<br \/>\niptables -L\u00a0 #\u67e5\u770b\u9632\u706b\u5899\u914d\u7f6e\u4fe1\u606f\uff0c\u663e\u793a\u5982\u4e0b\uff1a<br \/>\n\u7cfb\u7edf\u8fd0\u7ef4\u00a0<a href=\"http:\/\/www.osyunwei.com\/\">www.osyunwei.com<\/a>\u00a0\u6e29\u99a8\u63d0\u9192\uff1aqihang01\u539f\u521b\u5185\u5bb9\u00a9\u7248\u6743\u6240\u6709,\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\u53ca\u539f\u6587\u94fe\u63a5<br \/>\n#####################################################<br \/>\nChain INPUT (policy ACCEPT)<br \/>\ntarget\u00a0\u00a0\u00a0\u00a0 prot opt source\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 destination<\/p>\n<p>Chain FORWARD (policy ACCEPT)<br \/>\ntarget\u00a0\u00a0\u00a0\u00a0 prot opt source\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 destination<\/p>\n<p>Chain OUTPUT (policy ACCEPT)<br \/>\ntarget\u00a0\u00a0\u00a0\u00a0 prot opt source\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 destination<br \/>\n#####################################################<br \/>\nnano \/etc\/iptables.default.rules\u00a0\u00a0\u00a0 #\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9<br \/>\n##################################################################################################<br \/>\n*filter<br \/>\n# Allows all loopback (lo0) traffic and drop all traffic to 127\/8 that doesn&#8217;t use lo0<br \/>\n-A INPUT -i lo -j ACCEPT<br \/>\n# Accepts all established inbound connections<br \/>\n-A INPUT -m state &#8211;state ESTABLISHED,RELATED -j ACCEPT<br \/>\n# Allows all outbound traffic<br \/>\n# You could modify this to only allow certain traffic<br \/>\n-A OUTPUT -j ACCEPT<br \/>\n# Allows HTTP and MySQLconnections from anywhere (the normal ports for websites)<br \/>\n-A INPUT -p tcp &#8211;dport 80 -j ACCEPT<br \/>\n-A INPUT -p tcp &#8211;dport 3306 -j ACCEPT<br \/>\n# Allows SSH connections for script kiddies<br \/>\n# THE -dport NUMBER IS THE SAME ONE YOU SET UP IN THE SSHD_CONFIG FILE<br \/>\n-A INPUT -p tcp -m state &#8211;state NEW &#8211;dport 22 -j ACCEPT<br \/>\n# Now you should read up on iptables rules and consider whether ssh access<br \/>\n# for everyone is really desired. Most likely you will only allow access from certain IPs.<br \/>\n# Allow ping<br \/>\n-A INPUT -p icmp -m icmp &#8211;icmp-type 8 -j ACCEPT<br \/>\n# log iptables denied calls (access via &#8216;dmesg&#8217; command)<br \/>\n-A INPUT -m limit &#8211;limit 5\/min -j LOG &#8211;log-prefix &#8220;iptables denied: &#8221; &#8211;log-level 7<br \/>\n# Reject all other inbound &#8211; default deny unless explicitly allowed policy:<br \/>\n-A INPUT -j REJECT<br \/>\n-A FORWARD -j REJECT<br \/>\nCOMMIT<br \/>\n##################################################################################################<br \/>\nctrl+o\u00a0 #\u4fdd\u5b58<br \/>\nctrl+x\u00a0 #\u9000\u51fa<br \/>\n\u7cfb\u7edf\u8fd0\u7ef4\u00a0<a href=\"http:\/\/www.osyunwei.com\/\">www.osyunwei.com<\/a>\u00a0\u6e29\u99a8\u63d0\u9192\uff1aqihang01\u539f\u521b\u5185\u5bb9\u00a9\u7248\u6743\u6240\u6709,\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\u53ca\u539f\u6587\u94fe\u63a5<br \/>\n<strong>\u5907\u6ce8\uff1a80\u662f\u6307web\u670d\u52a1\u5668\u7aef\u53e3\u30013306\u662f\u6307MySQL\u6570\u636e\u5e93\u94fe\u63a5\u7aef\u53e3\u300122\u662f\u6307SSH\u8fdc\u7a0b\u7ba1\u7406\u7aef\u53e3<\/strong><br \/>\niptables-restore &lt; \/etc\/iptables.default.rules\u00a0\u00a0\u00a0 #\u4f7f\u9632\u706b\u5899\u89c4\u5219\u751f\u6548<br \/>\nnano\u00a0 \/etc\/network\/if-pre-up.d\/iptables\u00a0\u00a0 #\u521b\u5efa\u6587\u4ef6\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff0c\u4f7f\u9632\u706b\u5899\u5f00\u673a\u542f\u52a8<br \/>\n##########################################################<br \/>\n#!\/bin\/bash<br \/>\n\/sbin\/iptables-restore &lt;\/etc\/iptables.default.rules<br \/>\n##########################################################<br \/>\nchmod +x\u00a0 \/etc\/network\/if-pre-up.d\/iptables\u00a0 #\u6dfb\u52a0\u6267\u884c\u6743\u9650<br \/>\n<strong>\u5b89\u88c5\u7bc7<\/strong><br \/>\n<strong>\u4e00\u3001\u5b89\u88c5apache<\/strong><br \/>\napt-get install apache2\u00a0\u00a0\u00a0 #\u5b89\u88c5apache\uff0c\u6839\u636e\u63d0\u793a\u8f93\u5165y\u5b89\u88c5<br \/>\nservice apache2 start\u00a0 #\u542f\u52a8apache<br \/>\nservice apache2 restart\u00a0 #\u91cd\u542f<br \/>\napt-get install chkconfig\u00a0 #\u5b89\u88c5chkconfig<br \/>\nchkconfig\u00a0 apache2\u00a0 on\u00a0\u00a0 #\u5f00\u673a\u542f\u52a8apache<br \/>\n<strong>\u4e8c\u3001\u5b89\u88c5MySQL<\/strong><br \/>\napt-get install\u00a0 mysql-server\u00a0\u00a0 #\u5b89\u88c5mysql\uff0c\u6839\u636e\u63d0\u793a\u8f93\u5165y\u5b89\u88c5<br \/>\n\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u4f1a\u8df3\u51fa\u8f93\u5165root\u5bc6\u7801\u7684\u754c\u9762<br \/>\n\u8f93\u51652\u6b21\u5bc6\u7801\uff0c\u7ee7\u7eed\u81ea\u52a8\u5b89\u88c5<\/p>\n<p>\u7cfb\u7edf\u8fd0\u7ef4\u00a0<a href=\"http:\/\/www.osyunwei.com\/\">www.osyunwei.com<\/a>\u00a0\u6e29\u99a8\u63d0\u9192\uff1aqihang01\u539f\u521b\u5185\u5bb9\u00a9\u7248\u6743\u6240\u6709,\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\u53ca\u539f\u6587\u94fe\u63a5<br \/>\nservice mysql start\u00a0\u00a0 #\u542f\u52a8<br \/>\nchkconfig mysql on\u00a0\u00a0\u00a0 #\u5f00\u673a\u542f\u52a8mysql<br \/>\nservice mysql restart\u00a0 \u00a0#\u91cd\u542f<br \/>\n<strong>\u4e09\u3001\u5b89\u88c5php<\/strong><br \/>\n1\u3001apt-get\u00a0 install php5\u00a0\u00a0 #\u5b89\u88c5php5\uff0c\u6839\u636e\u63d0\u793a\u8f93\u5165y\u5b89\u88c5<br \/>\n2\u3001\u5b89\u88c5PHP\u7ec4\u4ef6\uff0c\u4f7fPHP\u652f\u6301 MySQL<br \/>\napt-get install php5-mysql php5-gd libjpeg8-dev php5-imap php5-ldap php5-odbc php*-pear php*-xml php5-xmlrpc\u00a0 php5-mcrypt\u00a0 php5-mhash libmcrypt* libmcrypt-dev php-fpdf<br \/>\n\/etc\/init.d\/mysql restart\u00a0 #\u91cd\u542fmysql<br \/>\n\/etc\/init.d\/apache2 restart #\u91cd\u542fapache2<br \/>\nln -s \/etc\/php5\/apache2\/php.ini\u00a0 \/etc\/php.ini\u00a0 #\u628aphp\u914d\u7f6e\u6587\u4ef6\u94fe\u63a5\u5230\u7cfb\u7edf\u9ed8\u8ba4\u4f4d\u7f6e<br \/>\n<strong>\u914d\u7f6e\u7bc7<\/strong><br \/>\n<strong>\u4e00\u3001Apache\u914d\u7f6e<\/strong><br \/>\ncp \/etc\/apache2\/apache2.conf\u00a0 \/etc\/apache2\/apache2.confbak\u00a0\u00a0 #\u5907\u4efd<br \/>\nnano\u00a0\u00a0 \/etc\/apache2\/apache2.conf\u00a0 #\u7f16\u8f91<br \/>\nServerTokens Prod\u00a0\u00a0\u00a0\u00a0 #\u5728\u51fa\u73b0\u9519\u8bef\u9875\u7684\u65f6\u5019\u4e0d\u663e\u793a\u670d\u52a1\u5668\u64cd\u4f5c\u7cfb\u7edf\u7684\u540d\u79f0<br \/>\nServerSignature Off\u00a0\u00a0 #\u5728\u5728\u9519\u8bef\u9875\u4e2d\u4e0d\u663e\u793aapache2\u7684\u7248\u672c<br \/>\nMaxKeepAliveRequests 1000\u00a0 #\u4fee\u6539\u4e3a1000\uff08\u9ed8\u8ba4\u4e3a100\uff0c\u589e\u52a0\u540c\u65f6\u8fde\u63a5\u6570\uff09<br \/>\nctrl+o\u00a0 #\u4fdd\u5b58<br \/>\nctrl+x\u00a0 #\u9000\u51fa<br \/>\nnano \/etc\/apache2\/sites-enabled\/000-default #\u7f16\u8f91<br \/>\nOptions MultiViews FollowSymLinks\u00a0 #\u4e0d\u5728\u6d4f\u89c8\u5668\u4e0a\u663e\u793a\u6811\u72b6\u76ee\u5f55\u7ed3\u6784<br \/>\nctrl+o\u00a0 #\u4fdd\u5b58<br \/>\nctrl+x\u00a0 #\u9000\u51fa<br \/>\na2enmod rewrite\u00a0\u00a0 #\u6fc0\u6d3bapache2\u4f2a\u9759\u6001\u6a21\u5757mod rewrite<br \/>\n\u7cfb\u7edf\u8fd0\u7ef4\u00a0<a href=\"http:\/\/www.osyunwei.com\/\">www.osyunwei.com<\/a>\u00a0\u6e29\u99a8\u63d0\u9192\uff1aqihang01\u539f\u521b\u5185\u5bb9\u00a9\u7248\u6743\u6240\u6709,\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\u53ca\u539f\u6587\u94fe\u63a5<br \/>\n<strong>\u4e8c\u3001\u914d\u7f6ephp<\/strong><br \/>\nnano\u00a0 \/etc\/php5\/apache2\/php.ini\u00a0\u00a0 #\u7f16\u8f91<br \/>\ndate.timezone = PRC\u00a0\u00a0\u00a0\u00a0 #\u5728946\u884c \u628a\u524d\u9762\u7684\u5206\u53f7\u53bb\u6389\uff0c\u6539\u4e3adate.timezone = PRC<br \/>\ndisable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname<br \/>\n#\u5728386\u884c \u5217\u51faPHP\u53ef\u4ee5\u7981\u7528\u7684\u51fd\u6570\uff0c\u5982\u679c\u67d0\u4e9b\u7a0b\u5e8f\u9700\u8981\u7528\u5230\u8fd9\u4e2a\u51fd\u6570\uff0c\u53ef\u4ee5\u5220\u9664\uff0c\u53d6\u6d88\u7981\u7528\u3002<br \/>\nexpose_php = Off\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u5728432\u884c \u7981\u6b62\u663e\u793aphp\u7248\u672c\u7684\u4fe1\u606f<br \/>\nmagic_quotes_gpc = On\u00a0\u00a0 #\u5728745\u884c \u6253\u5f00magic_quotes_gpc\u6765\u9632\u6b62SQL\u6ce8\u5165<br \/>\nopen_basedir = .:\/tmp\/\u00a0 #\u5728380\u884c\uff0c\u8bbe\u7f6e\u8868\u793a\u5141\u8bb8\u8bbf\u95ee\u5f53\u524d\u76ee\u5f55(\u5373PHP\u811a\u672c\u6587\u4ef6\u6240\u5728\u4e4b\u76ee\u5f55)\u548c\/tmp\/\u76ee\u5f55,\u53ef\u4ee5\u9632\u6b62php\u6728\u9a6c\u8de8\u7ad9\uff0c\u5982\u679c\u6539\u4e86\u4e4b\u540e\u5b89\u88c5\u7a0b\u5e8f\u6709\u95ee\u9898\uff0c\u53ef\u6ce8\u9500\u6b64\u884c\uff0c\u6216\u8005\u76f4\u63a5\u5199\u4e0a\u7a0b\u5e8f\u76ee\u5f55\u8def\u5f84\/var\/www\/www.osyunwei.com\/:\/tmp\/<br \/>\nctrl+o\u00a0 #\u4fdd\u5b58<br \/>\nctrl+x\u00a0 #\u9000\u51fa<br \/>\n<strong>\u6d4b\u8bd5\u7bc7<br \/>\n<\/strong>cd \/var\/www\u00a0 #\u8fdb\u5165\u9ed8\u8ba4\u7ad9\u70b9\u76ee\u5f55<br \/>\nnano index.php\u00a0\u00a0 #\u65b0\u5efa\u6d4b\u8bd5\u6587\u4ef6<br \/>\n&lt;?php<br \/>\nphpinfo();<br \/>\n?&gt;<br \/>\nctrl+o\u00a0 #\u4fdd\u5b58<br \/>\nctrl+x\u00a0 #\u9000\u51fa<br \/>\nchown www-data.www-data -R\u00a0 \/var\/www\u00a0\u00a0 #\u6dfb\u52a0\u76ee\u5f55\u6240\u6709\u8005<br \/>\nchmod 700\u00a0 -R\u00a0 \/var\/www\u00a0 #\u8bbe\u7f6e\u76ee\u5f55\u6743\u9650<br \/>\n\u5728\u5ba2\u6237\u7aef\u6d4f\u89c8\u5668\u8f93\u5165\u670d\u52a1\u5668IP\u5730\u5740\uff0c\u53ef\u4ee5\u770b\u5230\u76f8\u5173\u7684\u914d\u7f6e\u4fe1\u606f\uff01<br \/>\n<strong>\u5907\u6ce8\uff1a<\/strong><br \/>\napache2\u9ed8\u8ba4\u7ad9\u70b9\u76ee\u5f55\u662f\uff1a\/var\/www<br \/>\n\u6743\u9650\u8bbe\u7f6e\uff1achown www-data.www-data -R\u00a0 \/var\/www<br \/>\napache2\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u6587\u4ef6\uff1a\/etc\/apache2\/sites-enabled\/000-default\u00a0\u00a0 #\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u6587\u4ef6<br \/>\nMySQL\u6570\u636e\u5e93\u76ee\u5f55\u662f\uff1a\/var\/lib\/mysql<br \/>\n\u6743\u9650\u8bbe\u7f6e\uff1achown mysql.mysql -R\u00a0 \/var\/lib\/mysql<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u51c6\u5907\u7bc7\uff1a 1\u3001\u914d\u7f6e\u9632\u706b\u5899\uff0c\u5f00\u542f80\u7aef\u53e3\u30013306\u7aef\u53e3 \u8bf4\u660e\uff1adebian\u9ed8\u8ba4\u5b89\u88c5\u662f\u6ca1\u6709\u5f00\u542f\u4efb\u4f55\u9632\u706b\u5899\u7684\uff0c\u4e3a\u4e86\u670d &hellip; <a href=\"https:\/\/www.lnlog.cn\/index.php\/2012\/08\/10\/debian-6-lamp\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">Debian 6.0.4\u5b89\u88c5\u914d\u7f6elamp\uff08Apache+MySQL+PHP\uff09<\/span><\/a><\/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":[30,50,51],"class_list":["post-161","post","type-post","status-publish","format-standard","hentry","category-tech","tag-debian","tag-lamp","tag-linux"],"_links":{"self":[{"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/posts\/161","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=161"}],"version-history":[{"count":0,"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/posts\/161\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}