{"id":45244,"date":"2024-10-06T21:30:21","date_gmt":"2024-10-06T13:30:21","guid":{"rendered":"https:\/\/server.hk\/cnblog\/45244\/"},"modified":"2024-10-06T21:30:21","modified_gmt":"2024-10-06T13:30:21","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-centos-7-%e4%b8%ad%e4%bd%bf%e7%94%a8-nginx-%e5%92%8c-php7-fpm-%e5%ae%89%e8%a3%9d-nextcloud","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/45244\/","title":{"rendered":"\u5982\u4f55\u5728 CentOS 7 \u4e2d\u4f7f\u7528 Nginx \u548c PHP7-FPM \u5b89\u88dd Nextcloud"},"content":{"rendered":"<h1 id=\"%e5%a6%82%e4%bd%95%e5%9c%a8-centos-7-%e4%b8%ad%e4%bd%bf%e7%94%a8-nginx-%e5%92%8c-php7-fpm-%e5%ae%89%e8%a3%9d-nextcloud-BgPeHjrUIn\">\u5982\u4f55\u5728 CentOS 7 \u4e2d\u4f7f\u7528 Nginx \u548c PHP7-FPM \u5b89\u88dd Nextcloud<\/h1>\n<p>Nextcloud \u662f\u4e00\u500b\u958b\u6e90\u7684\u96f2\u7aef\u5132\u5b58\u89e3\u6c7a\u65b9\u6848\uff0c\u5141\u8a31\u7528\u6236\u5728\u81ea\u5df1\u7684\u4f3a\u670d\u5668\u4e0a\u5efa\u7acb\u79c1\u6709\u96f2\u3002\u9019\u7bc7\u6587\u7ae0\u5c07\u6307\u5c0e\u60a8\u5982\u4f55\u5728 CentOS 7 \u4e0a\u4f7f\u7528 Nginx \u548c PHP7-FPM \u5b89\u88dd Nextcloud\u3002<\/p>\n<h2 id=\"%e5%89%8d%e7%bd%ae%e6%a2%9d%e4%bb%b6-BgPeHjrUIn\">\u524d\u7f6e\u689d\u4ef6<\/h2>\n<ul>\n<li>\u4e00\u53f0\u904b\u884c CentOS 7 \u7684\u4f3a\u670d\u5668\u3002<\/li>\n<li>\u64c1\u6709 root \u6b0a\u9650\u7684\u7528\u6236\u3002<\/li>\n<li>\u5df2\u5b89\u88dd Nginx \u548c PHP7-FPM\u3002<\/li>\n<li>\u5b89\u88dd MariaDB \u6216 MySQL \u4f5c\u70ba\u6578\u64da\u5eab\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%ae%89%e8%a3%9d-nginx-BgPeHjrUIn\">\u5b89\u88dd Nginx<\/h2>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5b89\u88dd Nginx\u3002\u5982\u679c\u5c1a\u672a\u5b89\u88dd\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo yum install epel-release\nsudo yum install nginx<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5 Nginx \u4e26\u8a2d\u7f6e\u70ba\u958b\u6a5f\u81ea\u555f\uff1a<\/p>\n<pre><code>sudo systemctl start nginx\nsudo systemctl enable nginx<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-php7-fpm-BgPeHjrUIn\">\u5b89\u88dd PHP7-FPM<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5b89\u88dd PHP7 \u548c PHP-FPM\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo yum install -y php php-fpm php-mysqlnd php-xml php-mbstring php-curl php-zip<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5 PHP-FPM \u4e26\u8a2d\u7f6e\u70ba\u958b\u6a5f\u81ea\u555f\uff1a<\/p>\n<pre><code>sudo systemctl start php-fpm\nsudo systemctl enable php-fpm<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-nginx-BgPeHjrUIn\">\u914d\u7f6e Nginx<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u914d\u7f6e Nginx \u4ee5\u652f\u6301 Nextcloud\u3002\u9996\u5148\uff0c\u5275\u5efa\u4e00\u500b\u65b0\u7684 Nginx \u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/nginx\/conf.d\/nextcloud.conf<\/code><\/pre>\n<p>\u5728\u8a72\u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\uff1a<\/p>\n<pre><code>server {\n    listen 80;\n    server_name your_domain.com;  # \u66ff\u63db\u70ba\u60a8\u7684\u57df\u540d\n\n    root \/var\/www\/nextcloud;  # Nextcloud \u7684\u5b89\u88dd\u76ee\u9304\n    index index.php index.html index.htm;\n\n    location \/ {\n        rewrite ^ \/index.php$request_uri;\n    }\n\n    location ~ ^\/index.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        include fastcgi_params;\n    }\n\n    location ~ .php$ {\n        return 404;\n    }\n\n    location ~ \/.ht {\n        deny all;\n    }\n}<\/code><\/pre>\n<p>\u4fdd\u5b58\u4e26\u9000\u51fa\u7de8\u8f2f\u5668\uff0c\u7136\u5f8c\u6aa2\u67e5 Nginx \u914d\u7f6e\u662f\u5426\u6b63\u78ba\uff1a<\/p>\n<pre><code>sudo nginx -t<\/code><\/pre>\n<p>\u5982\u679c\u6c92\u6709\u932f\u8aa4\uff0c\u91cd\u65b0\u555f\u52d5 Nginx\uff1a<\/p>\n<pre><code>sudo systemctl restart nginx<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-nextcloud-BgPeHjrUIn\">\u5b89\u88dd Nextcloud<\/h2>\n<p>\u73fe\u5728\uff0c\u60a8\u53ef\u4ee5\u4e0b\u8f09 Nextcloud\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4e0b\u8f09\u6700\u65b0\u7248\u672c\uff1a<\/p>\n<pre><code>wget https:\/\/download.nextcloud.com\/server\/releases\/nextcloud-XX.X.X.zip<\/code><\/pre>\n<p>\u89e3\u58d3\u7e2e\u4e0b\u8f09\u7684\u6587\u4ef6\u4e26\u79fb\u52d5\u5230 Nginx \u7684\u6839\u76ee\u9304\uff1a<\/p>\n<pre><code>unzip nextcloud-XX.X.X.zip\nsudo mv nextcloud \/var\/www\/<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u8a2d\u7f6e\u76ee\u9304\u6b0a\u9650\uff1a<\/p>\n<pre><code>sudo chown -R nginx:nginx \/var\/www\/nextcloud\nsudo chmod -R 755 \/var\/www\/nextcloud<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae%e6%95%b8%e6%93%9a%e5%ba%ab-BgPeHjrUIn\">\u914d\u7f6e\u6578\u64da\u5eab<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u70ba Nextcloud \u5275\u5efa\u4e00\u500b\u6578\u64da\u5eab\u3002\u767b\u9304\u5230 MariaDB \u6216 MySQL\uff1a<\/p>\n<pre><code>mysql -u root -p<\/code><\/pre>\n<p>\u7136\u5f8c\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\u4f86\u5275\u5efa\u6578\u64da\u5eab\u548c\u7528\u6236\uff1a<\/p>\n<pre><code>CREATE DATABASE nextcloud;\nCREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'your_password';\nGRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost';\nFLUSH PRIVILEGES;\nEXIT;<\/code><\/pre>\n<h2 id=\"%e5%ae%8c%e6%88%90%e5%ae%89%e8%a3%9d-BgPeHjrUIn\">\u5b8c\u6210\u5b89\u88dd<\/h2>\n<p>\u73fe\u5728\uff0c\u60a8\u53ef\u4ee5\u901a\u904e\u700f\u89bd\u5668\u8a2a\u554f Nextcloud \u7684\u5b89\u88dd\u754c\u9762\u3002\u6253\u958b\u700f\u89bd\u5668\u4e26\u8f38\u5165\u60a8\u7684\u57df\u540d\uff1a<\/p>\n<pre><code>http:\/\/your_domain.com<\/code><\/pre>\n<p>\u6309\u7167\u5c4f\u5e55\u4e0a\u7684\u6307\u793a\u5b8c\u6210\u5b89\u88dd\uff0c\u8f38\u5165\u6578\u64da\u5eab\u4fe1\u606f\u548c\u7ba1\u7406\u54e1\u5e33\u6236\u4fe1\u606f\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-BgPeHjrUIn\">\u7e3d\u7d50<\/h2>\n<p>\u5728\u9019\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5011\u4ecb\u7d39\u4e86\u5982\u4f55\u5728 CentOS 7 \u4e2d\u4f7f\u7528 Nginx \u548c PHP7-FPM \u5b89\u88dd Nextcloud\u3002\u9019\u500b\u904e\u7a0b\u6d89\u53ca\u5230\u5b89\u88dd\u5fc5\u8981\u7684\u8edf\u4ef6\u3001\u914d\u7f6e Nginx\u3001\u8a2d\u7f6e\u6578\u64da\u5eab\u4ee5\u53ca\u5b8c\u6210 Nextcloud \u7684\u5b89\u88dd\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u53ef\u4ee5\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u4f86\u904b\u884c\u60a8\u7684 Nextcloud\uff0c\u9019\u6a23\u53ef\u4ee5\u78ba\u4fdd\u66f4\u597d\u7684\u6027\u80fd\u548c\u7a69\u5b9a\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u5728 CentOS 7 \u4e0a\u5b89\u88dd Nextcloud\uff0c\u4f7f\u7528 Nginx \u548c PHP7-FPM\uff0c\u8f15\u9b06\u642d\u5efa\u96f2\u7aef\u5132\u5b58\u89e3\u6c7a\u65b9\u6848\u3002<\/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-45244","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45244","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=45244"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45244\/revisions"}],"predecessor-version":[{"id":45245,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45244\/revisions\/45245"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=45244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=45244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=45244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}