Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.04 KB | None | 0 0
  1. pkg install nano
  2.  
  3. -------
  4.  
  5. pkg install nginx
  6. echo 'nginx_enable="YES"' >> /etc/rc.conf
  7. service nginx start
  8.  
  9. mkdir -p /var/nginx/{client_body_temp,proxy_temp} && chown -R www:www /var/nginx/
  10. mkdir /usr/local/etc/nginx/conf.d
  11.  
  12. nano /usr/local/etc/nginx/nginx.conf
  13. load_module /usr/local/libexec/nginx/ngx_mail_module.so;
  14. load_module /usr/local/libexec/nginx/ngx_stream_module.so;
  15.  
  16. user www;
  17. worker_processes auto;
  18.  
  19. pid /var/run/nginx.pid;
  20.  
  21. events {
  22. use kqueue;
  23. worker_connections 1024;
  24. multi_accept on;
  25. }
  26. http {
  27.  
  28. # Basic settings
  29. # ----------
  30.  
  31. sendfile on;
  32. tcp_nopush on;
  33. tcp_nodelay on;
  34. reset_timedout_connection on;
  35. keepalive_timeout 65;
  36. keepalive_requests 1000;
  37. types_hash_max_size 2048;
  38. server_tokens off;
  39. send_timeout 30;
  40. server_names_hash_max_size 4096;
  41.  
  42. # Common limits
  43. # ----------
  44.  
  45. client_max_body_size 100m; # upload size
  46. client_body_buffer_size 1m;
  47. client_header_timeout 3m;
  48. client_body_timeout 3m;
  49.  
  50. client_body_temp_path /var/nginx/client_body_temp;
  51.  
  52. proxy_connect_timeout 5;
  53. proxy_send_timeout 10;
  54. proxy_read_timeout 10;
  55.  
  56. proxy_buffer_size 4k;
  57. proxy_buffers 8 16k;
  58. proxy_busy_buffers_size 64k;
  59. proxy_temp_file_write_size 64k;
  60.  
  61. proxy_temp_path /var/nginx/proxy_temp;
  62.  
  63. include mime.types;
  64. default_type application/octet-stream;
  65.  
  66. # Logs format
  67. # ----------
  68.  
  69. log_format main '$remote_addr - $host [$time_local] "$request" '
  70. '$status $body_bytes_sent "$http_referer" '
  71. '"$http_user_agent" "$http_x_forwarded_for"'
  72. 'rt=$request_time ut=$upstream_response_time '
  73. 'cs=$upstream_cache_status';
  74.  
  75. log_format cache '$remote_addr - $host [$time_local] "$request" $status '
  76. '$body_bytes_sent "$http_referer" '
  77. 'rt=$request_time ut=$upstream_response_time '
  78. 'cs=$upstream_cache_status';
  79.  
  80. access_log /var/log/nginx/access.log main;
  81. error_log /var/log/nginx/error.log warn;
  82.  
  83. # GZip config
  84. # ----------
  85.  
  86. gzip on;
  87. gzip_static on;
  88. gzip_types text/plain text/css text/javascript text/xml application/x-javascript application/javascript application/xml application/json image/x-icon;
  89. gzip_comp_level 9;
  90. gzip_buffers 16 8k;
  91. gzip_proxied expired no-cache no-store private auth;
  92. gzip_min_length 1000;
  93. gzip_disable "msie6"
  94. gzip_vary on;
  95.  
  96. # Cache config
  97. # ----------
  98.  
  99. proxy_cache_valid 1m;
  100.  
  101. # Virtual host config
  102. # ----------
  103.  
  104. include /usr/local/etc/nginx/conf.d/*.conf;
  105. }
  106.  
  107. -------
  108.  
  109. nano /usr/local/etc/nginx/conf.d/nextcloud.conf
  110. server {
  111. listen 80;
  112. charset utf-8;
  113.  
  114. server_name _;
  115.  
  116. access_log /var/log/nginx/nextcloud.access.log;
  117. error_log /var/log/nginx/nextcloud.error.log;
  118.  
  119. # add_header Strict-Transport-Security 'max-age=631138519; includeSubDomains; preload' always;
  120. # add_header X-Content-Type-Options nosniff;
  121. # add_header X-Frame-Options SAMEORIGIN;
  122. # add_header X-XSS-Protection '1; mode=block';
  123. # add_header X-Robots-Tag none;
  124. # add_header X-Download-Options noopen;
  125. # add_header X-Permitted-Cross-Domain-Policies none;
  126. # add_header X-Content-Security-Policy "allow 'self';";
  127. # add_header X-WebKit-CSP "allow 'self';";
  128.  
  129. root /usr/local/www/;
  130.  
  131. location = /robots.txt {
  132. deny all;
  133. }
  134.  
  135. location / {
  136. deny all;
  137. return 404;
  138. }
  139.  
  140. location ^~ /cloud {
  141.  
  142. client_max_body_size 10G;
  143. fastcgi_buffers 64 4K;
  144.  
  145. gzip off;
  146.  
  147. error_page 403 /cloud/core/templates/403.php;
  148. error_page 404 /cloud/core/templates/404.php;
  149.  
  150. location ~ ^/cloud/(data|config|.ht|db_structure.xml|README) {
  151. deny all;
  152. }
  153.  
  154. location ~* /cloud/remote/(?:.*)$ {
  155. rewrite ^ /cloud/remote.php last;
  156. }
  157.  
  158. # logo
  159. location ~* /cloud/core/(?:js/oc.js|preview.png).*$ {
  160. rewrite ^ /cloud/index.php last;
  161. }
  162.  
  163. # WEB download files
  164. location ~* /cloud/apps/(?:files/ajax/upload.php).*$ {
  165. rewrite ^ /cloud/index.php last;
  166. }
  167.  
  168. # Theme Nextcloud
  169. location ~* /cloud/apps/(?:theming/styles.css).*$ {
  170. rewrite ^ /cloud/index.php last;
  171. }
  172.  
  173. location /cloud {
  174. rewrite ^/cloud/caldav(.*)$ /cloud/remote.php/caldav$1 redirect;
  175. rewrite ^/cloud/carddav(.*)$ /cloud/remote.php/carddav$1 redirect;
  176. rewrite ^/cloud/webdav(.*)$ /cloud/remote.php/webdav$1 redirect;
  177.  
  178. rewrite ^(/cloud/core/doc/[^/]+/)$ $1/index.html;
  179.  
  180. if ($uri !~* (?:.(?:css|js|svg|gif|png|html|ttf|woff)$|^/cloud/(?:remote|public|cron|status|ocs/v1|ocs/v2).php)){
  181. rewrite ^ /cloud/index.php last;
  182. }
  183. }
  184.  
  185. location ~* ^(?!/cloud/remote.php)(?:.*).(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf|html|svg|ttf|woff)$ {
  186. expires 30d;
  187. access_log off;
  188. }
  189.  
  190. location ~ .php(?:$|/) {
  191. include fastcgi_params;
  192. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  193. fastcgi_param PATH_INFO $fastcgi_path_info;
  194. fastcgi_pass unix:/var/run/php-fpm.sock;
  195. fastcgi_param HTTPS off;
  196. fastcgi_param modHeadersAvailable true;
  197. fastcgi_param front_controller_active true;
  198. fastcgi_intercept_errors on;
  199. fastcgi_request_buffering off;
  200. }
  201. }
  202. }
  203.  
  204. -------
  205.  
  206. pkg install mariadb101-{server,client}
  207. echo 'mysql_enable="YES"' >> /etc/rc.conf
  208.  
  209. ls -l /usr/local/share/mysql/my*.cnf
  210. cp /usr/local/share/mysql/my-small.cnf /usr/local/etc/my.cnf
  211.  
  212. sed -i "" "s/max_allowed_packet = .*/max_allowed_packet = 32M/" /usr/local/etc/my.cnf
  213.  
  214. service mysql-server start && /usr/local/bin/mysql_secure_installation // all yes
  215.  
  216. mysql -u root -p // 12345678
  217. CREATE DATABASE nextcloud CHARACTER SET utf8;
  218. CREATE USER cloud@localhost IDENTIFIED BY '12345678';
  219. GRANT ALL PRIVILEGES ON nextcloud.* TO cloud@localhost;
  220. FLUSH PRIVILEGES;
  221. QUIT;
  222.  
  223. service mysql-server restart
  224.  
  225. -------
  226.  
  227. cd /usr/local/www
  228. pkg install ca_root_nss && fetch https://download.nextcloud.com/server/releases/nextcloud-10.0.1.zip
  229. unzip nextcloud-10.0.1.zip
  230. mv /usr/local/www/nextcloud/ /usr/local/www/cloud/
  231. rm -f nextcloud-10.0.1.zip
  232.  
  233. mkdir /usr/local/www/cloud/data && chown -R www:www /usr/local/www/
  234.  
  235. -------
  236.  
  237. pkg install redis
  238. echo 'redis_enable="YES"' >> /etc/rc.conf
  239.  
  240. sed -i "" "s/port 6379/port 0/" /usr/local/etc/redis.conf
  241. sed -i "" "s/# unixsocket /tmp/redis.sock/unixsocket /tmp/redis.sock/" /usr/local/etc/redis.conf
  242. sed -i "" "s/# unixsocketperm 700/unixsocketperm 777/" /usr/local/etc/redis.conf
  243.  
  244. service redis start
  245. redis-cli -s /tmp/redis.sock // проверка работы сокета
  246.  
  247. -------
  248.  
  249. pkg search php70
  250. pkg install php70 mod_php70 php70-pdo_mysql php70-mysqli php70-redis php70-gd php70-curl php70-json php70-zip php70-dom php70-xmlwriter php70-xmlreader php70-xml php70-mbstring php70-ctype php70-zlib php70-simplexml php70-hash php70-fileinfo php70-posix php70-iconv php70-filter php70-openssl
  251. echo 'php_fpm_enable="YES"' >> /etc/rc.conf
  252.  
  253. cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini && rehash
  254.  
  255. sed -i "" "s/memory_limit = .*/memory_limit = 512M/" /usr/local/etc/php.ini
  256. sed -i "" "s/;date.timezone.*/date.timezone = UTC/" /usr/local/etc/php.ini
  257. sed -i "" "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /usr/local/etc/php.ini
  258. sed -i "" "s/upload_max_filesize = .*/upload_max_filesize = 10240M/" /usr/local/etc/php.ini
  259. sed -i "" "s/post_max_size = .*/post_max_size = 10240M/" /usr/local/etc/php.ini
  260.  
  261. sed -i "" "s/listen = .*/listen = /var/run/php-fpm.sock/" /usr/local/etc/php-fpm.d/www.conf
  262. sed -i "" "s/;listen.owner = www/listen.owner = www/" /usr/local/etc/php-fpm.d/www.conf
  263. sed -i "" "s/;listen.group = www/listen.group = www/" /usr/local/etc/php-fpm.d/www.conf
  264. sed -i "" "s/;listen.mode = 0660/listen.mode = 0660/" /usr/local/etc/php-fpm.d/www.conf
  265.  
  266. nano /usr/local/etc/php-fpm.d/www.conf // uncomment
  267. env[HOSTNAME] = $HOSTNAME
  268. env[PATH] = /usr/local/bin:/usr/bin:/bin
  269. env[TMP] = /tmp
  270. env[TMPDIR] = /tmp
  271. env[TEMP] = /tmp
  272.  
  273. php-fpm -t
  274. service php-fpm start
  275.  
  276. -------
  277.  
  278. nano /usr/local/www/cloud/config/config.php
  279. <?php
  280. $CONFIG = array(
  281. 'trusted_domains' => array (
  282. 0 => '192.168.1.*',
  283. ),
  284. 'datadirectory' => '/usr/local/www/cloud/data',
  285. 'dbtype' => 'mysql',
  286. 'defaultapp' => 'files',
  287. 'knowledgebaseenabled' => false,
  288. 'enable_avatars' => false,
  289. 'allow_user_to_change_display_name' => true,
  290. 'remember_login_cookie_lifetime' => 60*60*24*15,
  291. 'session_lifetime' => 60 * 60 * 24,
  292. 'session_keepalive' => true,
  293. 'token_auth_enforced' => false,
  294. 'auth.bruteforce.protection.enabled' => true,
  295. 'trashbin_retention_obligation' => 'auto, 30',
  296. 'versions_retention_obligation' => 'auto',
  297. 'updatechecker' => false,
  298. 'check_for_working_webdav' => true,
  299. 'check_for_working_htaccess' => false,
  300. 'config_is_read_only' => false,
  301. 'memcache.local' => 'OCMemcacheRedis',
  302. 'memcache.locking' => 'OCMemcacheRedis',
  303. 'memcache.distributed' => 'OCMemcacheRedis',
  304. 'redis' => array(
  305. 'host' => '/tmp/redis.sock',
  306. 'port' => 0,
  307. 'timeout' => 0.0,
  308. ),
  309. );
  310.  
  311. nano /usr/local/etc/php/ext-30-pdo_mysql.ini
  312. [mysql]
  313. mysql.allow_local_infile=On
  314. mysql.allow_persistent=On
  315. mysql.cache_size=2000
  316. mysql.max_persistent=-1
  317. mysql.max_links=-1
  318. mysql.default_port=
  319. mysql.default_socket=/tmp/mysql.sock
  320. mysql.default_host=
  321. mysql.default_user=
  322. mysql.default_password=
  323. mysql.connect_timeout=60
  324. mysql.trace_mode=Off
  325.  
  326. -------
  327.  
  328. service nginx restart && service php-fpm restart
  329.  
  330. http://192.168.1.*/cloud
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement