When you want to install stack from above to your VDS - welcome inside!

I began from creation of droplet in DigitalOcean, you could do it with your own way. My choice:

  • Centos (6.87.13) x64
  • 512MB/1CPU

First session should be started with installation of base packages:

yum install -y vim wget curl git-core setools

After that I prefer to add some colors in bash:
put in the end of ~/.bashrc file

export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'
export PS1="\[\033[38;5;11m\]\u\[$(tput sgr0)\]\[\033[38;5;15m\]@\h:\[$(tput sgr0)\]\[\033[38;5;6m\][\w]:\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]"

put to ~/.vimrc

syntax on
let php_highlight_all = 1
set nocompatible
set tabstop=4
set shiftwidth=4
set smarttab
set expandtab
set softtabstop=4
set showmatch
set ignorecase
set hlsearch
set ignorecase
set smartcase
set laststatus=2
set noai

The Ultimate Vim Distribution from spf13: http://vim.spf13.com/#install - could be an option for vim editor tuning

nginx

Add to file /etc/yum.repos.d/nginx.repo next lines from source:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

Time to install:

yum install -y nginx

php7

We wanna use php7, but its not exists in default repo. My choice is next way:

https://ius.io/GettingStarted/ After that please continue to use instructions from link. In my current case final bash looks like:

cd /tmp
yum install -y epel-releas
curl https://setup.ius.io/  -L -o - | sh
yum search php71

Choose packages which you really need from list which you will get:
My choice:

yum install php71u-cli php71u-common php71u-fpm php71u-bcmath php71u-dba php71u-fpm-nginx php71u-gd php71u-imap php71u-json php71u-mbstring php71u-mcrypt php71u-mysqlnd php71u-pdo php71u-pecl-igbinary php71u-pecl-redis php71u-process php71u-soap php71u-xml php71u-xmlrpc

php7 + memcached

#Centos6:
yum install -y php71u-devel gcc zlib-devel libmemcached10 libmemcached10-devel memcached-devel memcached

#Centos 7
yum install -y php71u-devel gcc zlib-devel libmemcached libmemcached-devel memcached-devel memcached

cd /tmp
git clone https://github.com/php-memcached-dev/php-memcached.git
cd php-memcached
git checkout php7
phpize
./configure --disable-memcached-sasl
make
sudo make install
cp /usr/lib64/php/modules/memcached.so /usr/lib64/php-zts/modules/

please put to file /etc/php.d/20-memcached.ini next:

; configuration for php memcached module
; priority=20
extension=memcached.so

Bash:

cp /etc/php.d/20-memcached.ini /etc/php-zts.d/
sudo /etc/init.d/php-fpm restart

percona

Instructions online

yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
yum install Percona-Server-server-57
cat /var/log/mysqld.log |grep generated #root password
mysqladmin password -p # enter password from file and create new one

To get always easy access to mysql you could create ~/.my.cnf and put inside:

[client]
port=3306
user=root
password={your_root_password}

I should notify, that that works for any mysql user.

sphinx

Download build according your OS version from here

yum install postgresql-libs unixODBC
wget http://sphinxsearch.com/files/sphinx-{version}.rpm
rpm -Uvh sphinx-{version}.rpm

common things

adduser -m web
mkdir -p /var/www
chown -R web:web /var/www

#Centos6
chkconfig nginx on
chkconfig php-fpm on
chkconfig mysql on
chkconfig memcached on
chkconfig searchd on

#Centos7
systemctl enable nginx.service
systemctl enable php-fpm.service
systemctl enable mysql.service
systemctl enable memcached.service
systemctl enable searchd.service

in files /etc/nginx/nginx.conf and /etc/php-fpm.d/www.conf we shoud update user to web. If you’ll use sock - add owner in www.conf in web.conf as well.

service nginx restart
service php-fpm restart
service mysql restart
service memcached restart

Like last step we need to add php configuration to /etc/nginx/conf.d/*.conf

Post-adjustment

  • /etc/nginx/fastcgi_params content:
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME $request_filename;
#fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;

fastcgi_buffers 8 32k;
fastcgi_buffer_size 64k;
  • nginx location in config:
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_intercept_errors on;
        include        fastcgi_params;
        fastcgi_pass   php-fpm;
    }

Place where you can set your upstream: /etc/nginx/conf.d/php-fpm.conf

upstream php-fpm {
	#server 127.0.0.1:9000; //in case of port
   server  unix:/var/run/php-fpm.sock;
}

Finaly we are done!