إعداد وتشغيل خادم نقل الملفات في نظام التشغيل أوبونتو 18.04 باستخدام VSFTPD

  • لتثبيت مكونات خادم نقل الملفات VSFTPD على نظام التشغيل أوبونتو
$ sudo apt-get install vsftpd
  • تعديل ملف التهيئة vsftpd.config

أولا سننقل ملف التهيئة كنسخة إحتياطية قبل التعديل

$ sudo mv /etc/vsftpd.conf /etc/vsftpd.conf_bkup

ثم نقوم بإنشاء ملف تهيئة جديد بنفس اﻹسم اﻷصل

$ sudo nano /etc/vsftpd.conf

سنقوم بكتابة هذه اﻹعدادات اﻷساسية في ملف تهيئة الخادم أولا وبعد أن نتأكد من عمله نقوم بتعديلها لتتناسب مع بيئة التشغيل الخاصة بنا.

listen=NO
listen_ipv6=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=NO
pasv_enable=Yes
pasv_min_port=50000
pasv_max_port=51000
allow_writeable_chroot=YES

إعدادات أخري يمكن استخدامها

    anonymous_enable=NO
    local_enable=YES
    write_enable=YES
    local_umask=022
    dirmessage_enable=YES
    xferlog_enable=YES
    connect_from_port_20=NO
    xferlog_file=/var/log/vsftpd/vsftpd.log
    xferlog_std_format=YES
    ftpd_banner=Welcome to FTP service
    chroot_local_user=YES
    listen=YES
    pam_service_name=vsftpd
    tcp_wrappers=YES
    userlist_file=/etc/vsftpd/vsftpd.userlist
    userlist_enable=YES
    userlist_deny=NO
    pasv_max_port=51000
    pasv_min_port=50000
    port_enable=YES
    pasv_enable=YES
    pasv_address=YOUR_SERVER_URL
    pasv_addr_resolve=YES
    check_shell=NO
    passwd_chroot_enable=YES

كما تري في اﻹعدادات السابقة:

  • منع اﻹتصال بالخادم بدون كلمة سر anonymous_enable=NO
  • إنشاء سجل تقارير مخصص /var/log/vsftpd/vsftpd.log
  • تفعيل سجل التقارير الخاص xferlog_std_format=YES
  • إضافة رسالة الترحيب الخاصة بنا ftpd_banner=Welcome to FTP service
  • تفعيل اﻹتصال للمستخدمين المسجلين في نظام التشغيل userlist_enable=YES
  • تحديد قائمة المستخدمين غير المسجلين في نظام التشغيل userlist_file=/etc/vsftpd/vsftpd.userlist
  • تفعيل قائمة المستخدمين غير المسجلين userlist_enable=YES
  • تفعيل قائمة المستخدمين كقائمة موثوق بها userlist_deny=NO
  • تمكين مستخدم نظام نقل الملفات FTP من الكتابة write_enable=YES
  • إعداد اﻹختار العام umask إلى 022 لتعديل صلاحية الوصول للملفات إلى (644) والمجلدات إلى (755) بشكل تلقائي عند رفعها للسيرفر. local_umask=022
  • تحديد المنافذ رقم 50000-51000 لنقل الملفات في الوضع Passive Mode pasv_max_port=51000 pasv_min_port=50000 (اﻷرقام للمثال فقط , استخدم أرقام أخري خاصة بك لمزيد من اﻷمان)
  • تحديد معرف اﻹنترنت IP أو اسم النظاق DomainName لسيرفر نقل الملفات للإتصال به YOUR_SERVER_URL
  • في حالة استخدام اسم النطاق DomainName يتم تعديل اﻹختيار pasv_addr_resolve=YES
  • في حالة استخدام IP يمكن تعديل الإختيار pasv_addr_resolve=NO

إذا كان جدار الحماية UFW مفعلا على الخادم فينبغي تنفيذ اﻷمر التالي لفتح منافذ اتصال FTP لخادم نقل الملفات.

$ sudo ufw allow from any to any port 20,21,50000:5100 proto tcp

اﻵن نقوم بإنشاء مجلد ومستخدم جديد باسم ftp_user لخدمة نقل الملفات FTP وتخصيص المجلد للمستخدم الجديد كمجلد شخصي رئيسي له

$ sudo mkdir -p /var/log/vsftpd/
$ sudo mkdir -p /var/www/ftp
$ sudo useradd -d /var/www/ftp/ -s /sbin/nologin ftp_user
$ sudo passwd ftp_pass
Enter new UNIX password:                                                                                                                                                                       
Retype new UNIX password:                                                                                                                                                                      
passwd: password updated successfully

ثم نقوم بتسجيل المستخدم الجديد في قائمة المستخدمين الموثوق بهم وإنشاء مجموعة جديدة باسم ftpgroup لمستخدمي خادم نقل الملفات FTP وإلحاق المستخدم ftp_user بها

