{"id":42716,"date":"2024-10-04T00:51:38","date_gmt":"2024-10-03T16:51:38","guid":{"rendered":"https:\/\/server.hk\/cnblog\/42716\/"},"modified":"2024-10-04T00:51:38","modified_gmt":"2024-10-03T16:51:38","slug":"centos-7-lnmp-%e7%92%b0%e5%a2%83%e6%90%ad%e5%bb%ba-zabbix-3-0","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/42716\/","title":{"rendered":"CentOS 7 LNMP \u74b0\u5883\u642d\u5efa Zabbix 3.0"},"content":{"rendered":"<h1 id=\"centos-7-lnmp-%e7%92%b0%e5%a2%83%e6%90%ad%e5%bb%ba-zabbix-3-0-pOORYrYvca\">CentOS 7 LNMP \u74b0\u5883\u642d\u5efa Zabbix 3.0<\/h1>\n<p>\u5728\u7576\u4eca\u7684 IT \u74b0\u5883\u4e2d\uff0c\u76e3\u63a7\u7cfb\u7d71\u7684\u9700\u6c42\u65e5\u76ca\u589e\u52a0\u3002Zabbix \u4f5c\u70ba\u4e00\u6b3e\u5f37\u5927\u7684\u958b\u6e90\u76e3\u63a7\u89e3\u6c7a\u65b9\u6848\uff0c\u80fd\u5920\u5e6b\u52a9\u7528\u6236\u5be6\u6642\u76e3\u63a7\u4f3a\u670d\u5668\u3001\u7db2\u7d61\u8a2d\u5099\u53ca\u61c9\u7528\u7a0b\u5e8f\u7684\u6027\u80fd\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 7 \u4e0a\u642d\u5efa LNMP \u74b0\u5883\u4e26\u5b89\u88dd Zabbix 3.0\u3002<\/p>\n<h2 id=\"lnmp-%e7%92%b0%e5%a2%83%e6%a6%82%e8%bf%b0-pOORYrYvca\">LNMP \u74b0\u5883\u6982\u8ff0<\/h2>\n<p>LNMP \u662f Linux\u3001Nginx\u3001MySQL \u548c PHP \u7684\u7e2e\u5beb\u3002\u9019\u500b\u7d44\u5408\u63d0\u4f9b\u4e86\u4e00\u500b\u9ad8\u6548\u7684\u7db2\u9801\u4f3a\u670d\u5668\u74b0\u5883\uff0c\u9069\u5408\u904b\u884c\u5404\u7a2e Web \u61c9\u7528\u7a0b\u5e8f\u3002\u4ee5\u4e0b\u662f\u6bcf\u500b\u7d44\u4ef6\u7684\u7c21\u8981\u4ecb\u7d39\uff1a<\/p>\n<ul>\n<li><strong>Linux<\/strong>: \u4f5c\u70ba\u64cd\u4f5c\u7cfb\u7d71\uff0c\u63d0\u4f9b\u7a69\u5b9a\u7684\u57fa\u790e\u3002<\/li>\n<li><strong>Nginx<\/strong>: \u4e00\u500b\u9ad8\u6548\u7684 Web \u4f3a\u670d\u5668\uff0c\u80fd\u5920\u8655\u7406\u5927\u91cf\u7684\u4e26\u767c\u9023\u63a5\u3002<\/li>\n<li><strong>MySQL<\/strong>: \u4e00\u500b\u6d41\u884c\u7684\u95dc\u806f\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u7528\u65bc\u5b58\u5132\u61c9\u7528\u7a0b\u5e8f\u6578\u64da\u3002<\/li>\n<li><strong>PHP<\/strong>: \u4e00\u7a2e\u5ee3\u6cdb\u4f7f\u7528\u7684\u8173\u672c\u8a9e\u8a00\uff0c\u9069\u5408\u7528\u65bc Web \u958b\u767c\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%ae%89%e8%a3%9d%e6%ad%a5%e9%a9%9f-pOORYrYvca\">\u5b89\u88dd\u6b65\u9a5f<\/h2>\n<h3 id=\"1-%e6%9b%b4%e6%96%b0%e7%b3%bb%e7%b5%b1-pOORYrYvca\">1. \u66f4\u65b0\u7cfb\u7d71<\/h3>\n<pre><code>sudo yum update -y<\/code><\/pre>\n<h3 id=\"2-%e5%ae%89%e8%a3%9d-nginx-pOORYrYvca\">2. \u5b89\u88dd Nginx<\/h3>\n<pre><code>sudo yum install epel-release -y\nsudo yum install nginx -y\nsudo systemctl start nginx\nsudo systemctl enable nginx<\/code><\/pre>\n<h3 id=\"3-%e5%ae%89%e8%a3%9d-mysql-pOORYrYvca\">3. \u5b89\u88dd MySQL<\/h3>\n<pre><code>sudo yum install mariadb-server -y\nsudo systemctl start mariadb\nsudo systemctl enable mariadb<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u57f7\u884c\u5b89\u5168\u914d\u7f6e\u8173\u672c\u4ee5\u52a0\u5f37 MySQL \u7684\u5b89\u5168\u6027\uff1a<\/p>\n<pre><code>sudo mysql_secure_installation<\/code><\/pre>\n<h3 id=\"4-%e5%ae%89%e8%a3%9d-php-pOORYrYvca\">4. \u5b89\u88dd PHP<\/h3>\n<pre><code>sudo yum install php php-mysql php-fpm -y\nsudo systemctl start php-fpm\nsudo systemctl enable php-fpm<\/code><\/pre>\n<h3 id=\"5-%e9%85%8d%e7%bd%ae-nginx-%e6%94%af%e6%8c%81-php-pOORYrYvca\">5. \u914d\u7f6e Nginx \u652f\u6301 PHP<\/h3>\n<p>\u7de8\u8f2f Nginx \u914d\u7f6e\u6587\u4ef6\u4ee5\u652f\u6301 PHP\uff1a<\/p>\n<pre><code>sudo vi \/etc\/nginx\/conf.d\/default.conf<\/code><\/pre>\n<p>\u5728 server \u5340\u584a\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>location ~ .php$ {\n    include fastcgi_params;\n    fastcgi_pass 127.0.0.1:9000;\n    fastcgi_index index.php;\n    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n}<\/code><\/pre>\n<p>\u7136\u5f8c\u91cd\u555f Nginx\uff1a<\/p>\n<pre><code>sudo systemctl restart nginx<\/code><\/pre>\n<h3 id=\"6-%e5%ae%89%e8%a3%9d-zabbix-3-0-pOORYrYvca\">6. \u5b89\u88dd Zabbix 3.0<\/h3>\n<p>\u9996\u5148\uff0c\u6dfb\u52a0 Zabbix \u7684\u5b98\u65b9\u5b58\u5132\u5eab\uff1a<\/p>\n<pre><code>sudo rpm -Uvh https:\/\/repo.zabbix.com\/zabbix\/3.0\/rhel\/7\/x86_64\/zabbix-release-3.0-1.el7.centos.noarch.rpm<\/code><\/pre>\n<p>\u7136\u5f8c\u5b89\u88dd Zabbix \u4f3a\u670d\u5668\u3001\u524d\u7aef\u548c\u4ee3\u7406\uff1a<\/p>\n<pre><code>sudo yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y<\/code><\/pre>\n<h3 id=\"7-%e9%85%8d%e7%bd%ae-zabbix-%e6%95%b8%e6%93%9a%e5%ba%ab-pOORYrYvca\">7. \u914d\u7f6e Zabbix \u6578\u64da\u5eab<\/h3>\n<p>\u767b\u9304 MySQL \u4e26\u5275\u5efa Zabbix \u6578\u64da\u5eab\uff1a<\/p>\n<pre><code>mysql -u root -p\nCREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;\nGRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost' IDENTIFIED BY 'your_password';\nFLUSH PRIVILEGES;\nEXIT;<\/code><\/pre>\n<p>\u5c0e\u5165 Zabbix \u7684\u521d\u59cb\u6578\u64da\uff1a<\/p>\n<pre><code>zcat \/usr\/share\/doc\/zabbix-server-mysql-3.0*\/create\/schema.sql.gz | mysql -u zabbix -p zabbix\nzcat \/usr\/share\/doc\/zabbix-server-mysql-3.0*\/create\/images.sql.gz | mysql -u zabbix -p zabbix\nzcat \/usr\/share\/doc\/zabbix-server-mysql-3.0*\/create\/data.sql.gz | mysql -u zabbix -p zabbix<\/code><\/pre>\n<h3 id=\"8-%e9%85%8d%e7%bd%ae-zabbix-%e4%bc%ba%e6%9c%8d%e5%99%a8-pOORYrYvca\">8. \u914d\u7f6e Zabbix \u4f3a\u670d\u5668<\/h3>\n<p>\u7de8\u8f2f Zabbix \u4f3a\u670d\u5668\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/zabbix\/zabbix_server.conf<\/code><\/pre>\n<p>\u8a2d\u7f6e\u6578\u64da\u5eab\u5bc6\u78bc\uff1a<\/p>\n<pre><code>DBPassword=your_password<\/code><\/pre>\n<h3 id=\"9-%e5%95%9f%e5%8b%95-zabbix-%e6%9c%8d%e5%8b%99-pOORYrYvca\">9. \u555f\u52d5 Zabbix \u670d\u52d9<\/h3>\n<pre><code>sudo systemctl start zabbix-server\nsudo systemctl enable zabbix-server\nsudo systemctl start zabbix-agent\nsudo systemctl enable zabbix-agent<\/code><\/pre>\n<h3 id=\"10-%e9%85%8d%e7%bd%ae-zabbix-%e5%89%8d%e7%ab%af-pOORYrYvca\">10. \u914d\u7f6e Zabbix \u524d\u7aef<\/h3>\n<p>\u7de8\u8f2f Zabbix \u524d\u7aef\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/httpd\/conf.d\/zabbix.conf<\/code><\/pre>\n<p>\u8a2d\u7f6e\u6b63\u78ba\u7684\u6642\u5340\uff1a<\/p>\n<pre><code>php_value date.timezone Asia\/Hong_Kong<\/code><\/pre>\n<p>\u91cd\u555f Apache \u4f3a\u670d\u5668\uff1a<\/p>\n<pre><code>sudo systemctl restart httpd<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-pOORYrYvca\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u6211\u5011\u6210\u529f\u5728 CentOS 7 \u4e0a\u642d\u5efa\u4e86 LNMP \u74b0\u5883\u4e26\u5b89\u88dd\u4e86 Zabbix 3.0\u3002\u9019\u500b\u76e3\u63a7\u7cfb\u7d71\u80fd\u5920\u5e6b\u52a9\u7528\u6236\u5be6\u6642\u76e3\u63a7\u4f3a\u670d\u5668\u7684\u6027\u80fd\uff0c\u53ca\u6642\u767c\u73fe\u554f\u984c\u3002\u82e5\u60a8\u9700\u8981\u7a69\u5b9a\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\u4f86\u904b\u884c\u60a8\u7684 Zabbix \u76e3\u63a7\u7cfb\u7d71\uff0c\u8acb\u8003\u616e\u6211\u5011\u7684\u670d\u52d9\u3002\u7121\u8ad6\u662f <a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a> \u9084\u662f\u5176\u4ed6\u5730\u5340\u7684 <a href=\"https:\/\/server.hk\">\u4e91\u4f3a\u670d\u5668<\/a>\uff0c\u6211\u5011\u90fd\u80fd\u63d0\u4f9b\u9ad8\u6548\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to set up a CentOS 7 LNMP environment for Zabbix 3.0 with step-by-step instructions for monitoring and performance optimization.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-42716","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42716","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=42716"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42716\/revisions"}],"predecessor-version":[{"id":42717,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42716\/revisions\/42717"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=42716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=42716"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=42716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}