开启php-fpm服务
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm chkconfig --add php-fpm service php-fpm start安装扩展模块
cd .. pecl install smbclient pecl install imagick wget -O igbinary.zip https://github.com/igbinary/igbinary7/archive/master.zip unzip igbinary.zip cd igbinary7-master phpize ./configure CFLAGS="-O2 -g" --enable-igbinary make && make install pecl install apcu pecl install redis复制/usr/local/etc/php.ini到/usr/local/lib/
cp /usr/local/etc/php.ini /usr/local/lib/修改/usr/local/lib/php.ini,搜索’extension=’,在这段后面添加
extension=smbclient.so extension=imagick.so extension=igbinary.so extension=redis.so extension=apcu.so zend_extension=opcache.so继续修改php.ini,搜索“[opcache]”,将以下行注释去掉,并修改为对应的配置值
opcache.enable=1 opcache.enable_cli=1 opcache.memory_consumption=128 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=10000 opcache.revalidate_freq=1 opcache.save_comments=1继续修改php.ini,在最后面添加
[apc] apc.enabled=1 apc.shm_segments=1 apc.shm_size=64M apc.ttl=7200 apc.user_ttl=7200 apc.enable_cli=1 遇到的问题总结a、安装完扩展模块后,在/usr/local/etc/php.ini配置了,却发现一直无法加载成功,后来才发现我安装的php配置文件路径应该在/usr/local/lib,拷贝过去就对了
b、使用命令php -i可以查看php的相关信息,包括使用的配置文件路径、扩展模块路径等等
c、使用命令php -m可以查看成功加载了的模块,如果扩展模块安装成功了,就可以看到
d、php的扩展模块有两种安装方式,最简单的就是使用pecl,类似于yum,指定模块名称后就可以一键下载、编译、安装了,当然如果有依赖库的话必须先进行安装,再在php.ini里面加上extension配置项即可
e、php的扩展模块另外一种安装方式,就是下载模块的源代码,解压后进入源代码目录,执行phpize生成configure文件,然后就是执行configure、make、make install了,最后在php.ini增加配置项
五、安装Nextcloud下载解压到www目录
wget https://download.nextcloud.com/server/releases/nextcloud-12.0.2.zip unzip nextcloud-12.0.2.zip mv nextcloud /var/www/ chown -R nginx:nginx /var/www生成SSL证书
mkdir -p /etc/nginx/cert/ openssl req -new -x509 -days 365 -nodes -out /etc/nginx/cert/nextcloud.crt -keyout /etc/nginx/cert/nextcloud.key chmod 700 /etc/nginx/cert chmod 600 /etc/nginx/cert/*修改nginx服务配置文件/usr/local/nginx/conf/nginx.conf为以下内容,将“yourname.domain”替换为自己的域名,修改client_max_body_size可以设置最大可上传的文件大小
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; upstream php-handler { server 127.0.0.1:9000; #server unix:/var/run/php5-fpm.sock; } server { listen 80; server_name yourname.domain; # enforce https return 301 https://$server_name$request_uri; } server { listen 443 ssl http2; server_name yourname.domain; ssl_certificate /etc/nginx/cert/nextcloud.crt; ssl_certificate_key /etc/nginx/cert/nextcloud.key; # Add headers to serve security related headers # Before enabling Strict-Transport-Security headers please read into this # topic first. # add_header Strict-Transport-Security "max-age=15768000; # includeSubDomains; preload;"; # # WARNING: Only add the preload option once you read about # the consequences in https://hstspreload.org/. This option # will add the domain to a hardcoded list that is shipped # in all major browsers and getting removed from this list # could take several months. add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; add_header X-Robots-Tag none; add_header X-Download-Options noopen; add_header X-Permitted-Cross-Domain-Policies none; # Path to the root of your installation root /var/www/nextcloud/; location = /robots.txt { allow all; log_not_found off; access_log off; } # The following 2 rules are only needed for the user_webfinger app. # Uncomment it if you're planning to use this app. #rewrite ^/.well-known/host-meta /public.php?service=host-meta last; #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json # last; location = /.well-known/carddav { return 301 $scheme://$host/remote.php/dav; } location = /.well-known/caldav { return 301 $scheme://$host/remote.php/dav; } # set max upload size client_max_body_size 512M; fastcgi_buffers 64 4K; # Enable gzip but do not remove ETag headers gzip on; gzip_vary on; gzip_comp_level 4; gzip_min_length 256; gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; gzip_types application/atom+xml application/Javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy; # Uncomment if your server is build with the ngx_pagespeed module # This module is currently not supported. #pagespeed off; location / { rewrite ^ /index.php$uri; } location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ { deny all; } location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { deny all; } location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$|/) { fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param HTTPS on; #Avoid sending the security headers twice fastcgi_param modHeadersAvailable true; fastcgi_param front_controller_active true; fastcgi_pass php-handler; fastcgi_intercept_errors on; fastcgi_request_buffering off; } location ~ ^/(?:updater|ocs-provider)(?:$|/) { try_files $uri/ =404; index index.php; } # Adding the cache control header for js and css files # Make sure it is BELOW the PHP block location ~ \.(?:css|js|woff|svg|gif)$ { try_files $uri /index.php$uri$is_args$args; add_header Cache-Control "public, max-age=15778463"; # Add headers to serve security related headers (It is intended to # have those duplicated to the ones above) # Before enabling Strict-Transport-Security headers please read into # this topic first. # add_header Strict-Transport-Security "max-age=15768000; # includeSubDomains; preload;"; # # WARNING: Only add the preload option once you read about # the consequences in https://hstspreload.org/. This option # will add the domain to a hardcoded list that is shipped # in all major browsers and getting removed from this list # could take several months. add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; add_header X-Robots-Tag none; add_header X-Download-Options noopen; add_header X-Permitted-Cross-Domain-Policies none; # Optional: Don't log access to assets access_log off; } location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ { try_files $uri /index.php$uri$is_args$args; # Optional: Don't log access to other assets access_log off; } } }让Nginx重新载入配置
nginx -s reload