Install Nginx:
If Apache2 is already installed, then use these commands to remove and install Nginx first:
Service apache2 Stop
update-rc.d-f apache2 remove
apt-get Remove apache2
Ubuntu16.04 has Nginx installation package that we can install.
Apt-get-y Install nginx
service Nginx start
The document root for the default Nginx in Ubuntu16.04 is/var/www/html
Install PHP7:
Apt-get-y Install PHP7.0-FPM
Configure Nginx:
Open configuration file/etc/nginx/nginx.conf
First (this is optional) adjust keepalive_timeout to a reasonable value:
[...]
Keepalive_timeout 2;
[...]
Open the container definition/etc/nginx/sites-available/default
change as follows:
"'
server {
Listen default_server;
Listen [::]:80 default_server;
# SSL Configuration # # Listen 443 SSL default_server;
# Listen [::]:443 SSL Default_server;
# # Note:you should disable gzip for SSL traffic.
# see:https://bugs.debian.org/773332 # Read up in ssl_ciphers to ensure a secure configuration. # see:https://bugs.debian.org/765782 # Self signed certs generated by the Ssl-cert package # Don ' t use them in a pro
Duction server!
# # include snippets/snakeoil.conf;
root/var/www/html;
# ADD index.php to the ' list if you are using PHP index index.html index.htm index.nginx-debian.html;
server_name _;
Location/{# Attempt to serve request as file, then # as directory, then fall back to displaying a 404.
Try_files $uri $uri/= 404; # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ {include snippets/fastcgi
-php.conf;
# with php7.0-cgi alone: # Fastcgi_pass 127.0.0.1:9000;
# with Php7.0-fpm:fastcgi_pass Unix:/run/php/php7.0-fpm.sock; # Deny access to. htaccess files, if Apache ' s document Root # concurs with Nginx ' s one # location ~/\.ht {deny all;
}
}
SERVER_NAME: Make this a default catch for all virtual hosts (of course, you can also like here www.example.com specify host name).
root directory/var/www/html means the document root/var/www/html.
PHP is an important part of the location ~ \.php$ {} stanza. Uncomment it to enable it.
now save the file and reload the Nginx:
Service Nginx Reload
Open configuration file:/etc/php/7.0/fpm/php.ini
'
[...]
; Cgi.fix_pathinfo provides *real* path_info/path_translated Support for CGI. PHP ' s
; previous behaviour is to set path_translated to Script_filename, and to not grok; what Path_info is.
for more information on Path_info, the "the CGI specs." Setting this to
1 would cause PHP CGI to fix its paths to conform to the spec. A setting of
zero causes PHP to behave as before. Default is 1. You are should fix your scripts to use
script_filename rather than path_translated.
; http://php.net/cgi.fix-path Info
cgi.fix_pathinfo=0
[...]
' Reboot
php7:service php7.0-fpm Reload
# install MySQL:
install mysql Run command:
Apt-get-y Install Mysql-server mysql-client
You will be asked to provide the MySQL root user password:
set MySQL security:
mysql_secure_installation
let MySQL get php 7 support
first search PHP supported modules:
Apt-cache Search php7.0
is installed using the following command:
Apt-get-y Install php7.0-mysql php7.0-curl php7.0-gd php7.0-intl php-pear php-imagick php7.0-imap php7.0-mcrypt PHP-MEMC Ache Php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc php7.0-xsl php7.0-mbstring php-gettext
APCU is an extension of the PHP7 PHP Opcache module, which adds some compatibility features to support APC caching (such as WordPress's plug-in cache) software.
APCU can be installed as follows:
apt-get-y install PHP-APCU
Reload php-fpm:
service php7.0-fpm Reload
# uninstall MySQL
sudo deluser MySQL
sudo delgroup MySQL
Sudo service mysql stop #or mysqld
sudo killall-9 mysql
sudo killall-9 mysqld
sudo apt-get Remove–pur GE mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo deluser mysql
sudo rm-rf/var/lib/mysql
sudo apt-get purge mysql-server-core-5.5
sudo apt-get purge mysql-client-core-5 .5
sudo rm-rf/var/log/mysql
sudo rm-rf/etc/mysql
"'