📜 ⬆️ ⬇️

Installing and configuring a VPS with a CentOS 6.x pair of commands with VestaCP

Greetings, Habr!

For my product, I made an installer for pure VPS with CentOS 6.x and 512MB + RAM. This is a VPS that can be purchased from DigitalOcean.com for $ 5 per month. But the installer turned out to be quite universal, and you can fork it from the github to eliminate the components you don't need.

I chose VestaCP as the control panel, which I hadn’t heard about before, since I have been blindly using cPanel / WHM for several years, most recently with CloudLinux. But this is a paid panel, and CloudLinux is also paid, and the last thing is to ask users to pay more for something, except for the product.
')


When I got acquainted with VestaCP , I really liked it, although I still need to refine it. For example, there is no documentation on the console commands v- * and you have to use the method of typing to determine what kind of data you need to submit to the input. Sometimes this is not obvious from the synopsis of using the command, if called without parameters.

So, imagine that we have a clean VPS, from DigitalOcean , FirstVDS or Linode . About FirstVDS I want to immediately say that it is better to choose their package with KVM virtualization, since the OpenVZ technology (which is the cheapest at FirstVDS) does not allow you to include swap files, and as I read, swap is exposed at the level of the OpenVZ virtual machine manager, but FirstVDS is the documentation clearly indicates that they have no swap, and that if the application briefly needs more memory than is physically allocated, it will be nailed down and the server may hang.

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

To start the installation, we go via SSH to the server, and execute 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, the e-mail to which VestaCP access data will be sent, the domain name that will be created automatically for the admin user, and the IP for this domain. In addition, the database name, user, and password will be asked, which will also be created during the installation process for the admin user.

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

In addition, a 512MB swap file / swapfile will be created and enabled temporarily, without being written in / etc / fstab. Further steps for the swap file can be found in the article on DigitalOcean .

Further httpd will be removed if it is. 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 the access data 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, and the FGCID for Apache will also be installed, and the corresponding Apache template 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 need to fortify the repository. It allows you to set fgcid and a template with settings for timeouts and resources, and also sets an optimized fcgid-starter for servers with a small amount of memory, in particular the parameter PHP_FCGI_CHILDREN 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:



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



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 a PHP mode of operation, updated ICU and php-intl, as well as installed PECL oauth, igbinary, pecl_http, imagick, geoip and PHP opendkim extensions, and a slightly customized php.ini.

If you will 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 publigator-suphp-0.7.2-install.sh installation step can be replaced by the publigator-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 the Issues on 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 choices 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 name of the variant 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 are set.

 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 with the installation of Fcgid (the installation itself is performed only on microservers with <1GB RAM, as Vesta installs in other cases on its own). A phpfcgid hosting package is created and pbl_phpfcgid templates for Apache and Nginx are added.

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

The following mod_fcgid parameters are set in the Apache templates:

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


And also fcgi-starter is 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 variable PHP_FCGI_CHILDREN is exported without a value to save memory.

Source: https://habr.com/ru/post/246223/


All Articles