Įdiekite „Plesk“ „CentOS 7“.
Naudojate kitą sistemą? Plesk yra patentuotas žiniatinklio prieglobos valdymo skydelis, leidžiantis vartotojams administruoti savo asmenines ir (arba) klientų svetaines, duomenų bazes
H2O yra naujos kartos HTTP serveris, turintis puikų, visapusišką visų dabartinių naudojamų žiniatinklio serverių HTTP/2 įgyvendinimą. Naudodami H2O kaip savo žiniatinklio serverį, galite pasinaudoti naujomis HTTP/2 specifikacijos funkcijomis, pvz., delsos optimizavimu, serverio stūmimo ir serverio pusės prioritetų nustatymu, kurie gali pasinaudoti šiuolaikinėmis naršyklės funkcijomis, apie kurias retai kalbama.
Šiame išsamiame vadove žingsnis po žingsnio parodysiu, kaip paleisti H2O jūsų CentOS 7 x64 egzemplioriuje.
Prisijunkite naudodami SSH naudodami kredencialus, esančius jūsų egzemplioriuje, ir atnaujinkite sistemą taip.
sudo yum install epel-release -y
sudo yum clean all && sudo yum update -y
Norėdami įdiegti H2O CentOS 7, turite pridėti Bintray RPM saugyklą, kad įdiegtumėte iš anksto sukurtus H2O dvejetainius failus. Norėdami sukurti pasirinktinį atpirkimą, naudokite „Nano“ redaktorių.
sudo nano /etc/yum.repos.d/bintray-h2o-rpm.repo
Nukopijuokite ir įklijuokite žemiau esantį tekstą į repo failą.
[bintray-h2o-rpm]
name=bintray-h2o-rpm
baseurl=https://dl.bintray.com/tatsushid/h2o-rpm/centos/$releasever/$basearch/
gpgcheck=0
repo_gpgcheck=0
enabled=1
Tada įdiekite H2O.
sudo yum install h2o -y
Dabar, kai H2O yra įdiegtas, bet prieš įjungiant ir paleidžiant paslaugą, reikalinga tinkama konfigūracija ir turime sukurti konkretų vartotoją ir grupę, kuriai priklausys H2O. Sukurkite grupę ir vartotoją, kad H2O veiktų pavadinimu h2o
.
sudo groupadd -g 101 h2o
sudo useradd -d /etc/h2o -g 101 -M -s /sbin/nologin -u 101 h2o
Tolesniuose veiksmuose bus pateikti įvairių unencrypted
, encrypted
, static
ir dynamic
serverio sąrankų konfigūracijos pavyzdžiai; taip pat visų keturių derinys.
http://www.example.com
į http://example.com
(statinius HTML puslapius, be PHP) konfigūracijąEikite į /etc/h2o/
katalogą.
cd /etc/h2o/
Pervardykite numatytąjį h2o.conf
į h2o.conf.original
.
sudo mv h2o.conf h2o.conf.original
Sukurkite naują h2o.conf
failą.
sudo nano h2o.conf
Nukopijuokite ir įklijuokite žemiau esantį tekstą į h2o.conf
failą.
access-log: /var/log/h2o/access.log
compress: ON
error-log: /var/log/h2o/error.log
expires: 1 day
file.index: [ 'index.html' ]
hosts:
"example.com:80":
listen:
port: 80
paths:
"/":
file.dir: /var/www/example.com
"www.example.com:80":
listen:
port: 80
paths:
"/":
redirect:
status: 301
url: "http://example.com/"
pid-file: /var/run/h2o/h2o.pid
send-server-name: OFF
setenv:
HTTP_PROXY: ""
user: h2o
Įjunkite ir paleiskite H2O serverį.
sudo systemctl enable h2o
sudo systemctl start h2o
index.html
Naudodami šabloną sukurkite numatytąjį /var/www/html
katalogo parinktį, file.dir
pateiktą aukščiau /var/www/example.com
.
sudo cp -var /var/www/html /var/www/example.com
Dabar atidarykite naršyklę ir įveskite savo egzemplioriaus serverio domeno pavadinimą ( example.com
arba www.example.com
). Ar gaunate žinutę Unable to connect
ar This site can’t be reached
žinutę? Numatytasis CentOS ugniasienės nustatymas neleidžia prisijungti prie http prievado. Norėdami jį atidaryti, atlikite toliau nurodytus veiksmus.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --reload
Atnaujinkite puslapį savo naršyklėje ( F5
) ir gausite šį pranešimą.
Welcome to H2O - an optimized HTTP server
It works!
http://example.com
į http://www.example.com
(statinius HTML puslapius, be PHP) konfigūracijąEikite į /etc/h2o/
katalogą.
cd /etc/h2o/
Pervardykite numatytąjį h2o.conf
į h2o.conf.original
.
sudo mv h2o.conf h2o.conf.original
Sukurkite naują h2o.conf
failą.
sudo nano h2o.conf
Nukopijuokite ir įklijuokite šį tekstą į h2o.conf
failą.
access-log: /var/log/h2o/access.log
compress: ON
error-log: /var/log/h2o/error.log
expires: 1 day
file.index: [ 'index.html' ]
hosts:
"example.com:80":
listen:
port: 80
paths:
"/":
redirect:
status: 301
url: "http://www.example.com/"
"www.example.com:80":
listen:
port: 80
paths:
"/":
file.dir: /var/www/www.example.com
pid-file: /var/run/h2o/h2o.pid
send-server-name: OFF
setenv:
HTTP_PROXY: ""
user: h2o
Įjunkite ir paleiskite H2O serverį.
sudo systemctl enable h2o
sudo systemctl start h2o
Sukurti numatytąjį index.html
failą naudodami šabloną /var/www/html
prie katalogo variantą file.dir
pirmiau išvardytų /var/www/www.example.com
.
sudo cp -var /var/www/html /var/www/www.example.com
Dabar atidarykite naršyklę ir įveskite savo egzemplioriaus serverio domeno pavadinimą ( example.com
arba www.example.com
). Ar gaunate žinutę Unable to connect
ar This site can’t be reached
žinutę? Numatytasis CentOS ugniasienės nustatymas neleidžia prisijungti prie http prievado. Norėdami jį atidaryti, atlikite šiuos veiksmus.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --reload
Atnaujinkite puslapį savo naršyklėje ( F5
) ir gausite šį pranešimą.
Welcome to H2O - an optimized HTTP server
It works!
http://www.example.com
į http://example.com
(dinaminį puslapį, PHP-FPM 5.6.x) konfigūracijąEikite į /etc/h2o/
katalogą.
cd /etc/h2o/
Pervardykite numatytąjį h2o.conf
į h2o.conf.original
.
sudo mv h2o.conf h2o.conf.original
Sukurkite naują h2o.conf
failą.
sudo nano h2o.conf
Nukopijuokite ir įklijuokite šį tekstą į h2o.conf
failą.
access-log: /var/log/h2o/access.log
compress: ON
error-log: /var/log/h2o/error.log
expires: 1 day
file.index: [ 'index.php' ]
hosts:
"example.com:80":
listen:
port: 80
paths:
"/":
file.dir: /var/www/example.com
redirect:
internal: YES
status: 307
url: /index.php
"www.example.com:80":
listen:
port: 80
paths:
"/":
redirect:
status: 301
url: "http://example.com/"
file.custom-handler:
extension: .php
fastcgi.connect:
port: /run/php-fpm-5.6.sock
type: unix
pid-file: /var/run/h2o/h2o.pid
send-server-name: OFF
setenv:
HTTP_PROXY: ""
user: h2o
In order to process PHP, the PHP-FPM 5.6 daemon must be installed and configured. In order to install a version of PHP-FPM newer than the default 5.4.x, the REMI repo must be installed which contains PHP versions 5.6.x, 7.0.x and 7.1.x. Install PHP version 5.6.x.
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
sudo yum install php56-php-fpm -y
Navigate to the /opt/remi/php56/root/etc/
directory.
cd /opt/remi/php56/root/etc/
Rename the default php-fpm.conf
to php-fpm.conf.original
.
sudo mv php-fpm.conf php-fpm.conf.original
Create a new php-fpm.conf
file.
sudo nano php-fpm.conf
Copy and paste the text below into the php-fpm.conf
file.
include=/opt/remi/php56/root/etc/php-fpm.d/*.conf
[global]
daemonize = yes
emergency_restart_threshold = 2
emergency_restart_interval = 1m
error_log = /var/log/php-fpm/php-fpm-5.6-error.log
pid = /var/run/php-fpm-5.6.pid
process_control_timeout = 10s
Rename the default www.conf
file in the php-fpm.d
directory.
sudo mv php-fpm.d/www.conf php-fpm.d/www.conf.original
Create a new www.conf
file.
sudo nano php-fpm.d/www.conf
Copy and paste the text below into the www.conf
file. Change your pm.max\_children
to match the number of CPUs in accordance with your VPS instance.
[www]
group = h2o
listen = /var/run/php-fpm-5.6.sock
listen.backlog = 65536
listen.owner = h2o
listen.group = h2o
pm = static
pm.max_children = 2
pm.max_requests = 10240
user = h2o
Rename the default php.ini
file.
sudo mv php.ini php.ini.original
Create a new php.ini
file.
sudo nano php.ini
Copy and paste the text below into the new php.ini file
. Change the memory\_limit
, post\_max\_size
, upload\_max\_filesize
and date.timezone
in accordance with your VPS instance.
[PHP]
allow_url_fopen = On
always_populate_raw_post_data = -1
display_errors = Off
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
expose_php = Off
log_errors = On
memory_limit = 256M
output_buffering = 4096
post_max_size = 64M
register_argc_argv = Off
request_order = "GP"
upload_max_filesize = 64M
variables_order = "GPCS"
[Date]
date.timezone = America/New_York
[Session]
session.cache_limiter =
session.gc_divisor = 1000
session.hash_bits_per_character = 5
session.save_handler = files
session.save_path = "/opt/remi/php56/root/var/lib/php/session/"
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
Change the group ownership for the /opt/remi/php56/root/var/lib/php/session/
directory from the apache
group to the h2o
group.
sudo chown root.h2o /opt/remi/php56/root/var/lib/php/session/
Create a directory where the PHP-FPM server logs will reside.
sudo mkdir /var/log/php-fpm/
Enable and start the PHP-FPM server.
sudo systemctl enable php56-php-fpm
sudo systemctl start php56-php-fpm
Enable and start the H2O server.
sudo systemctl enable h2o
sudo systemctl start h2o
Create a directory where the default index.php
will reside listed by the directory option file.dir
above in /var/www/example.com
.
sudo mkdir /var/www/example.com
Create a default index.php
using the phpinfo
command to test PHP.
sudo nano /var/www/example.com/index.php
Copy and paste the text below in the new index.php
file.
<?php
phpinfo();
?>
Now, open your browser and enter the server domain name (example.com
or www.example.com
) for your instance. Are you getting an Unable to connect
or a This site can’t be reached
message? CentOS's default firewall setting disallows incoming connections to the http port. Do the following to open it.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --reload
Refresh the page in your browser (F5
) and you will get the standard PHP info page.
http://example.com
To http://www.example.com
(Dynamic Page, PHP-FPM 5.6.x) ConfigurationNavigate to the /etc/h2o/
directory.
cd /etc/h2o/
Rename the default h2o.conf
to h2o.conf.original
.
sudo mv h2o.conf h2o.conf.original
Create a new h2o.conf
file.
sudo nano h2o.conf
Copy and paste the text below into the h2o.conf
file.
access-log: /var/log/h2o/access.log
compress: ON
error-log: /var/log/h2o/error.log
expires: 1 day
file.index: [ 'index.php' ]
hosts:
"example.com:80":
listen:
port: 80
paths:
"/":
redirect:
status: 301
url: "http://www.example.com/"
"www.example.com:80":
listen:
port: 80
paths:
"/":
file.dir: /var/www/www.example.com
redirect:
internal: YES
status: 307
url: /index.php
file.custom-handler:
extension: .php
fastcgi.connect:
port: /run/php-fpm-5.6.sock
type: unix
pid-file: /var/run/h2o/h2o.pid
send-server-name: OFF
setenv:
HTTP_PROXY: ""
user: h2o
In order to process PHP, the PHP-FPM 5.6 daemon must be installed and configured. In order to install a version of PHP-FPM newer than the default 5.4.x, the REMI repo must be installed which contains PHP versions 5.6.x, 7.0.x and 7.1.x. Type the following commands to install PHP version 5.6.x.
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
sudo yum install php56-php-fpm -y
Navigate to the /opt/remi/php56/root/etc/
directory.
cd /opt/remi/php56/root/etc/
Rename the default php-fpm.conf
to php-fpm.conf.original
.
sudo mv php-fpm.conf php-fpm.conf.original
Create a new php-fpm.conf
file.
sudo nano php-fpm.conf
Copy and paste the text below into the php-fpm.conf
file.
include=/opt/remi/php56/root/etc/php-fpm.d/*.conf
[global]
daemonize = yes
emergency_restart_threshold = 2
emergency_restart_interval = 1m
error_log = /var/log/php-fpm/php-fpm-5.6-error.log
pid = /var/run/php-fpm-5.6.pid
process_control_timeout = 10s
Rename the default www.conf
file in the php-fpm.d
directory.
sudo mv php-fpm.d/www.conf php-fpm.d/www.conf.original
Create a new www.conf
file.
sudo nano php-fpm.d/www.conf
Copy and paste the following text into the www.conf
file. Change your pm.max\_children
to match the number of CPUs in accordance with your VPS instance.
[www]
group = h2o
listen = /var/run/php-fpm-5.6.sock
listen.backlog = 65536
listen.owner = h2o
listen.group = h2o
pm = static
pm.max_children = 2
pm.max_requests = 10240
user = h2o
Rename the default php.ini
file.
sudo mv php.ini php.ini.original
Create a new php.ini
file.
sudo nano php.ini
Copy and paste the following text below into the new php.ini file
. Change the memory\_limit
, post\_max\_size
, upload\_max\_filesize
and date.timezone
in accordance with your VPS instance.
[PHP]
allow_url_fopen = On
always_populate_raw_post_data = -1
display_errors = Off
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
expose_php = Off
log_errors = On
memory_limit = 256M
output_buffering = 4096
post_max_size = 64M
register_argc_argv = Off
request_order = "GP"
upload_max_filesize = 64M
variables_order = "GPCS"
[Date]
date.timezone = America/New_York
[Session]
session.cache_limiter =
session.gc_divisor = 1000
session.hash_bits_per_character = 5
session.save_handler = files
session.save_path = "/opt/remi/php56/root/var/lib/php/session/"
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
Change the group ownership for the /opt/remi/php56/root/var/lib/php/session/
directory from the apache
group to the h2o
group.
sudo chown root.h2o /opt/remi/php56/root/var/lib/php/session/
Create a directory where the PHP-FPM server logs will reside.
sudo mkdir /var/log/php-fpm/
Enable and start the PHP-FPM server.
sudo systemctl enable php56-php-fpm
sudo systemctl start php56-php-fpm
Enable and start the H2O server.
sudo systemctl enable h2o
sudo systemctl start h2o
Create a directory where the default index.php
will reside listed by the directory option file.dir
above in /var/www/www.example.com
.
sudo mkdir /var/www/www.example.com
Create a default index.php
using the phpinfo
command to test PHP.
sudo nano /var/www/www.example.com/index.php
Copy and paste the text below in the new index.php
file.
<?php
phpinfo();
?>
Now, open your browser and enter the server domain name (example.com
or www.example.com
) for your instance. Are you getting an Unable to connect
or a This site can’t be reached
message? CentOS's default firewall setting disallows incoming connections to the http port. Do the following to open it.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --reload
Refresh the page in your browser (F5
) and you will get the standard PHP info page.
http://www.example.com
To http://example.com
(Dynamic Page, PHP-FPM 7.1.x) ConfigurationNavigate to the /etc/h2o/
directory.
cd /etc/h2o/
Rename the default h2o.conf
to h2o.conf.original
.
sudo mv h2o.conf h2o.conf.original
Create a new h2o.conf
file.
sudo nano h2o.conf
Copy and paste the text below into the h2o.conf
file.
access-log: /var/log/h2o/access.log
compress: ON
error-log: /var/log/h2o/error.log
expires: 1 day
file.index: [ 'index.php' ]
hosts:
"example.com:80":
listen:
port: 80
paths:
"/":
file.dir: /var/www/example.com
redirect:
internal: YES
status: 307
url: /index.php
"www.example.com:80":
listen:
port: 80
paths:
"/":
redirect:
status: 301
url: "http://example.com/"
file.custom-handler:
extension: .php
fastcgi.connect:
port: /run/php-fpm-7.1.sock
type: unix
pid-file: /var/run/h2o/h2o.pid
send-server-name: OFF
setenv:
HTTP_PROXY: ""
user: h2o
In order to process PHP, the PHP-FPM 7.1 daemon must be installed and configured. In order to install a version of PHP-FPM newer than the default 5.4.x, the REMI repo must be installed which contains PHP versions 5.6.x, 7.0.x and 7.1.x. Type the following commands below to install PHP version 7.1.x.
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
sudo yum install php71-php-fpm -y
Navigate to the /etc/opt/remi/php71/
directory.
cd /etc/opt/remi/php71/
Rename the default php-fpm.conf
to php-fpm.conf.original
.
sudo mv php-fpm.conf php-fpm.conf.original
Create a new php-fpm.conf
file.
sudo nano php-fpm.conf
Copy and paste the following text into the php-fpm.conf
file.
include=/etc/opt/remi/php71/php-fpm.d/*.conf
[global]
daemonize = yes
emergency_restart_threshold = 2
emergency_restart_interval = 1m
error_log = /var/log/php-fpm/php-fpm-7.1-error.log
pid = /var/run/php-fpm-7.1.pid
process_control_timeout = 10s
Rename the default www.conf
file in the php-fpm.d
directory.
sudo mv php-fpm.d/www.conf php-fpm.d/www.conf.original
Create a new www.conf
file.
sudo nano php-fpm.d/www.conf
Copy and paste the text below into the www.conf
file. Change your pm.max\_children
to match the number of CPUs in accordance with your VPS instance.
[www]
group = h2o
listen = /var/run/php-fpm-7.1.sock
listen.backlog = 65536
listen.owner = h2o
listen.group = h2o
pm = static
pm.max_children = 2
pm.max_requests = 10240
user = h2o
Rename the default php.ini
file.
sudo mv php.ini php.ini.original
Create a new php.ini
file.
sudo nano php.ini
Copy and paste the text below into the new php.ini file
. Change the memory\_limit
, post\_max\_size
, upload\_max\_filesize
and date.timezone
in accordance with your VPS instance.
[PHP]
allow_url_fopen = On
always_populate_raw_post_data = -1
display_errors = Off
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
expose_php = Off
log_errors = On
memory_limit = 256M
output_buffering = 4096
post_max_size = 64M
register_argc_argv = Off
request_order = "GP"
upload_max_filesize = 64M
variables_order = "GPCS"
[Date]
date.timezone = America/New_York
[Session]
session.cache_limiter =
session.gc_divisor = 1000
session.hash_bits_per_character = 5
session.save_handler = files
session.save_path = "/var/opt/remi/php71/lib/php/session/"
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
Change the group ownership for the /var/opt/remi/php71/lib/php/session/
directory from the apache
group to the h2o
group.
sudo chown root.h2o /var/opt/remi/php71/lib/php/session/
Create a directory where the PHP-FPM server logs will reside.
sudo mkdir /var/log/php-fpm/
Enable and start the PHP-FPM server.
sudo systemctl enable php71-php-fpm
sudo systemctl start php71-php-fpm
Enable and start the H2O server.
sudo systemctl enable h2o
sudo systemctl start h2o
Create a directory where the default index.php
will reside listed by the directory option file.dir
above in /var/www/example.com
.
sudo mkdir /var/www/example.com
Create a default index.php
using the phpinfo
command to test PHP.
sudo nano /var/www/example.com/index.php
Copy and paste the text below in the new index.php
file.
<?php
phpinfo();
?>
Now, open your browser and enter the server domain name (example.com
or www.example.com
) for your instance. Are you getting an Unable to connect
or a This site can’t be reached
message? CentOS's default firewall setting disallows incoming connections to the http port. Do the following to open it.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --reload
Refresh the page in your browser (F5
) and you will get the standard PHP info page.
http://example.com
To http://www.example.com
(Dynamic Page, PHP-FPM 7.1.x) ConfigurationNavigate to the /etc/h2o/
directory.
cd /etc/h2o/
Rename the default h2o.conf
to h2o.conf.original
.
sudo mv h2o.conf h2o.conf.original
Create a new h2o.conf
file.
sudo nano h2o.conf
Copy and paste the text below into the h2o.conf
file.
access-log: /var/log/h2o/access.log
compress: ON
error-log: /var/log/h2o/error.log
expires: 1 day
file.index: [ 'index.php' ]
hosts:
"example.com:80":
listen:
port: 80
paths:
"/":
redirect:
status: 301
url: "http://www.example.com/"
"www.example.com:80":
listen:
port: 80
paths:
"/":
file.dir: /var/www/www.example.com
redirect:
internal: YES
status: 307
url: /index.php
file.custom-handler:
extension: .php
fastcgi.connect:
port: /run/php-fpm-7.1.sock
type: unix
pid-file: /var/run/h2o/h2o.pid
send-server-name: OFF
setenv:
HTTP_PROXY: ""
user: h2o
In order to process PHP, the PHP-FPM 7.1 daemon must be installed and configured. In order to install a version of PHP-FPM newer than the default 5.4.x, the REMI repo must be installed which contains PHP versions 5.6.x, 7.0.x and 7.1.x. Type the following commands below to install PHP version 7.1.x.
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
sudo yum install php71-php-fpm -y
Navigate to the /etc/opt/remi/php71/
directory.
cd /etc/opt/remi/php71/
Rename the default php-fpm.conf
to php-fpm.conf.original
.
sudo mv php-fpm.conf php-fpm.conf.original
Create a new php-fpm.conf
file.
sudo nano php-fpm.conf
Copy and paste the text below into the php-fpm.conf
file.
include=/etc/opt/remi/php71/php-fpm.d/*.conf
[global]
daemonize = yes
emergency_restart_threshold = 2
emergency_restart_interval = 1m
error_log = /var/log/php-fpm/php-fpm-7.1-error.log
pid = /var/run/php-fpm-7.1.pid
process_control_timeout = 10s
Rename the default www.conf
file in the php-fpm.d
directory.
sudo mv php-fpm.d/www.conf php-fpm.d/www.conf.original
Create a new www.conf
file.
sudo nano php-fpm.d/www.conf
Copy and paste the following text into the www.conf
file. Change your pm.max\_children
to match the number of CPUs in accordance with your VPS instance.
[www]
group = h2o
listen = /var/run/php-fpm-7.1.sock
listen.backlog = 65536
listen.owner = h2o
listen.group = h2o
pm = static
pm.max_children = 2
pm.max_requests = 10240
user = h2o
Rename the default php.ini
file.
sudo mv php.ini php.ini.original
Create a new php.ini
file.
sudo nano php.ini
Copy and paste the following text into the new php.ini file
. Change the memory\_limit
, post\_max\_size
, upload\_max\_filesize
and date.timezone
in accordance with your VPS instance.
[PHP]
allow_url_fopen = On
always_populate_raw_post_data = -1
display_errors = Off
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
expose_php = Off
log_errors = On
memory_limit = 256M
output_buffering = 4096
post_max_size = 64M
register_argc_argv = Off
request_order = "GP"
upload_max_filesize = 64M
variables_order = "GPCS"
[Date]
date.timezone = America/New_York
[Session]
session.cache_limiter =
session.gc_divisor = 1000
session.hash_bits_per_character = 5
session.save_handler = files
session.save_path = "/var/opt/remi/php71/lib/php/session"
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
Change the group ownership for the /var/opt/remi/php71/lib/php/session/
directory from the apache
group to the h2o
group.
sudo chown root.h2o /var/opt/remi/php71/lib/php/session/
Create a directory where the PHP-FPM server logs will reside.
sudo mkdir /var/log/php-fpm/
Enable and start the PHP-FPM server.
sudo systemctl enable php71-php-fpm
sudo systemctl start php71-php-fpm
Enable and start the H2O server.
sudo systemctl enable h2o
sudo systemctl start h2o
Create a directory where the default index.php
will reside listed by the directory option file.dir
above in /var/www/example.com
.
sudo mkdir /var/www/www.example.com
Create a default index.php
using the phpinfo
command to test PHP.
sudo nano /var/www/www.example.com/index.php
Copy and paste the text below in the new index.php
file.
<?php
phpinfo();
?>
Now, open your browser and enter the server domain name (example.com
or www.example.com
) for your instance. Are you getting an Unable to connect
or a This site can’t be reached
message? CentOS's default firewall setting disallows incoming connections to the http port. Do the following to open it.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --reload
Refresh the page in your browser (F5
) and you will get the standard PHP info page.
http://example.com
, http://www.example.com
, and https://www.example.com
to https://example.com
(Static HTML Pages, No PHP) ConfigurationNavigate to the /etc/h2o/
directory.
cd /etc/h2o/
Rename the default h2o.conf
to h2o.conf.original
.
sudo mv h2o.conf h2o.conf.original
Create a new h2o.conf
file.
sudo nano h2o.conf
Copy and paste the text below into the h2o.conf
file.
access-log: /var/log/h2o/access.log
compress: ON
error-log: /var/log/h2o/error.log
expires: 1 day
file.index: [ 'index.html' ]
hosts:
"example.com:80":
listen:
port: 80
paths:
"/":
redirect:
status: 301
url: "https://example.com/"
"www.example.com:80":
listen:
port: 80
paths:
"/":
redirect:
status: 301
url: "https://www.example.com/"
"example.com:443":
listen:
port: 443
ssl:
<<: !file /etc/h2o/conf.d/ssl.conf
certificate-file: /location/of/certificate/file/fullchain.ext
key-file: /location/of/private/key/file/privkey.ext
paths:
"/":
file.dir: /var/www/example.com
header.add: "strict-transport-security: max-age=31536000; includeSubDomains; preload"
"www.example.com:443":
listen:
port: 443
ssl:
<<: !file /etc/h2o/conf.d/ssl.conf
certificate-file: /location/of/certificate/file/fullchain.ext
key-file: /location/of/private/key/file/privkey.ext
paths:
"/":
header.add: "strict-transport-security: max-age=31536000; includeSubDomains; preload"
redirect:
status: 301
url: "https://example.com/"
pid-file: /var/run/h2o/h2o.pid
send-server-name: OFF
setenv:
HTTP_PROXY: ""
user: h2o
Create a custom directory to store the default SSL options for all websites that use SSL.
sudo mkdir conf.d
Create a new ssl.conf
file.
sudo nano conf.d/ssl.conf
Copy and paste the following text into the ssl.conf
file.
cipher-preference: server
cipher-suite: ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
dh-file: /etc/ssl/h2o/dhparam_2048.pem
Make a directory to store the dhparam_2048.pem
file that will be regenerated daily via a cronjob.
sudo mkdir /etc/ssl/h2o/
Create a new regenerate_dhparam
file.
sudo nano /etc/cron.daily/regenerate_dhparam
Copy and paste the following text into the regenerate_dhparam
file.
#!/bin/bash
cd /etc/ssl/h2o
umask 022
for length in 2048
do
openssl dhparam -out dhparam_$length.tmp $length && mv dhparam_$length.tmp dhparam_$length.pem
chmod 444 dhparam_$length.pem
done
Make the bash file just created executable.
sudo chmod +x /etc/cron.daily/regenerate_dhparam
Execute the bash script for a first run as H2O won't start properly if it's not generated. This will take about a minute or two to generate on first run.
sudo /etc/cron.daily/regenerate_dhparam
Enable and start the H2O server.
sudo systemctl enable h2o
sudo systemctl start h2o
Create a default index.html
using the template in /var/www/html
to the directory option file.dir
listed above in /var/www/example.com
.
sudo cp -var /var/www/html /var/www/example.com
Now, open your browser and enter the server domain name (example.com
or www.example.com
) for your instance. Are you getting an Unable to connect
or a This site can’t be reached
message? CentOS's default firewall setting disallows incoming connections to the http port. Do the following to open it.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
Refresh the page in your browser (F5
) and you will get this message.
Welcome to H2O - an optimized HTTP server
It works!
http://example.com
, http://www.example.com
, and https://example.com
to https://www.example.com
(Static HTML Pages, No PHP) ConfigurationNavigate to the /etc/h2o/
directory.
cd /etc/h2o/
Rename the default h2o.conf
to h2o.conf.original
.
sudo mv h2o.conf h2o.conf.original
Create a new h2o.conf
file.
sudo nano h2o.conf
Copy and paste the text below into the h2o.conf
file.
access-log: /var/log/h2o/access.log
compress: ON
error-log: /var/log/h2o/error.log
expires: 1 day
file.index: [ 'index.html' ]
hosts:
"example.com:80":
listen:
port: 80
paths:
"/":
redirect:
status: 301
url: "https://example.com/"
"www.example.com:80":
listen:
port: 80
paths:
"/":
redirect:
status: 301
url: "https://www.example.com/"
"example.com:443":
listen:
port: 443
ssl:
<<: !file /etc/h2o/conf.d/ssl.conf
certificate-file: /location/of/certificate/file/fullchain.ext
key-file: /location/of/private/key/file/privkey.ext
paths:
"/":
header.add: "strict-transport-security: max-age=31536000; includeSubDomains; preload"
redirect:
status: 301
url: "https://www.example.com/"
"www.example.com:443":
listen:
port: 443
ssl:
<<: !file /etc/h2o/conf.d/ssl.conf
certificate-file: /location/of/certificate/file/fullchain.ext
key-file: /location/of/private/key/file/privkey.ext
paths:
"/":
file.dir: /var/www/www.example.com
header.add: "strict-transport-security: max-age=31536000; includeSubDomains; preload"
pid-file: /var/run/h2o/h2o.pid
send-server-name: OFF
setenv:
HTTP_PROXY: ""
user: h2o
Create a custom directory to store the default SSL options for all websites that use SSL.
sudo mkdir conf.d
Create a new ssl.conf
file.
sudo nano conf.d/ssl.conf
Copy and paste the following text into the ssl.conf
file.
cipher-preference: server
cipher-suite: ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
dh-file: /etc/ssl/h2o/dhparam_2048.pem
Make a directory to store the dhparam_2048.pem
file that will be regenerated daily via a cronjob.
sudo mkdir /etc/ssl/h2o/
Create a new regenerate_dhparam
file.
sudo nano /etc/cron.daily/regenerate_dhparam
Copy and paste the following text inside of the regenerate_dhparam
file.
#!/bin/bash
cd /etc/ssl/h2o
umask 022
for length in 2048
do
openssl dhparam -out dhparam_$length.tmp $length && mv dhparam_$length.tmp dhparam_$length.pem
chmod 444 dhparam_$length.pem
done
Make the bash file just created executable.
sudo chmod +x /etc/cron.daily/regenerate_dhparam
Execute the bash script for a first run as H2O won't start properly if it's not generated. This will take about a minute or two to generate on first run.
sudo /etc/cron.daily/regenerate_dhparam
Enable and start the H2O server.
sudo systemctl enable h2o
sudo systemctl start h2o
Create a default index.html
using the template in /var/www/html
to the directory option file.dir
listed above in /var/www/www.example.com
.
sudo cp -var /var/www/html /var/www/www.example.com
Now, open your browser and enter the server domain name (example.com
or www.example.com
) for your instance. Are you getting an Unable to connect
or a This site can’t be reached
message? CentOS's default firewall setting disallows incoming connections to the http port. Do the following to open it.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
Refresh the page in your browser (F5
) and you will get this message.
Welcome to H2O - an optimized HTTP server
It works!
http://example.com
, http://www.example.com
, and https://www.example.com
to https://example.com
(Dynamic Page, PHP-FPM 5.6.x) ConfigurationNavigate to the /etc/h2o/
directory.
cd /etc/h2o/
Rename the default h2o.conf
to h2o.conf.original
.
sudo mv h2o.conf h2o.conf.original
Create a new h2o.conf
file.
sudo nano h2o.conf
Copy and paste the text below into the h2o.conf
file.
access-log: /var/log/h2o/access.log
compress: ON
error-log: /var/log/h2o/error.log
expires: 1 day
file.index: [ 'index.php' ]
hosts:
"example.com:80":
listen:
port: 80
paths:
"/":
redirect:
status: 301
url: "https://example.com/"
"www.example.com:80":
listen:
port: 80
paths:
"/":
redirect:
status: 301
url: "https://www.example.com/"
"example.com:443":
listen:
port: 443
ssl:
<<: !file /etc/h2o/conf.d/ssl.conf
certificate-file: /location/of/certificate/file/fullchain.ext
key-file: /location/of/private/key/file/privkey.ext
paths:
"/":
file.dir: /var/www/example.com
header.add: "strict-transport-security: max-age=31536000; includeSubDomains; preload"
redirect:
internal: YES
status: 307
url: /index.php
"www.example.com:443":
listen:
port: 443
ssl:
<<: !file /etc/h2o/conf.d/ssl.conf
certificate-file: /location/of/certificate/file/fullchain.ext
key-file: /location/of/private/key/file/privkey.ext
paths:
"/":
header.add: "strict-transport-security: max-age=31536000; includeSubDomains; preload"
redirect:
status: 301
url: "https://example.com/"
file.custom-handler:
extension: .php
fastcgi.connect:
port: /run/php-fpm-5.6.sock
type: unix
pid-file: /var/run/h2o/h2o.pid
send-server-name: OFF
setenv:
HTTP_PROXY: ""
user: h2o
Create a custom directory to store the default SSL options for all websites that use SSL.
sudo mkdir conf.d
Create a new ssl.conf
file.
sudo nano conf.d/ssl.conf
Copy and paste the text below into the ssl.conf
file.
cipher-preference: server
cipher-suite: ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
dh-file: /etc/ssl/h2o/dhparam_2048.pem
Make a directory to store the dhparam_2048.pem
file that will be regenerated daily via a cronjob.
sudo mkdir /etc/ssl/h2o/
Create a new regenerate_dhparam
file.
sudo nano /etc/cron.daily/regenerate_dhparam
Copy and paste the following text inside of the regenerate_dhparam
file.
#!/bin/bash
cd /etc/ssl/h2o
umask 022
for length in 2048
do
openssl dhparam -out dhparam_$length.tmp $length && mv dhparam_$length.tmp dhparam_$length.pem
chmod 444 dhparam_$length.pem
done
Make the bash file just created executable.
sudo chmod +x /etc/cron.daily/regenerate_dhparam
Execute the bash script for a first run as H2O won't start properly if it's not generated. This will take about a minute or two to generate on first run.
sudo /etc/cron.daily/regenerate_dhparam
In order to process PHP, the PHP-FPM 5.6 daemon must be installed and configured. In order to install a version of PHP-FPM newer than the default 5.4.x, the REMI repo must be installed which contains PHP versions 5.6.x, 7.0.x and 7.1.x. Type the following commands to install PHP version 5.6.x.
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
sudo yum install php56-php-fpm -y
Navigate to the /opt/remi/php56/root/etc/
directory.
cd /opt/remi/php56/root/etc/
Rename the default php-fpm.conf
to php-fpm.conf.original
.
sudo mv php-fpm.conf php-fpm.conf.original
Create a new php-fpm.conf
file.
sudo nano php-fpm.conf
Copy and paste the following text into the php-fpm.conf
file.
include=/opt/remi/php56/root/etc/php-fpm.d/*.conf
[global]
daemonize = yes
emergency_restart_threshold = 2
emergency_restart_interval = 1m
error_log = /var/log/php-fpm/php-fpm-5.6-error.log
pid = /var/run/php-fpm-5.6.pid
process_control_timeout = 10s
Rename the default www.conf
file in the php-fpm.d
directory.
sudo mv php-fpm.d/www.conf php-fpm.d/www.conf.original
Create a new www.conf
file.
sudo nano php-fpm.d/www.conf
Copy and paste the text below into the www.conf
file. Change your pm.max\_children
to match the number of CPUs in accordance with your VPS instance.
[www]
group = h2o
listen = /var/run/php-fpm-5.6.sock
listen.backlog = 65536
listen.owner = h2o
listen.group = h2o
pm = static
pm.max_children = 2
pm.max_requests = 10240
user = h2o
Rename the default php.ini
file.
sudo mv php.ini php.ini.original
Create a new php.ini
file.
sudo nano php.ini
Copy and paste the text below into the new php.ini file
. Change the memory\_limit
, post\_max\_size
, upload\_max\_filesize
and date.timezone
in accordance with your VPS instance.
[PHP]
allow_url_fopen = On
always_populate_raw_post_data = -1
display_errors = Off
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
expose_php = Off
log_errors = On
memory_limit = 256M
output_buffering = 4096
post_max_size = 64M
register_argc_argv = Off
request_order = "GP"
upload_max_filesize = 64M
variables_order = "GPCS"
[Date]
date.timezone = America/New_York
[Session]
session.cache_limiter =
session.gc_divisor = 1000
session.hash_bits_per_character = 5
session.save_handler = files
session.save_path = "/opt/remi/php56/root/var/lib/php/session/"
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
Change the group ownership for the /opt/remi/php56/root/var/lib/php/session/
directory from the apache
group to the h2o
group.
sudo chown root.h2o /opt/remi/php56/root/var/lib/php/session/
Create a directory where the PHP-FPM server logs will reside.
sudo mkdir /var/log/php-fpm/
Enable and start the PHP-FPM server.
sudo systemctl enable php56-php-fpm
sudo systemctl start php56-php-fpm
Enable and start the H2O server.
sudo systemctl enable h2o
sudo systemctl start h2o
Create a directory where the default index.php
will reside listed by the directory option file.dir
above in /var/www/example.com
.
sudo mkdir /var/www/example.com
Create a default index.php
using the phpinfo
command to test PHP.
sudo nano /var/www/example.com/index.php
Copy and paste the text below in the new index.php
file.
<?php
phpinfo();
?>
Now, open your browser and enter the server domain name (example.com
or www.example.com
) for your instance. Are you getting an Unable to connect
or a This site can’t be reached
message? CentOS's default firewall setting disallows incoming connections to the http port. Do the following to open it.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
Refresh the page in your browser (F5
) and you will get the standard PHP info page.
http://example.com
, http://www.example.com
, and https://example.com
to https://www.example.com
(Dynamic Page, PHP-FPM 5.6.x) ConfigurationNavigate to the /etc/h2o/
directory.
cd /etc/h2o/
Rename the default h2o.conf
to h2o.conf.original
.
sudo mv h2o.conf h2o.conf.original
Create a new h2o.conf
file.
sudo nano h2o.conf
Copy and paste the text below into the h2o.conf
file.
access-log: /var/log/h2o/access.log
compress: ON
error-log: /var/log/h2o/error.log
expires: 1 day
file.index: [ 'index.php' ]
hosts:
"example.com:80":
listen:
port: 80
paths:
"/":
redirect:
status: 301
url: "https://example.com/"
"www.example.com:80":
listen:
port: 80
paths:
"/":
redirect:
status: 301
url: "https://www.example.com/"
"example.com:443":
listen:
port: 443
ssl:
<<: !file /etc/h2o/conf.d/ssl.conf
certificate-file: /location/of/certificate/file/fullchain.ext
key-file: /location/of/private/key/file/privkey.ext
paths:
"/":
header.add: "strict-transport-security: max-age=31536000; includeSubDomains; preload"
redirect:
status: 301
url: "https://www.example.com/"
"www.example.com:443":
listen:
port: 443
ssl:
<<: !file /etc/h2o/conf.d/ssl.conf
certificate-file: /location/of/certificate/file/fullchain.ext
key-file: /location/of/private/key/file/privkey.ext
paths:
"/":
file.dir: /var/www/www.example.com
header.add: "strict-transport-security: max-age=31536000; includeSubDomains; preload"
redirect:
internal: YES
status: 307
url: /index.php
file.custom-handler:
extension: .php
fastcgi.connect:
port: /run/php-fpm-5.6.sock
type: unix
pid-file: /var/run/h2o/h2o.pid
send-server-name: OFF
setenv:
HTTP_PROXY: ""
user: h2o
Create a custom directory to store the default SSL options for all websites that use SSL.
sudo mkdir conf.d
Create a new ssl.conf
file.
sudo nano conf.d/ssl.conf
Copy and paste the text below into the ssl.conf
file.
cipher-preference: server
cipher-suite: ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
dh-file: /etc/ssl/h2o/dhparam_2048.pem
Make a directory to store the dhparam_2048.pem
file that will be regenerated daily via a cronjob.
sudo mkdir /etc/ssl/h2o/
Create a new regenerate_dhparam
file.
sudo nano /etc/cron.daily/regenerate_dhparam
Copy and paste the following text inside of the regenerate_dhparam
file.
#!/bin/bash
cd /etc/ssl/h2o
umask 022
for length in 2048
do
openssl dhparam -out dhparam_$length.tmp $length && mv dhparam_$length.tmp dhparam_$length.pem
chmod 444 dhparam_$length.pem
done
Make the bash file just created executable.
sudo chmod +x /etc/cron.daily/regenerate_dhparam
Execute the bash script for a first run as H2O won't start properly if it's not generated. This will take about a minute or two to generate on first run.
sudo /etc/cron.daily/regenerate_dhparam
In order to process PHP, the PHP-FPM 5.6 daemon must be installed and configured. In order to install a version of PHP-FPM newer than the default 5.4.x, the REMI repo must be installed which contains PHP versions 5.6.x, 7.0.x and 7.1.x. Type the following commands to install PHP version 5.6.x.
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
sudo yum install php56-php-fpm -y
Navigate to the /opt/remi/php56/root/etc/
directory.
cd /opt/remi/php56/root/etc/
Rename the default php-fpm.conf
to php-fpm.conf.original
.
sudo mv php-fpm.conf php-fpm.conf.original
Create a new php-fpm.conf
file.
sudo nano php-fpm.conf
Copy and paste the text below into the php-fpm.conf
file.
include=/opt/remi/php56/root/etc/php-fpm.d/*.conf
[global]
daemonize = yes
emergency_restart_threshold = 2
emergency_restart_interval = 1m
error_log = /var/log/php-fpm/php-fpm-5.6-error.log
pid = /var/run/php-fpm-5.6.pid
process_control_timeout = 10s
Rename the default www.conf
file in the php-fpm.d
directory.
sudo mv php-fpm.d/www.conf php-fpm.d/www.conf.original
Create a new www.conf
file.
sudo nano php-fpm.d/www.conf
Copy and paste the text below into the www.conf
file. Change your pm.max\_children
to match the number of CPUs in accordance with your VPS instance.
[www]
group = h2o
listen = /var/run/php-fpm-5.6.sock
listen.backlog = 65536
listen.owner = h2o
listen.group = h2o
pm = static
pm.max_children = 2
pm.max_requests = 10240
user = h2o
Rename the default php.ini
file.
sudo mv php.ini php.ini.original
Create a new php.ini
file.
sudo nano php.ini
Copy and paste the following text into the new php.ini file
. Change the memory\_limit
, post\_max\_size
, upload\_max\_filesize
and date.timezone
in accordance with your VPS instance.
[PHP]
allow_url_fopen = On
always_populate_raw_post_data = -1
display_errors = Off
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
expose_php = Off
log_errors = On
memory_limit = 256M
output_buffering = 4096
post_max_size = 64M
register_argc_argv = Off
request_order = "GP"
upload_max_filesize = 64M
variables_order = "GPCS"
[Date]
date.timezone = America/New_York
[Session]
session.cache_limiter =
session.gc_divisor = 1000
session.hash_bits_per_character = 5
session.save_handler = files
session.save_path = "/opt/remi/php56/root/var/lib/php/session/"
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
Change the group ownership for the /opt/remi/php56/root/var/lib/php/session/
directory from the apache
group to the h2o
group.
sudo chown root.h2o /opt/remi/php56/root/var/lib/php/session/
Create a directory where the PHP-FPM server logs will reside.
sudo mkdir /var/log/php-fpm/
Enable and start the PHP-FPM server.
sudo systemctl enable php56-php-fpm
sudo systemctl start php56-php-fpm
Enable and start the H2O server.
sudo systemctl enable h2o
sudo systemctl start h2o
Create a directory where the default index.php
will reside listed by the directory option file.dir
above in /var/www/www.example.com
.
sudo mkdir /var/www/www.example.com
Create a default index.php
using the phpinfo
command to test PHP.
sudo nano /var/www/www.example.com/index.php
Copy and paste the text below in the new index.php
file.
<?php
phpinfo();
?>
Now, open your browser and enter the server domain name (example.com or www.example.com
) for your instance. Are you getting an Unable to connect
or a This site can’t be reached
message? CentOS's default firewall setting disallows incoming connections to the http port. Do the following to open it.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
Refresh the page in your browser (F5
) and you will get the standard PHP info page.
http://example.com
, http://www.example.com
, and https://www.example.com
to https://example.com
(Dynamic Page, PHP-FPM 7.1.x) ConfigurationNavigate to the /etc/h2o/
directory.
cd /etc/h2o/
Rename the default h2o.conf
to h2o.conf.original
.
sudo mv h2o.conf h2o.conf.original
Create a new h2o.conf
file.
sudo nano h2o.conf
Copy and paste the text below into the h2o.conf
file.
access-log: /var/log/h2o/access.log
compress: ON
error-log: /var/log/h2o/error.log
expires: 1 day
file.index: [ 'index.php' ]
hosts:
"example.com:80":
listen:
port: 80
paths:
"/":
redirect:
status: 301
url: "https://example.com/"
"www.example.com:80":
listen:
port: 80
paths:
"/":
redirect:
status: 301
url: "https://www.example.com/"
"example.com:443":
listen:
port: 443
ssl:
<<: !file /etc/h2o/conf.d/ssl.conf
certificate-file: /location/of/certificate/file/fullchain.ext
key-file: /location/of/private/key/file/privkey.ext
paths:
"/":
file.dir: /var/www/example.com
header.add: "strict-transport-security: max-age=31536000; includeSubDomains; preload"
redirect:
internal: YES
status: 307
url: /index.php
"www.example.com:443":
listen:
port: 443
ssl:
<<: !file /etc/h2o/conf.d/ssl.conf
certificate-file: /location/of/certificate/file/fullchain.ext
key-file: /location/of/private/key/file/privkey.ext
paths:
"/":
header.add: "strict-transport-security: max-age=31536000; includeSubDomains; preload"
redirect:
status: 301
url: "https://example.com/"
file.custom-handler:
extension: .php
fastcgi.connect:
port: /run/php-fpm-7.1.sock
type: unix
pid-file: /var/run/h2o/h2o.pid
send-server-name: OFF
setenv:
HTTP_PROXY: ""
user: h2o
Create a custom directory to store the default SSL options for all websites that use SSL.
sudo mkdir conf.d
Create a new ssl.conf
file.
sudo nano conf.d/ssl.conf
Copy and paste the text below into the ssl.conf
file.
cipher-preference: server
cipher-suite: ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
dh-file: /etc/ssl/h2o/dhparam_2048.pem
Make a directory to store the dhparam_2048.pem
file that will be regenerated daily via a cronjob.
sudo mkdir /etc/ssl/h2o/
Create a new regenerate_dhparam
file.
sudo nano /etc/cron.daily/regenerate_dhparam
Copy and paste the following text inside of the regenerate_dhparam
file.
#!/bin/bash
cd /etc/ssl/h2o
umask 022
for length in 2048
do
openssl dhparam -out dhparam_$length.tmp $length && mv dhparam_$length.tmp dhparam_$length.pem
chmod 444 dhparam_$length.pem
done
Make the bash file just created executable.
sudo chmod +x /etc/cron.daily/regenerate_dhparam
Execute the bash script for a first run as H2O won't start properly if it's not generated. This will take about a minute or two to generate on first run.
sudo /etc/cron.daily/regenerate_dhparam
In order to process PHP, the PHP-FPM 7.1 daemon must be installed and configured. In order to install a version of PHP-FPM newer than the default 5.4.x, the REMI repo must be installed which contains PHP versions 5.6.x, 7.0.x and 7.1.x. Type the following commands below to install PHP version 7.1.x.
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
sudo yum install php71-php-fpm -y
Navigate to the /etc/opt/remi/php71/
directory.
cd /etc/opt/remi/php71/
Rename the default php-fpm.conf
to php-fpm.conf.original
.
sudo mv php-fpm.conf php-fpm.conf.original
Create a new php-fpm.conf
file.
sudo nano php-fpm.conf
Copy and paste the text below into the php-fpm.conf
file.
include=/etc/opt/remi/php71/php-fpm.d/*.conf
[global]
daemonize = yes
emergency_restart_threshold = 2
emergency_restart_interval = 1m
error_log = /var/log/php-fpm/php-fpm-7.1-error.log
pid = /var/run/php-fpm-7.1.pid
process_control_timeout = 10s
Rename the default www.conf
file in the php-fpm.d
directory.
sudo mv php-fpm.d/www.conf php-fpm.d/www.conf.original
Create a new www.conf
file.
sudo nano php-fpm.d/www.conf
Copy and paste the following text into the www.conf
file. Change your pm.max\_children
to match the number of CPUs in accordance with your VPS instance.
[www]
group = h2o
listen = /var/run/php-fpm-7.1.sock
listen.backlog = 65536
listen.owner = h2o
listen.group = h2o
pm = static
pm.max_children = 2
pm.max_requests = 10240
user = h2o
Rename the default php.ini
file.
sudo mv php.ini php.ini.original
Create a new php.ini
file.
sudo nano php.ini
Copy and paste the following text below into the new php.ini file
. Change the memory\_limit
, post\_max\_size
, upload\_max\_filesize
and date.timezone
in accordance with your VPS instance.
[PHP]
allow_url_fopen = On
always_populate_raw_post_data = -1
display_errors = Off
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
expose_php = Off
log_errors = On
memory_limit = 256M
output_buffering = 4096
post_max_size = 64M
register_argc_argv = Off
request_order = "GP"
upload_max_filesize = 64M
variables_order = "GPCS"
[Date]
date.timezone = America/New_York
[Session]
session.cache_limiter =
session.gc_divisor = 1000
session.hash_bits_per_character = 5
session.save_handler = files
session.save_path = "/var/opt/remi/php71/lib/php/session/"
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
Change the group ownership for the /var/opt/remi/php71/lib/php/session/
directory from the apache
group to the h2o
group.
sudo chown root.h2o /var/opt/remi/php71/lib/php/session/
Create a directory where the PHP-FPM server logs will reside.
sudo mkdir /var/log/php-fpm/
Enable and start the PHP-FPM server.
sudo systemctl enable php71-php-fpm
sudo systemctl start php71-php-fpm
Enable and start the H2O server.
sudo systemctl enable h2o
sudo systemctl start h2o
Create a directory where the default index.php
will reside listed by the directory option file.dir
above in /var/www/example.com
.
sudo mkdir /var/www/example.com
Create a default index.php
using the phpinfo
command to test PHP.
sudo nano /var/www/example.com/index.php
Copy and paste the text below in the new index.php
file.
<?php
phpinfo();
?>
Now, open your browser and enter the server domain name (example.com
or www.example.com
) for your instance. Are you getting an Unable to connect
or a This site can’t be reached
message? CentOS's default firewall setting disallows incoming connections to the http port. Do the following to open it.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
Refresh the page in your browser (F5
) and you will get the standard PHP info page.
http://example.com
, http://www.example.com
, and https://example.com
to https://www.example.com
(Dynamic Page, PHP-FPM 7.1.x) ConfigurationNavigate to the /etc/h2o/
directory.
cd /etc/h2o/
Pervardykite numatytąjį h2o.conf
į h2o.conf.original
.
sudo mv h2o.conf h2o.conf.original
Sukurkite naują h2o.conf
failą.
sudo nano h2o.conf
Nukopijuokite ir įklijuokite žemiau esantį tekstą į h2o.conf
failą.
access-log: /var/log/h2o/access.log
compress: ON
error-log: /var/log/h2o/error.log
expires: 1 day
file.index: [ 'index.php' ]
hosts:
"example.com:80":
listen:
port: 80
paths:
"/":
redirect:
status: 301
url: "https://example.com/"
"www.example.com:80":
listen:
port: 80
paths:
"/":
redirect:
status: 301
url: "https://www.example.com/"
"example.com:443":
listen:
port: 443
ssl:
<<: !file /etc/h2o/conf.d/ssl.conf
certificate-file: /location/of/certificate/file/fullchain.ext
key-file: /location/of/private/key/file/privkey.ext
paths:
"/":
header.add: "strict-transport-security: max-age=31536000; includeSubDomains; preload"
redirect:
status: 301
url: "https://www.example.com/"
"www.example.com:443":
listen:
port: 443
ssl:
<<: !file /etc/h2o/conf.d/ssl.conf
certificate-file: /location/of/certificate/file/fullchain.ext
key-file: /location/of/private/key/file/privkey.ext
paths:
"/":
file.dir: /var/www/www.example.com
header.add: "strict-transport-security: max-age=31536000; includeSubDomains; preload"
redirect:
internal: YES
status: 307
url: /index.php
file.custom-handler:
extension: .php
fastcgi.connect:
port: /run/php-fpm-7.1.sock
type: unix
pid-file: /var/run/h2o/h2o.pid
send-server-name: OFF
setenv:
HTTP_PROXY: ""
user: h2o
Sukurkite tinkintą katalogą, kad išsaugotumėte numatytąsias SSL parinktis visoms svetainėms, kuriose naudojamas SSL.
sudo mkdir conf.d
Sukurkite naują ssl.conf
failą.
sudo nano conf.d/ssl.conf
Nukopijuokite ir įklijuokite žemiau esantį tekstą į ssl.conf
failą.
cipher-preference: server
cipher-suite: ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
dh-file: /etc/ssl/h2o/dhparam_2048.pem
Sukurkite katalogą, kuriame saugomas dhparam_2048.pem
failas, kuris bus atkuriamas kasdien naudojant cronjob.
sudo mkdir /etc/ssl/h2o/
Sukurkite naują regenerate_dhparam
failą.
sudo nano /etc/cron.daily/regenerate_dhparam
Nukopijuokite ir įklijuokite šį tekstą į regenerate_dhparam
failą.
#!/bin/bash
cd /etc/ssl/h2o
umask 022
for length in 2048
do
openssl dhparam -out dhparam_$length.tmp $length && mv dhparam_$length.tmp dhparam_$length.pem
chmod 444 dhparam_$length.pem
done
Padarykite ką tik sukurtą bash failą vykdomąjį.
sudo chmod +x /etc/cron.daily/regenerate_dhparam
Vykdykite bash scenarijų pirmą kartą, nes H2O nebus tinkamai paleistas, jei jis nebus sugeneruotas. Tai užtruks maždaug minutę ar dvi, kol bus sukurtas pirmą kartą.
sudo /etc/cron.daily/regenerate_dhparam
Norint apdoroti PHP, turi būti įdiegtas ir sukonfigūruotas PHP-FPM 7.1 demonas. Norint įdiegti naujesnę nei numatytoji 5.4.x PHP-FPM versiją, turi būti įdiegtas REMI repo, kuriame yra PHP 5.6.x, 7.0.x ir 7.1.x versijos. Įveskite šias komandas, kad įdiegtumėte PHP 7.1.x versiją.
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
sudo yum install php71-php-fpm -y
Eikite į /etc/opt/remi/php71/
katalogą.
cd /etc/opt/remi/php71/
Pervardykite numatytąjį php-fpm.conf
į php-fpm.conf.original
.
sudo mv php-fpm.conf php-fpm.conf.original
Sukurkite naują php-fpm.conf
failą.
sudo nano php-fpm.conf
Nukopijuokite ir įklijuokite šį tekstą į php-fpm.conf
failą.
include=/etc/opt/remi/php71/php-fpm.d/*.conf
[global]
daemonize = yes
emergency_restart_threshold = 2
emergency_restart_interval = 1m
error_log = /var/log/php-fpm/php-fpm-7.1-error.log
pid = /var/run/php-fpm-7.1.pid
process_control_timeout = 10s
Pervardykite numatytąjį www.conf
failą php-fpm.d
kataloge.
sudo mv php-fpm.d/www.conf php-fpm.d/www.conf.original
Sukurkite naują www.conf
failą.
sudo nano php-fpm.d/www.conf
Nukopijuokite ir įklijuokite žemiau esantį tekstą į www.conf
failą. Pakeiskite, pm.max\_children
kad atitiktų procesorių skaičių pagal jūsų VPS egzempliorių.
[www]
group = h2o
listen = /var/run/php-fpm-7.1.sock
listen.backlog = 65536
listen.owner = h2o
listen.group = h2o
pm = static
pm.max_children = 2
pm.max_requests = 10240
user = h2o
Pervardykite numatytąjį php.ini
failą.
sudo mv php.ini php.ini.original
Sukurkite naują php.ini
failą.
sudo nano php.ini
Nukopijuokite ir įklijuokite toliau pateiktą tekstą į naują php.ini file
. Pakeisti memory\_limit
, post\_max\_size
, upload\_max\_filesize
ir date.timezone
pagal savo VPS instancijos.
[PHP]
allow_url_fopen = On
always_populate_raw_post_data = -1
display_errors = Off
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
expose_php = Off
log_errors = On
memory_limit = 256M
output_buffering = 4096
post_max_size = 64M
register_argc_argv = Off
request_order = "GP"
upload_max_filesize = 64M
variables_order = "GPCS"
[Date]
date.timezone = America/New_York
[Session]
session.cache_limiter =
session.gc_divisor = 1000
session.hash_bits_per_character = 5
session.save_handler = files
session.save_path = "/var/opt/remi/php71/lib/php/session"
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
Pakeiskite /var/opt/remi/php71/lib/php/session/
katalogo grupės nuosavybės teisę iš apache
grupės į h2o
grupę.
sudo chown root.h2o /var/opt/remi/php71/lib/php/session/
Sukurkite katalogą, kuriame bus PHP-FPM serverio žurnalai.
sudo mkdir /var/log/php-fpm/
Įjunkite ir paleiskite PHP-FPM serverį.
sudo systemctl enable php71-php-fpm
sudo systemctl start php71-php-fpm
Įjunkite ir paleiskite H2O serverį.
sudo systemctl enable h2o
sudo systemctl start h2o
Sukurkite katalogą, kuriame index.php
bus numatytasis katalogas, file.dir
nurodytas aukščiau esančioje katalogo parinktyje /var/www/example.com
.
sudo mkdir /var/www/www.example.com
Sukurkite numatytąjį nustatymą index.php
naudodami phpinfo
komandą, kad patikrintumėte PHP.
sudo nano /var/www/www.example.com/index.php
Nukopijuokite ir įklijuokite toliau esantį tekstą į naują index.php
failą.
<?php
phpinfo();
?>
Dabar atidarykite naršyklę ir įveskite savo egzemplioriaus serverio domeno pavadinimą ( example.com
arba www.example.com
). Ar gaunate žinutę Unable to connect
ar This site can’t be reached
žinutę? Numatytasis CentOS ugniasienės nustatymas neleidžia prisijungti prie http prievado. Norėdami jį atidaryti, atlikite šiuos veiksmus.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
Atnaujinkite puslapį savo naršyklėje ( F5
) ir gausite standartinį PHP informacijos puslapį.
Tai baigia mano mokymo programą. Ačiū, kad skaitėte.
Naudojate kitą sistemą? Plesk yra patentuotas žiniatinklio prieglobos valdymo skydelis, leidžiantis vartotojams administruoti savo asmenines ir (arba) klientų svetaines, duomenų bazes
Squid yra populiari nemokama „Linux“ programa, leidžianti sukurti persiuntimo žiniatinklio tarpinį serverį. Šiame vadove pamatysite, kaip įdiegti „Squid“ „CentOS“, kad paverstumėte jus
Įvadas Lighttpd yra „Apache“ šakutė, skirta daug mažiau išteklių imti. Jis yra lengvas, todėl jo pavadinimas ir yra gana paprastas naudoti. Įdiegti
VULTR neseniai atliko pakeitimus, ir dabar viskas turėtų veikti gerai, kai įjungta „NetworkManager“. Jei norite išjungti
Icinga2 yra galinga stebėjimo sistema, o kai naudojama pagrindinio kliento modelyje, ji gali pakeisti NRPE pagrįstų stebėjimo patikrų poreikį. Meistras-klientas
Naudojate kitą sistemą? Apache Cassandra yra nemokama ir atviro kodo NoSQL duomenų bazių valdymo sistema, skirta užtikrinti mastelio keitimą, hig.
Naudojate kitą sistemą? Mattermost yra atvirojo kodo, savarankiškai priglobta alternatyva Slack SAAS pranešimų paslaugai. Kitaip tariant, naudodami Mattermost, jūs apytiksliai
„Plesk“ valdymo skydelyje yra labai graži „Lets Encrypt“ integracija. „Lets Encrypt“ yra vienas iš vienintelių SSL teikėjų, išduodančių visus sertifikatus
„Lets Encrypt“ yra sertifikatų institucija, skirta nemokamai teikti SSL sertifikatus. cPanel sukūrė tvarkingą integraciją, kad jūs ir jūsų klientas
Naudojate kitą sistemą? Concrete5 yra atvirojo kodo TVS, kuri siūlo daug išskirtinių ir naudingų funkcijų, padedančių redaktoriams lengvai sukurti turinį
Naudojate kitą sistemą? „Review Board“ yra nemokamas atvirojo kodo įrankis, skirtas šaltinio kodui, dokumentacijai, vaizdams ir daugeliui kitų peržiūrėti. Tai internetinė programinė įranga
Šiame vadove sužinosite, kaip nustatyti HTTP autentifikavimą Nginx žiniatinklio serveriui, kuriame veikia CentOS 7. Reikalavimai Norėdami pradėti, jums reikės
YOURLS (Your Own URL Shortener) yra atvirojo kodo URL sutrumpinimo ir duomenų analizės programa. Šiame straipsnyje apžvelgsime diegimo procesą
Naudojate kitą sistemą? Įvadas ArangoDB yra atvirojo kodo NoSQL duomenų bazė su lanksčiu duomenų modeliu dokumentams, grafikams ir raktų reikšmėms. tai yra
Įvadas Katalogas /etc/ vaidina lemiamą vaidmenį veikiant Linux sistemai. Taip yra todėl, kad beveik visos sistemos konfigūracijos
Daugelis sistemos administratorių valdo didelius serverių kiekius. Kai failus reikia pasiekti skirtinguose serveriuose, prisijungiant prie kiekvieno atskirai apytiksliai
Ši pamoka apims Half Life 2 žaidimų serverio diegimą CentOS 6 sistemoje. 1 veiksmas: būtinų sąlygų įdiegimas Norėdami nustatyti ou
Laravel GitScrum arba GitScrum yra atvirojo kodo produktyvumo įrankis, skirtas padėti kūrimo komandoms įgyvendinti Scrum metodiką panašiai
Įvadas Šiame „Vultr“ vadove sužinosite, kaip įdiegti „PowerDNS“. PowerDNS yra programa, skirta paleisti savo vardų serverius. Tai labai naudinga, kai
Galite nukopijuoti ir įklijuoti šį bash scenarijų į Vultr valdymo skydelio paleisties scenarijaus sritį. Jis įdiegs visus reikalingus paketus į ru
Dirbtinis intelektas nėra ateityje, jis čia, dabartyje Šiame tinklaraštyje Skaitykite, kaip dirbtinio intelekto programos paveikė įvairius sektorius.
Ar taip pat esate DDOS atakų auka ir esate sumišęs dėl prevencijos metodų? Perskaitykite šį straipsnį, kad išspręstumėte savo užklausas.
Galbūt girdėjote, kad įsilaužėliai uždirba daug pinigų, bet ar kada susimąstėte, kaip jie uždirba tokius pinigus? padiskutuokime.
Ar norite pamatyti revoliucinius „Google“ išradimus ir kaip šie išradimai pakeitė kiekvieno žmogaus gyvenimą šiandien? Tada skaitykite tinklaraštį, kad pamatytumėte „Google“ išradimus.
Savavaledžių automobilių koncepcija, kuri išvažiuotų į kelius su dirbtinio intelekto pagalba, yra svajonė, kurią jau kurį laiką svajojame. Tačiau nepaisant kelių pažadų, jų niekur nematyti. Skaitykite šį tinklaraštį, kad sužinotumėte daugiau…
Kadangi mokslas sparčiai vystosi, perimdamas daug mūsų pastangų, taip pat didėja rizika, kad pateksime į nepaaiškinamą singuliarumą. Skaitykite, ką mums gali reikšti išskirtinumas.
Duomenų saugojimo metodai gali būti tobulinami nuo pat Duomenų gimimo. Šiame tinklaraštyje, remiantis infografika, aprašoma duomenų saugojimo raida.
Skaitykite tinklaraštį, kad paprasčiausiai sužinotumėte apie skirtingus didžiųjų duomenų architektūros sluoksnius ir jų funkcijas.
Šiame skaitmeniniu būdu pagrįstame pasaulyje išmanieji namų įrenginiai tapo svarbia gyvenimo dalimi. Štai keletas nuostabių išmaniųjų namų įrenginių privalumų, kaip jie daro mūsų gyvenimą vertą gyventi ir paprastesnį.
Neseniai „Apple“ išleido „macOS Catalina 10.15.4“ priedą, skirtą problemoms išspręsti, tačiau atrodo, kad dėl atnaujinimo kyla daugiau problemų, dėl kurių „Mac“ įrenginiai blokuojami. Norėdami sužinoti daugiau, perskaitykite šį straipsnį