Install and configure VPS with CentOS 6.x a couple of commands with VestaCP

    Greetings, Habr!

    For my product, I made an installer on a clean VPS with CentOS 6.x and 512MB + RAM. This is such a VPS, which can be purchased from DigitalOcean.com for $ 5 per month. But the installer turned out to be quite universal, and it can be forked from the github to exclude components you do not need. VestaCP

    was chosen as the control panel , which I had not heard of before, since I have been using cPanel / WHM blindly for several years, recently with CloudLinux. But this is a paid panel, and CloudLinux is also paid, and the last thing is to ask users to pay for something else, except for the product. Acquainted with VestaCP



    I really liked it, although it still needs to be further developed. For example, there is no documentation on the v- * console commands, and you have to determine by typing what kind of data you need to submit to the input. Sometimes this is not obvious from the synopsis of using a command if you invoke it without parameters.

    So, let's imagine that we have a clean VPS, from DigitalOcean , FirstVDS or Linode . About FirstVDS I want to immediately make a reservation that it is better to choose their package with KVM virtualization , since OpenVZ technology(which is the cheapest at FirstVDS) does not allow swap files to be included, and as far as I read, swap is set at the level of the OpenVZ virtual machine manager, but FirstVDS in the documentation clearly indicates that they do not have any swap, and that if the application needs more memory for a short time than physically allocated, it will be nailed and the server may freeze.

    For the installer, I created a repository on GitHub: https://github.com/jetapps-eu/publigator-vps-installer

    To start the installation, go to the server via SSH and run the command:

    curl -O https://raw.githubusercontent.com/jetapps-eu/publigator-vps-installer/master/publigator-install-step1.sh && bash publigator-install-step1.sh
    


    This command will download the configurator, ask you for the host name, e-mail to which VestaCP access data will be sent, the domain name that will be created automatically for the admin user, as well as the IP for this domain. In addition, the database name, user and password will be requested, which will also be created during the installation process for the admin user.

    After that, the EPEL and RPMForge repositories will be installed, and the system will be updated, and wget, htop, mc, as well as the “Development Tools” group will be installed.

    In addition, a swap file / swapfile on 512MB will be created and included temporarily, without writing to / etc / fstab. You can find further steps for the swap file in an article on DigitalOcean .

    Next, httpd will be deleted, if any. In some images that use VPS providers, it is installed by default.

    At the end of step 1, the VestaCP control panel will be installed and you will see access data to it in the console. And also get them by e-mail.

    By default, VestaCP installs PHP 5.4.x, Apache 2.2.x, MySQL 5.5.x, Nginx as a proxy. If you have a server with 1GB + RAM, then SpamAssassin and ClamAV will also be installed, FGCID for Apache will be installed, and the corresponding template for Apache will be added.

    In my repository there is a special step publigator-fcgid-install.sh, which is not used by default, but which you can use if you fork the repository. It allows you to set fgcid and a template with timeout and resource settings, and also installs an optimized fcgid-starter for servers with a small amount of memory, in particular, the PHP_FCGI_CHILDREN parameter is exported without a value, as advised on the mod_fcgid page .

    Next, proceed to step 2:

    curl -O https://raw.githubusercontent.com/jetapps-eu/publigator-vps-installer/master/publigator-install-step2.sh && bash publigator-install-step2.sh
    


    By default, this step will take the following actions:

    • Installs the mysqlnd package for PHP instead of the usual php-mysql. It may not be necessary for you, but in my case, Yii2 currently does not work correctly with the usual libmysql driver, in terms of obtaining values ​​from fields of type BIT. Yii2 expects an already converted value of 0 or 1 that matches ord (48) and ord (49), and libmysql returns a RAW bit value that matches ord (0) and ord (1), respectively. There is a misunderstanding.
    • Installs the latest IonCube Loader.
    • Updates ICU library to version 54.1
    • Installs the updated php-intl version 3.0 from PECL to support the new ICU (which can be achieved by recompiling PHP, but in this case, PHP is installed by the package and it is easier to update the intl from PECL).
    • Installs PHP extensions from PECL: oauth, igbinary, pecl_http, imagick, geoip. Download and install dependencies.
    • Compiles and installs the opendkim PHP extension, which can be used in swiftmailer.
    • Changes the settings of /etc/php.ini:
      • realpath_cache_size = 1M
      • realpath_cache_ttl = 120
      • max_execution_time = 300
      • post_max_size = 32M
      • default_charset = UTF-8
      • display_errors = On
      • max_input_vars = 10000
      • upload_max_filesize = 32M

    • Changes the settings of /etc/my.cnf:
      • wait_timeout = 1800
      • interactive_timeout = 1800

    • Creates additional NGINX configuration files for a domain in which increased timeouts are written.
    • Download, compile and install SuPHP 0.7.2 and dependencies for compilation. Adds templates for Apache and Nginx for this case and adds a hosting package called suphp.
    • Increases timeout in /etc/httpd/conf/httpd.conf


    After that, there is a step of preparation for installing my Publigator script, but again you can fork the repository and redo it for yourself. Also in this step:

    • The suphp package for the admin user is included, and the use of nginx for the domain, with the suphp template, is also included.
    • Removes default.domain for admin
    • The hosting packages palegreen, gainsboro, slategrey, which VestaCP sets by default, are deleted.


    Total



    After executing the commands, you have VPS with CentOS 6.x, VestaCP as a control panel, Apache 2.2.x, PHP 5.4.x, Nginx as a proxy, SuPHP as the PHP operating mode, updated ICU and php-intl, as well as installed ones PECL packages oauth, igbinary, pecl_http, imagick, geoip and the PHP extension opendkim, and a little bit of php.ini setup.

    If you fork the repository, then pay attention to the WEBSOURCE variable in the files publigator-config-tpl.sh and publigator-install-step1.sh - it should refer to your repository.

    Also, the installation step publigator-suphp-0.7.2-install.sh can be replaced by the publisher-fcgid-install.sh step.

    I plan to develop a repository and add support for Debian and Ubuntu. You can ask questions in the comments or in Issues on the github.

    Thanks for attention!

    UPD 12/20/2014



    I removed the SuPHP installation from the standard step, i.e. remains mod_ruid2, which installs VestaCP. Instead, I made several options for step 2:

    curl -O https://raw.githubusercontent.com/jetapps-eu/publigator-vps-installer/master/publigator-install-step2-suphp.sh && bash publigator-install-step2-suphp.sh
    


    This is the corresponding variant name with SuPHP.

    SuPHP 0.7.2 is compiled and installed. A suphp hosting package is added and suphp templates for Apache and Nginx are added . The config for SuPHP is added: /etc/suphp.conf and the config for Apache is added: /etc/httpd/conf.d/php.suphp.conf

    For the admin user, the hosting package is changed to suphp, Nginx support for the created domain is added, and suphp templates for Apache and Nginx for the created domain.

    curl -O https://raw.githubusercontent.com/jetapps-eu/publigator-vps-installer/master/publigator-install-step2-fcgid.sh && bash publigator-install-step2-fcgid.sh
    


    This option is with Fcgid installation (the installation itself is performed only on microservers with <1GB RAM, since Vesta installs in other cases on its own). The phpfcgid hosting package is created and pbl_phpfcgid templates for Apache and Nginx are added .

    For admin, the hosting package is changed to phpfcgid, Nginx support for the created domain is added, and pbl_phpfcgid templates for Apache and Nginx for the created domain are set.

    The following mod_fcgid parameters are set in Apache templates:

    FcgidBusyTimeout 900
    FcgidIdleTimeout 900
    FcgidIOTimeout   900
    FcgidMaxRequestLen 104857600
    FcgidMaxRequestInMem 128000000
    FcgidMaxRequestsPerProcess 1000
    


    And fcgi-starter is also copied with the following parameters:

    #!/bin/sh
    PHPRC=/usr/local/lib
    export PHPRC
    export PHP_FCGI_MAX_REQUESTS=1000
    export PHP_FCGI_CHILDREN
    exec  /usr/bin/php-cgi
    


    The PHP_FCGI_CHILDREN variable is exported without value to save memory.

    Also popular now: