Instalējiet Plesk operētājsistēmā CentOS 7
Vai izmantojat citu sistēmu? Plesk ir patentēts tīmekļa mitinātāja vadības panelis, kas ļauj lietotājiem administrēt savas personīgās un/vai klientu vietnes, datu bāzes
H2O ir jaunas paaudzes HTTP serveris, kuram ir lieliska, pilnībā aprīkota HTTP/2 ieviešana visiem pašreizējiem izmantotajiem tīmekļa serveriem. Izmantojot H2O kā savu tīmekļa serveri, varat izmantot jaunās HTTP/2 specifikācijas funkcijas, piemēram, latentuma optimizāciju, servera push un servera puses prioritāšu noteikšanu, kas var izmantot modernās pārlūkprogrammas funkcijas, par kurām reti tiek runāts.
Šajā detalizētajā apmācībā es jums soli pa solim parādīšu, kā H2O palaist jūsu CentOS 7 x64 instancē.
Piesakieties, izmantojot SSH, izmantojot akreditācijas datus, kas atrodami jūsu instancē, un atjauniniet sistēmu, kā norādīts tālāk.
sudo yum install epel-release -y
sudo yum clean all && sudo yum update -y
Lai instalētu H2O operētājsistēmā CentOS 7, jums jāpievieno Bintray RPM repozitorijs, lai instalētu iepriekš izveidotos H2O bināros failus. Izmantojiet Nano redaktoru, lai izveidotu pielāgotu repo.
sudo nano /etc/yum.repos.d/bintray-h2o-rpm.repo
Kopējiet un ielīmējiet tālāk esošo tekstu 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
Pēc tam instalējiet H2O.
sudo yum install h2o -y
Tagad, kad H2O ir instalēts, bet pirms pakalpojuma iespējošanas un palaišanas ir nepieciešama atbilstoša konfigurācija, un mums ir jāizveido konkrēts lietotājs un grupa, kurā H2O darboties. Izveidojiet grupu un lietotāju, lai H2O darbotos ar nosaukumu h2o
.
sudo groupadd -g 101 h2o
sudo useradd -d /etc/h2o -g 101 -M -s /sbin/nologin -u 101 h2o
Tālāk ir sniegti konfigurācijas iestatīšanas piemēri dažādiem unencrypted
, encrypted
, static
un dynamic
servera iestatījumiem; kā arī visu četru kombinācija.
http://www.example.com
uz http://example.com
(statiskām HTML lapām, bez PHP) konfigurācijuPārejiet uz /etc/h2o/
direktoriju.
cd /etc/h2o/
Pārdēvējiet noklusējuma vērtību h2o.conf
uz h2o.conf.original
.
sudo mv h2o.conf h2o.conf.original
Izveidojiet jaunu h2o.conf
failu.
sudo nano h2o.conf
Kopējiet un ielīmējiet tālāk norādīto tekstu 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
Iespējojiet un startējiet H2O serveri.
sudo systemctl enable h2o
sudo systemctl start h2o
Izveidot noklusējuma index.html
, izmantojot veidni /var/www/html
uz direktoriju iespēju file.dir
iepriekš uzskaitīti /var/www/example.com
.
sudo cp -var /var/www/html /var/www/example.com
Tagad atveriet pārlūkprogrammu un ievadiet servera domēna nosaukumu ( example.com
vai www.example.com
) savai instancei. Vai saņemat ziņojumu Unable to connect
vai This site can’t be reached
ziņojumu? CentOS noklusējuma ugunsmūra iestatījums neatļauj ienākošos savienojumus ar http portu. Lai to atvērtu, izpildiet tālāk norādītās darbības.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --reload
Atsvaidziniet lapu savā pārlūkprogrammā ( F5
), un jūs saņemsit šo ziņojumu.
Welcome to H2O - an optimized HTTP server
It works!
http://example.com
uz http://www.example.com
(statiskām HTML lapām, bez PHP) konfigurācijuPārejiet uz /etc/h2o/
direktoriju.
cd /etc/h2o/
Pārdēvējiet noklusējuma vērtību h2o.conf
uz h2o.conf.original
.
sudo mv h2o.conf h2o.conf.original
Izveidojiet jaunu h2o.conf
failu.
sudo nano h2o.conf
Kopējiet un ielīmējiet tālāk norādīto tekstu 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
Iespējojiet un startējiet H2O serveri.
sudo systemctl enable h2o
sudo systemctl start h2o
Izveidot noklusējuma index.html
failu, izmantojot veidni /var/www/html
uz direktoriju iespēju file.dir
iepriekš uzskaitīti /var/www/www.example.com
.
sudo cp -var /var/www/html /var/www/www.example.com
Tagad atveriet pārlūkprogrammu un ievadiet servera domēna nosaukumu ( example.com
vai www.example.com
) savai instancei. Vai saņemat ziņojumu Unable to connect
vai This site can’t be reached
ziņojumu? CentOS noklusējuma ugunsmūra iestatījums neatļauj ienākošos savienojumus ar http portu. Lai to atvērtu, veiciet tālāk norādītās darbības.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --reload
Atsvaidziniet lapu savā pārlūkprogrammā ( F5
), un jūs saņemsit šo ziņojumu.
Welcome to H2O - an optimized HTTP server
It works!
http://www.example.com
uz http://example.com
(dinamisko lapu, PHP-FPM 5.6.x) konfigurācijuPārejiet uz /etc/h2o/
direktoriju.
cd /etc/h2o/
Pārdēvējiet noklusējuma vērtību h2o.conf
uz h2o.conf.original
.
sudo mv h2o.conf h2o.conf.original
Izveidojiet jaunu h2o.conf
failu.
sudo nano h2o.conf
Kopējiet un ielīmējiet tālāk norādīto tekstu 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
Lai apstrādātu PHP, ir jāinstalē un jākonfigurē PHP-FPM 5.6 dēmons. Lai instalētu PHP-FPM versiju, kas ir jaunāka par noklusējuma 5.4.x, ir jāinstalē REMI repo, kas satur PHP versijas 5.6.x, 7.0.x un 7.1.x. Instalējiet PHP versiju 5.6.x.
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
sudo yum install php56-php-fpm -y
Pārejiet uz /opt/remi/php56/root/etc/
direktoriju.
cd /opt/remi/php56/root/etc/
Pārdēvējiet noklusējuma vērtību php-fpm.conf
uz php-fpm.conf.original
.
sudo mv php-fpm.conf php-fpm.conf.original
Izveidojiet jaunu php-fpm.conf
failu.
sudo nano php-fpm.conf
Kopējiet un ielīmējiet tālāk norādīto tekstu php-fpm.conf
failā.
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
Pārdēvējiet noklusējuma www.conf
failu php-fpm.d
direktorijā.
sudo mv php-fpm.d/www.conf php-fpm.d/www.conf.original
Izveidojiet jaunu www.conf
failu.
sudo nano php-fpm.d/www.conf
Kopējiet un ielīmējiet tālāk norādīto tekstu www.conf
failā. Mainiet savu, pm.max\_children
lai tas atbilstu CPU skaitam atbilstoši jūsu VPS instancei.
[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
Pārdēvējiet noklusējuma php.ini
failu.
sudo mv php.ini php.ini.original
Izveidojiet jaunu php.ini
failu.
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"
Mainiet /var/opt/remi/php71/lib/php/session/
direktorija grupas īpašumtiesības no apache
grupas uz h2o
grupu.
sudo chown root.h2o /var/opt/remi/php71/lib/php/session/
Izveidojiet direktoriju, kurā atradīsies PHP-FPM servera žurnāli.
sudo mkdir /var/log/php-fpm/
Iespējojiet un startējiet PHP-FPM serveri.
sudo systemctl enable php71-php-fpm
sudo systemctl start php71-php-fpm
Iespējojiet un startējiet H2O serveri.
sudo systemctl enable h2o
sudo systemctl start h2o
Izveidojiet direktoriju, kurā index.php
atradīsies noklusējuma direktorija, kas norādīta file.dir
iepriekš sadaļā /var/www/example.com
.
sudo mkdir /var/www/example.com
Izveidojiet noklusējuma iestatījumu, index.php
izmantojot phpinfo
komandu, lai pārbaudītu PHP.
sudo nano /var/www/example.com/index.php
Kopējiet un ielīmējiet tālāk esošo tekstu jaunajā index.php
failā.
<?php
phpinfo();
?>
Tagad atveriet pārlūkprogrammu un ievadiet servera domēna nosaukumu ( example.com
vai www.example.com
) savai instancei. Vai saņemat ziņojumu Unable to connect
vai This site can’t be reached
ziņojumu? CentOS noklusējuma ugunsmūra iestatījums neatļauj ienākošos savienojumus ar http portu. Lai to atvērtu, veiciet tālāk norādītās darbības.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
Atsvaidziniet lapu savā pārlūkprogrammā ( F5
), un jūs iegūsit standarta PHP informācijas lapu.
http://example.com
, http://www.example.com
, un https://example.com
uz https://www.example.com
(dinamisko lapu, PHP-FPM 7.1.x) konfigurācijuPārejiet uz /etc/h2o/
direktoriju.
cd /etc/h2o/
Pārdēvējiet noklusējuma vērtību h2o.conf
uz h2o.conf.original
.
sudo mv h2o.conf h2o.conf.original
Izveidojiet jaunu h2o.conf
failu.
sudo nano h2o.conf
Kopējiet un ielīmējiet tālāk norādīto tekstu 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
Izveidojiet pielāgotu direktoriju, lai saglabātu noklusējuma SSL opcijas visām vietnēm, kurās tiek izmantots SSL.
sudo mkdir conf.d
Izveidojiet jaunu ssl.conf
failu.
sudo nano conf.d/ssl.conf
Kopējiet un ielīmējiet tālāk norādīto tekstu 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
Izveidojiet direktoriju, lai saglabātu dhparam_2048.pem
failu, kas katru dienu tiks atjaunots, izmantojot cronjob.
sudo mkdir /etc/ssl/h2o/
Izveidojiet jaunu regenerate_dhparam
failu.
sudo nano /etc/cron.daily/regenerate_dhparam
Kopējiet un ielīmējiet tālāk norādīto tekstu 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
Padariet tikko izveidoto bash failu par izpildāmu.
sudo chmod +x /etc/cron.daily/regenerate_dhparam
Izpildiet bash skriptu pirmajai palaišanai, jo H2O nesāksies pareizi, ja tas netiks ģenerēts. Tas prasīs apmēram minūti vai divas, lai to ģenerētu pirmajā reizē.
sudo /etc/cron.daily/regenerate_dhparam
Lai apstrādātu PHP, ir jāinstalē un jākonfigurē PHP-FPM 7.1 dēmons. Lai instalētu PHP-FPM versiju, kas ir jaunāka par noklusējuma 5.4.x, ir jāinstalē REMI repo, kas satur PHP versijas 5.6.x, 7.0.x un 7.1.x. Ievadiet šīs komandas, lai instalētu PHP versiju 7.1.x.
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
sudo yum install php71-php-fpm -y
Pārejiet uz /etc/opt/remi/php71/
direktoriju.
cd /etc/opt/remi/php71/
Pārdēvējiet noklusējuma vērtību php-fpm.conf
uz php-fpm.conf.original
.
sudo mv php-fpm.conf php-fpm.conf.original
Izveidojiet jaunu php-fpm.conf
failu.
sudo nano php-fpm.conf
Kopējiet un ielīmējiet tālāk norādīto tekstu 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
Pārdēvējiet noklusējuma www.conf
failu php-fpm.d
direktorijā.
sudo mv php-fpm.d/www.conf php-fpm.d/www.conf.original
Izveidojiet jaunu www.conf
failu.
sudo nano php-fpm.d/www.conf
Kopējiet un ielīmējiet tālāk norādīto tekstu www.conf
failā. Mainiet savu, pm.max\_children
lai tas atbilstu CPU skaitam atbilstoši jūsu VPS instancei.
[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
Pārdēvējiet noklusējuma php.ini
failu.
sudo mv php.ini php.ini.original
Izveidojiet jaunu php.ini
failu.
sudo nano php.ini
Kopējiet un ielīmējiet tālāk esošo tekstu jaunajā php.ini file
. Mainīt memory\_limit
, post\_max\_size
, upload\_max\_filesize
un date.timezone
saskaņā ar savu VPS instancē.
[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"
Mainiet /var/opt/remi/php71/lib/php/session/
direktorija grupas īpašumtiesības no apache
grupas uz h2o
grupu.
sudo chown root.h2o /var/opt/remi/php71/lib/php/session/
Izveidojiet direktoriju, kurā atradīsies PHP-FPM servera žurnāli.
sudo mkdir /var/log/php-fpm/
Iespējojiet un startējiet PHP-FPM serveri.
sudo systemctl enable php71-php-fpm
sudo systemctl start php71-php-fpm
Iespējojiet un startējiet H2O serveri.
sudo systemctl enable h2o
sudo systemctl start h2o
Izveidojiet direktoriju, kurā index.php
atradīsies noklusējuma direktorija, kas norādīta file.dir
iepriekš sadaļā /var/www/example.com
.
sudo mkdir /var/www/www.example.com
Izveidojiet noklusējuma iestatījumu, index.php
izmantojot phpinfo
komandu, lai pārbaudītu PHP.
sudo nano /var/www/www.example.com/index.php
Kopējiet un ielīmējiet tālāk esošo tekstu jaunajā index.php
failā.
<?php
phpinfo();
?>
Tagad atveriet pārlūkprogrammu un ievadiet servera domēna nosaukumu ( example.com
vai www.example.com
) savai instancei. Vai saņemat ziņojumu Unable to connect
vai This site can’t be reached
ziņojumu? CentOS noklusējuma ugunsmūra iestatījums neatļauj ienākošos savienojumus ar http portu. Lai to atvērtu, veiciet tālāk norādītās darbības.
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
Atsvaidziniet lapu savā pārlūkprogrammā ( F5
), un jūs iegūsit standarta PHP informācijas lapu.
Ar to mana apmācība ir beigusies. Paldies, ka izlasījāt.
Vai izmantojat citu sistēmu? Plesk ir patentēts tīmekļa mitinātāja vadības panelis, kas ļauj lietotājiem administrēt savas personīgās un/vai klientu vietnes, datu bāzes
Squid ir populāra bezmaksas Linux programma, kas ļauj izveidot pāradresācijas tīmekļa starpniekserveri. Šajā rokasgrāmatā jūs redzēsit, kā instalēt Squid uz CentOS, lai jūs pārvērstu
Ievads Lighttpd ir Apache dakša, kuras mērķis ir daudz mazāk resursietilpīgs. Tas ir viegls, tāpēc arī tā nosaukums ir diezgan vienkārši lietojams. Instalēšana
VULTR nesen veica izmaiņas, un tagad visam vajadzētu darboties labi, ja ir iespējots NetworkManager. Ja vēlaties atspējot
Icinga2 ir spēcīga uzraudzības sistēma, un, ja to izmanto galvenā klienta modelī, tā var aizstāt vajadzību pēc NRPE balstītām uzraudzības pārbaudēm. Meistars-klients
Vai izmantojat citu sistēmu? Apache Cassandra ir bezmaksas un atvērtā koda NoSQL datu bāzes pārvaldības sistēma, kas ir izstrādāta, lai nodrošinātu mērogojamību, hig.
Vai izmantojat citu sistēmu? Microweber ir atvērtā koda vilkšanas un nomešanas CMS un tiešsaistes veikals. Microweber pirmkods tiek mitināts vietnē GitHub. Šī rokasgrāmata jums parādīs
Vai izmantojat citu sistēmu? Mattermost ir atvērtā pirmkoda, pašmitināta alternatīva Slack SAAS ziņojumapmaiņas pakalpojumam. Citiem vārdiem sakot, izmantojot Mattermost, jūs apm
Kas jums būs nepieciešams Vultr VPS ar vismaz 1 GB RAM. SSH piekļuve (ar root/administratora tiesībām). 1. darbība: BungeeCord instalēšana Vispirms vispirms
Plesk vadības panelī ir ļoti jauka Lets Encrypt integrācija. Lets Encrypt ir viens no vienīgajiem SSL nodrošinātājiem, kas pilnībā izsniedz sertifikātus
Lets Encrypt ir sertifikātu iestāde, kas nodrošina SSL sertifikātus bez maksas. cPanel ir izveidojis glītu integrāciju, lai jūs un jūsu klients
Vai izmantojat citu sistēmu? Concrete5 ir atvērtā pirmkoda CMS, kas piedāvā daudzas atšķirīgas un noderīgas funkcijas, lai palīdzētu redaktoriem viegli izveidot saturu.
Vai izmantojat citu sistēmu? Pārskatīšanas padome ir bezmaksas atvērtā pirmkoda rīks pirmkoda, dokumentācijas, attēlu un daudz ko citu pārskatīšanai. Tā ir tīmekļa programmatūra
Šajā rokasgrāmatā jūs uzzināsit, kā iestatīt HTTP autentifikāciju Nginx tīmekļa serverim, kas darbojas operētājsistēmā CentOS 7. Prasības Lai sāktu darbu, jums būs nepieciešams
YOURLS (Your Own URL Shortener) ir atvērtā koda URL saīsināšanas un datu analīzes lietojumprogramma. Šajā rakstā mēs apskatīsim instalēšanas procesu
Vai izmantojat citu sistēmu? Ievads ArangoDB ir atvērtā koda NoSQL datu bāze ar elastīgu datu modeli dokumentiem, grafikiem un atslēgu vērtībām. Tas ir
Ievads /etc/ direktorijam ir izšķiroša nozīme Linux sistēmas darbībā. Iemesls tam ir gandrīz visas sistēmas konfigurācijas
Daudzi sistēmu administratori pārvalda lielu daudzumu serveru. Ja failiem ir jāpiekļūst dažādos serveros, piesakieties katrā atsevišķi apm
Šajā apmācībā tiks apskatīts Half Life 2 spēļu servera instalēšanas process sistēmā CentOS 6. 1. darbība: priekšnosacījumu instalēšana Lai iestatītu ou
Laravel GitScrum jeb GitScrum ir atvērtā pirmkoda produktivitātes rīks, kas izstrādāts, lai palīdzētu izstrādātāju komandām ieviest Scrum metodoloģiju līdzīgā veidā.
Mākslīgais intelekts nav nākotnē, tas ir šeit, tagadnē. Šajā emuārā lasiet, kā mākslīgā intelekta lietojumprogrammas ir ietekmējušas dažādas nozares.
Vai arī jūs esat DDOS uzbrukumu upuris un esat neizpratnē par profilakses metodēm? Izlasiet šo rakstu, lai atrisinātu savus jautājumus.
Iespējams, esat dzirdējuši, ka hakeri pelna daudz naudas, bet vai esat kādreiz domājuši, kā viņi nopelna šādu naudu? pārrunāsim.
Vai vēlaties redzēt revolucionārus Google izgudrojumus un to, kā šie izgudrojumi mainīja katra cilvēka dzīvi mūsdienās? Pēc tam lasiet emuārā, lai redzētu Google izgudrojumus.
Pašpiedziņas automobiļu koncepcija izbraukt uz ceļiem ar mākslīgā intelekta palīdzību ir mūsu sapnis jau kādu laiku. Bet, neskatoties uz vairākiem solījumiem, tie nekur nav redzami. Lasiet šo emuāru, lai uzzinātu vairāk…
Zinātnei strauji attīstoties, pārņemot lielu daļu mūsu pūļu, palielinās arī risks pakļaut sevi neizskaidrojamai singularitātei. Izlasiet, ko singularitāte varētu nozīmēt mums.
Datu uzglabāšanas metodes ir attīstījušās kopš datu dzimšanas. Šajā emuārā ir aprakstīta datu uzglabāšanas attīstība, pamatojoties uz infografiku.
Lasiet emuāru, lai vienkāršākā veidā uzzinātu dažādus lielo datu arhitektūras slāņus un to funkcijas.
Šajā digitālajā pasaulē viedās mājas ierīces ir kļuvušas par būtisku dzīves sastāvdaļu. Šeit ir daži pārsteidzoši viedo mājas ierīču ieguvumi, lai padarītu mūsu dzīvi dzīves vērtu un vienkāršāku.
Nesen Apple izlaida macOS Catalina 10.15.4 papildinājuma atjauninājumu, lai novērstu problēmas, taču šķiet, ka atjauninājums rada vairāk problēmu, kas izraisa Mac datoru bloķēšanu. Izlasiet šo rakstu, lai uzzinātu vairāk