先更新源
apt-get update
安装 MySQL5.7 运行命令:
apt-get -y install mysql-server mysql-client
安装期间要求设置MySQL的root用户密码 :
New password for the MySQL “root” user: <– yourrootsqlpassword
Repeat password for the MySQL “root” user: <– yourrootsqlpassword
myql命令
service mysqld stop
service mysql restart
增加操作用户
GRANT ALL ON *.* TO test@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
安装 Nginx
如果你已经安装了Apache2的话,那么使用这些命令先删除再安装nginx:
service apache2 stop
update-rc.d -f apache2 remove
apt-get remove apache2
Ubuntu16.04有Nginx安装包,我们可以安装。
apt-get -y install nginx
启动ngninx:
service nginx start
输入您的Web服务器的IP地址或主机名到浏览器(例如120.132.114.131),你应该
Ubuntu16.04的默认nginx的文档根目录为/var/www/html
安装 PHP 7
apt-get -y install php7.0-fpm
配置 nginx
打开配置文件 /etc/nginx/nginx.conf:
vi /etc/nginx/nginx.conf
配置很容易理解 (你可以点击官方教程: http://wiki.nginx.org/NginxFullExample或:http://wiki.nginx.org/NginxFullExample2)
首先(这是可选)调整keepalive_timeout到一个合理的值:
[...]
keepalive_timeout 2;
[...]
虚拟主机服务器{}容器定义。默认的虚拟主机是在/etc/nginx/sites-available/default 文件中定义- 修改它,如下所示:
vi /etc/nginx/sites-available/default
[...]
server {
listen 80 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 on 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 production 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 / {
# First 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;
}
}
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting
; this to 1 will 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 should fix your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
; http://php.net/cgi.fix-pathinfo
cgi.fix_pathinfo=0