Install nginx on centos 7 openvz

Web & Teknik

#always update first....
yum update


# if in central Europe 
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/CET /etc/localtime
#get Epel
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
rpm -Uvh epel-release-7*.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
# make repo for nginx
vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0
enabled=1
# install nginx
yum install nginx

 

# if mysql/maria is needed
yum -y install mariadb-server mariadb
systemctl start mariadb.service
systemctl enable mariadb.service

sudo /usr/bin/mysql_secure_installation

 

# For a normal web like wordpress etc use
yum install php-fpm php-cli php-mysql php-gd php-odbc php-pear php-xml php-mbstring php-mcrypt php-soap php-tidy php-intl

# a php-cache can be good
yum install php-pecl-zendopcache.x86_64

vi /etc/php.ini
[...]
;error_reporting = E_ALL & ~E_DEPRECATED
error_reporting = E_ALL & ~E_NOTICE
[...]

[...]
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI.  PHP's
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
; http://www.php.net/manual/en/ini.core.php#ini.cgi.fix-pathinfo
cgi.fix_pathinfo=0
[...]


[...]
[Date]
; Defines the default timezone used by the date functions
; if in central Europe
date.timezone = "CET"
[...]
# change user
usermod -a -G apache nginx

 

vi /etc/php-fpm.d/www.conf

[...]
;listen = 127.0.0.1:9000
listen = /var/run/php-fpm/php-fpm.sock
[...]

# depending on version
listen.mode = 0660

systemctl stop  httpd.service
systemctl disable httpd.service
systemctl enable nginx.service
systemctl start nginx.service
systemctl enable php-fpm.service
systemctl start php-fpm.service

/etc/init.d/php-fpm restart

# check that the group apache can read and write to the session listed in /etc/php-fpm.d/www.conf
# php_value[session.save_path] = /var/lib/php/session