$ sudo echo "ftp_user" > /etc/vsftpd/vsftpd.userlist
$ sudo groupadd ftpusers
$ sudo usermod -G ftpusers ftp_user
$ sudo chown ftp_user /var/www/ftp/ -R

أعد تشغيل خادم نقل الملفات لتطبيق اﻷعدادات السابقة

$ sudo service vsftpd restart

سنقوم بتسجيل الدخول لنظام التشغيل باسم المستخدم الجديد وإضافة ملف لمجلد المستخدم الجديد الشخصيﻹختبار إمكانية الكتابة والقراءة منه باستخدام اﻷمر التالي

$ sudo bash -c "echo FTP TESTING > /home/ftpuser/FTP-TEST"

اﻵن خادم نقل الملفات جاهز للإتصال به من قبل المستخدم ftp_user كما يلي:

$ ftp Server IP/DomainName
Name : 
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

إذا كنت ترغب في اﻹتصال بالخادم عن طريق اﻹنترنت فينبغي إضافة الإعدادات الخاصة بالتأمين إلى ملف التهيئة vsftpd.conf

Odoo Configuration

odoo --help
Running as user 'root' is a security risk.
Usage: odoo [options]

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit

  Common options:
    -c CONFIG, --config=CONFIG
                        specify alternate config file
    -s, --save          save configuration to ~/.odoorc (or to
                        ~/.openerp_serverrc if it exists)
    -i INIT, --init=INIT
                        install one or more modules (comma-separated list, use
                        "all" for all modules), requires -d
    -u UPDATE, --update=UPDATE
                        update one or more modules (comma-separated list, use
                        "all" for all modules). Requires -d.
    --without-demo=WITHOUT_DEMO
                        disable loading demo data for modules to be installed
                        (comma-separated, use "all" for all modules). Requires
                        -d and -i. Default is none
    -P IMPORT_PARTIAL, --import-partial=IMPORT_PARTIAL
                        Use this for big data importation, if it crashes you
                        will be able to continue at the current state. Provide
                        a filename to store intermediate importation states.
    --pidfile=PIDFILE   file where the server pid will be stored
    --addons-path=ADDONS_PATH
                        specify additional addons paths (separated by commas).
    --load=SERVER_WIDE_MODULES
                        Comma-separated list of server-wide modules.
    -D DATA_DIR, --data-dir=DATA_DIR
                        Directory where to store Odoo data

  HTTP Service Configuration:
    --http-interface=HTTP_INTERFACE
                        Listen interface address for HTTP services. Keep empty
                        to listen on all interfaces (0.0.0.0)
    -p PORT, --http-port=PORT
                        Listen port for the main HTTP service
    --longpolling-port=PORT
                        Listen port for the longpolling HTTP service
    --no-http           Disable the HTTP and Longpolling services entirely
    --proxy-mode        Activate reverse proxy WSGI wrappers (headers
                        rewriting) Only enable this when running behind a
                        trusted web proxy!

  Web interface Configuration:
    --db-filter=REGEXP  Regular expressions for filtering available databases
                        for Web UI. The expression can use %d (domain) and %h
                        (host) placeholders.

  Testing Configuration:
    --test-file=TEST_FILE
                        Launch a python test file.
    --test-enable       Enable unit tests.
    --test-tags=TEST_TAGS
                        Comma separated list of tags to filter which tests to
                        excute. Enable unit tests if set.

  Logging Configuration:
    --logfile=LOGFILE   file where the server log will be stored
    --logrotate         enable logfile rotation
    --syslog            Send the log to the syslog server
    --log-handler=PREFIX:LEVEL
                        setup a handler at LEVEL for a given PREFIX. An empty
                        PREFIX indicates the root logger. This option can be
                        repeated. Example: "odoo.orm:DEBUG" or
                        "werkzeug:CRITICAL" (default: ":INFO")
    --log-request       shortcut for --log-handler=odoo.http.rpc.request:DEBUG
    --log-response      shortcut for --log-
                        handler=odoo.http.rpc.response:DEBUG
    --log-web           shortcut for --log-handler=odoo.http:DEBUG
    --log-sql           shortcut for --log-handler=odoo.sql_db:DEBUG
    --log-db=LOG_DB     Logging database
    --log-db-level=LOG_DB_LEVEL
                        Logging database level
    --log-level=LOG_LEVEL
                        specify the level of the logging. Accepted values:
                        ['info', 'debug_rpc', 'warn', 'test', 'critical',
                        'debug_sql', 'error', 'debug', 'debug_rpc_answer',
                        'notset'].

  SMTP Configuration:
    --email-from=EMAIL_FROM
                        specify the SMTP email address for sending email
    --smtp=SMTP_SERVER  specify the SMTP server for sending email
    --smtp-port=SMTP_PORT
                        specify the SMTP port
    --smtp-ssl          if passed, SMTP connections will be encrypted with SSL
                        (STARTTLS)
    --smtp-user=SMTP_USER
                        specify the SMTP username for sending email
    --smtp-password=SMTP_PASSWORD
                        specify the SMTP password for sending email

  Database related options:
    -d DB_NAME, --database=DB_NAME
                        specify the database name
    -r DB_USER, --db_user=DB_USER
                        specify the database user name
    -w DB_PASSWORD, --db_password=DB_PASSWORD
                        specify the database password
    --pg_path=PG_PATH   specify the pg executable path
    --db_host=DB_HOST   specify the database host
    --db_port=DB_PORT   specify the database port
    --db_sslmode=DB_SSLMODE
                        specify the database ssl connection mode (see
                        PostgreSQL documentation)
    --db_maxconn=DB_MAXCONN
                        specify the maximum number of physical connections to
                        PostgreSQL
    --db-template=DB_TEMPLATE
                        specify a custom database template to create a new
                        database

  Internationalisation options. :
    Use these options to translate Odoo to another language. See i18n
    section of the user manual. Option '-d' is mandatory. Option '-l' is
    mandatory in case of importation

    --load-language=LOAD_LANGUAGE
                        specifies the languages for the translations you want
                        to be loaded
    -l LANGUAGE, --language=LANGUAGE
                        specify the language of the translation file. Use it
                        with --i18n-export or --i18n-import
    --i18n-export=TRANSLATE_OUT
                        export all sentences to be translated to a CSV file, a
                        PO file or a TGZ archive and exit
    --i18n-import=TRANSLATE_IN
                        import a CSV or a PO file with translations and exit.
                        The '-l' option is required.
    --i18n-overwrite    overwrites existing translation terms on updating a
                        module or importing a CSV or a PO file.
    --modules=TRANSLATE_MODULES
                        specify modules to export. Use in combination with
                        --i18n-export

  Security-related options:
    --no-database-list  Disable the ability to obtain or view the list of
                        databases. Also disable access to the database manager
                        and selector, so be sure to set a proper --database
                        parameter first

  Advanced options:
    --dev=DEV_MODE      Enable developer mode. Param: List of options
                        separated by comma. Options : all,
                        [pudb|wdb|ipdb|pdb], reload, qweb, werkzeug, xml
    --shell-interface=SHELL_INTERFACE
                        Specify a preferred REPL to use in shell mode.
                        Supported REPLs are: [ipython|ptpython|bpython|python]
    --stop-after-init   stop the server after its initialization
    --osv-memory-count-limit=OSV_MEMORY_COUNT_LIMIT
                        Force a limit on the maximum number of records kept in
                        the virtual osv_memory tables. The default is False,
                        which means no count-based limit.
    --osv-memory-age-limit=OSV_MEMORY_AGE_LIMIT
                        Force a limit on the maximum age of records kept in
                        the virtual osv_memory tables. This is a decimal value
                        expressed in hours, and the default is 1 hour.
    --max-cron-threads=MAX_CRON_THREADS
                        Maximum number of threads processing concurrently cron
                        jobs (default 2).
    --unaccent          Use the unaccent function provided by the database
                        when available.
    --geoip-db=GEOIP_DATABASE
                        Absolute path to the GeoIP database file.

  Multiprocessing options:
    --workers=WORKERS   Specify the number of workers, 0 disable prefork mode.
    --limit-memory-soft=LIMIT_MEMORY_SOFT
                        Maximum allowed virtual memory per worker, when
                        reached the worker be reset after the current request
                        (default 2048MiB).
    --limit-memory-hard=LIMIT_MEMORY_HARD
                        Maximum allowed virtual memory per worker, when
                        reached, any memory allocation will fail (default
                        2560MiB).
    --limit-time-cpu=LIMIT_TIME_CPU
                        Maximum allowed CPU time per request (default 60).
    --limit-time-real=LIMIT_TIME_REAL
                        Maximum allowed Real time per request (default 120).
    --limit-time-real-cron=LIMIT_TIME_REAL_CRON
                        Maximum allowed Real time per cron job. (default:
                        --limit-time-real). Set to 0 for no limit.
    --limit-request=LIMIT_REQUEST
                        Maximum number of request to be processed per worker
                        (default 8192).

تهيئة خادم مواقع اﻹنترنت

اﻷدوات المطلوبة ﻹعداد خادم مواقع اﻹنترنت:

  • جهاز خادم:
    • افتراضي VPS – Virtual Private Server
    • حقيقي Dedicated Server
  • نظام التشغيل OS – Operating System
    • Debian – Ubuntu
    • Cantos
  • نظام خادم الويب Web Server
    • Apache
    • Nginx
  • نظام خادم قواعد البيانات Database Server
    • MySQL
    • MariaDB
    • PostgreSQL
    • SQLite
  • نظام مفسر للغات البرمجة Interpretter
    • Python
    • PHP
  • نظام إدارة المحتوى
    • WordPress
    • Joomla