Полный список шагов настройки sed для разработчиков

Материал из Справочная информация по работе с СЭД
Версия от 13:07, 26 декабря 2018; Pylnev (обсуждение | вклад) (Pylnev переименовал страницу Полный список шагов в Полный список шагов настройки sed для разработчиков без оставления перенаправления)
Перейти к: навигация, поиск

1. sudo apt-get install apache2

2. sudo cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak

3. sudo nano /etc/apache2/apache2.conf

# The directory where shm and other runtime files will be stored.
DefaultRuntimeDir ${APACHE_RUN_DIR}

# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
PidFile ${APACHE_PID_FILE}

# Timeout: The number of seconds before receives and sends time out.
Timeout 300

# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
KeepAlive On

# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
MaxKeepAliveRequests 100

# KeepAliveTimeout: Number of seconds to wait for the next request from the same client on the same connection.
KeepAliveTimeout 5

# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

# HostnameLookups: Log the names of clients or just their IP addresses e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the nameserver.
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
ErrorLog ${APACHE_LOG_DIR}/error.log

# LogLevel: Control the severity of messages logged to the error_log.
# Available values: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the log level for particular modules, e.g.
# "LogLevel info ssl:warn"
LogLevel warn

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# Include list of ports to listen on
Include ports.conf

# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
AccessFileName .htaccess

# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
<FilesMatch "^\.ht">
        Require all denied
</FilesMatch>

#
# The following directives define some format nicknames for use with
# a CustomLog directive.
#
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
#
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.
# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

4. sudo systemctl restart apache2

5. sudo nano /etc/apache2/conf-available/security.conf

ServerTokens Prod
ServerSignature Off

6. sudo a2enmod rewrite

7. sudo systemctl restart apache2

8. sudo apt install php7.0 php-pear libapache2-mod-php7.0
(для Ubuntu18.04: sudo apt install php7.2 php-pear libapache2-mod-php7.2)

9. sudo apt-get install php7.0-curl php7.0-gd php7.0-ldap php7.0-pgsql php7.0-mbstring php7.0-zip php-apcu php-imagick php7.0-imap php7.0-intl php7.0-xmlrpc php7.0-soap php-xdebug
(для Ubuntu18.04: sudo apt-get install php7.2-curl php7.2-gd php7.2-ldap php7.2-pgsql php7.2-mbstring php7.2-zip php-apcu php-imagick php7.2-imap php7.2-intl php7.2-xmlrpc php7.2-soap php-xdebug)

10. sudo nano /etc/apache2/ports.conf

Listen 12080

11.1. sudo mkdir -p /var/www/sed

11.2. sudo nano /etc/apache2/sites-available/sed.conf

<VirtualHost *:12080>     
ServerName sed.local
ServerAdmin webmaster@localhost
DocumentRoot /var/www/sed

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

11.3

sudo ln -s /etc/apache2/sites-available/sed.conf /etc/apache2/sites-enabled/
sudo rm /etc/apache2/sites-enabled/000-default.conf	 

11.4 sudo nano /etc/hosts

127.0.0.1    sed.local

12. sudo apt-get install nginx

13. sudo service nginx restart

14. sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak

15. sudo nano /etc/nginx/nginx.conf

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;
        client_max_body_size 500m;
        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
		 ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # nginx-naxsi config
        ##
        # Uncomment it if you installed nginx-naxsi
        ##

        #include /etc/nginx/naxsi_core.rules;
		##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

16. sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak

17.1. sudo nano /etc/nginx/sites-available/sed

upstream php {
    server 127.0.0.1:12080;
}

server {
        listen 80 default_server;
        #listen [::]:80 default_server;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;
        proxy_connect_timeout       600;
        proxy_send_timeout          600;
        proxy_read_timeout          600;
        send_timeout                600;
		
		server_name sed.local;        
        root /var/www/sed;
                 # Add index.php to the list if you are using PHP
        index index.php index.html;
    
		location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules;
                add_header prc f;
        }

        location ^~ /svn/ {
            proxy_pass http://php;
        }

#       location ^~ /moodle/ {
#            proxy_pass http://php;
#        }

        location ~ \.php$ {
            proxy_pass http://php;
            add_header prc ppe;
        }
        location ~ \.php\.t$ {
            proxy_pass http://php;
            add_header prc pte;
        }
        location = / {
            proxy_pass http://php;
            add_header prc pi;
        }
		location ~ /[^/.]+$ {
            if ( -f $request_filename.php ) {
                    proxy_pass http://php;
            }
            if ( -f $request_filename.php.t ) {
                    proxy_pass http://php;
                    add_header prc pt;
            }
        }
        location ^~ /gen/ {
            proxy_pass http://php;
        }
                 location ^~ /file/ {
            proxy_pass http://php;
        }


        location ~ ^/(?:\.|cfg|az/cfg-sample) {
            deny all;
        }
		# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #       include snippets/fastcgi-php.conf;
        #
        #       # With php5-cgi alone:
        #       fastcgi_pass 127.0.0.1:9000;
        #       # With php5-fpm:
        #       fastcgi_pass unix:/var/run/php5-fpm.sock;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
}

17.2.

sudo ln -s /etc/nginx/sites-available/sed /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default 


18. sudo service nginx restart

19. sudo apt-get install libapache2-mod-rpaf

20. sudo apt-get install poppler-utils

21. sudo apt-get install netpbm

22.

sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -sc)-pgdg main"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.6


23.1 скачать sed из репозитория в /var/www/sed

23.2

  • скопировать с сервера файл /cabinet/config.php себе в проект в ту же директорию
  • скопировать с сервера папку /cfg-local себе в проект

23.3

sudo chown -R $USER:$USER /var/www/sed 
sudo chmod -R 755 /var/www/sed	

23.4

sudo chown -R www-data:www-data /var/www/sed/cache
sudo chown -R www-data:www-data /var/www/sed/storage
sudo chmod -R 777 /var/www/sed/cache
sudo chmod -R 777 /var/www/sed/storage

23.5. в файле /cfg/db.ini изменить пути

docfile_storage=/var/www/sed/storage/docfiles
storagedir = /var/www/sed/storage

24. Настройка БД и постгреса.

24.1 скопировать с сервера папку /usr/share/postgresql/9.6/tsearch_data себе на компьютер в ту же директорию

24.2. сменить дефолтный пароль постгреса:

а) sudo -u postgres psql postgres
б) \password postgres
в) Ввести пароль ЕДИНИЧКУ (1)
г) Повторить пароль
д) \q

24.3. Добавляем юзера 'www-data':

а) sudo -u postgres psql postgres
б) CREATE USER "www-data" WITH PASSWORD 'pass';
в) \q

24.4. Создаем БД:

а) sudo -u postgres psql postgres
б) CREATE DATABASE edfs OWNER "www-data";
в) \q


24.5. на сервере сделать бэкап БД:

pg_dump -h localhost -p 5432 -U postgres -F c -C -d edfs > ~/my-14-12-2018.edfs (14-12-2018 - дата бэкапа)

24.6. с сервера скопировать бэкап себе в /home/$USER

24.7. pg_restore -h localhost -p 5432 -U postgres -d edfs ~/my-14-12-2018.edfs

24.8. Сделаем pass единички:

а) sudo -u postgres psql postgres
б) \c edfs 
в) UPDATE public.users SET pass = 1;
г) \q

24.9.

sudo service apache2 restart
sudo service nginx restart
sudo service postgresql restart