安装Nginx、MySQL和PHP7并配置

2020-01-03  本文已影响0人  whuangxm

安装Nginx、MySQL和PHP7

使用 apt-get install nginx php7.0 mysql-server 命令可以安装Nginx、MySQL和PHP7。

配置MySQL

mysql -h 127.0.0.1 -u root -p
mysql> CREATE DATABASE devcom;
mysql> CREATE USER dev;
mysql> GRANT ALL PRIVILEGES ON devcom.* TO 'dev'@'%' ;
mysql> SET PASSWORD FOR 'dev'@'%' = PASSWORD('mylittlesecret');
mysql> quit;

如果你的MySQL数据文件不是默认设置,需要修改/etc/mysql/mysql.cnf,应使用apparmor赋予权限。

如果外部无法连接MySQL提示10061错误,需要修改/etc/mysql/mysql.conf.d/mysqld.cnf,使得:

bind-address                = 0.0.0.0

如果查询时得到提示:[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

此时,可以修改在 /etc/my.cnf 文件里加上如下: sql_mode='NO_ENGINE_SUBSTITUTION'

Nginx使用ssl模块配置HTTPS支持

修改Nginx配置文件,让其包含新标记的证书和私钥:

server {
    server_name YOUR_DOMAINNAME_HERE;
    listen 443;
    ssl on;
    ssl_certificate /usr/local/nginx/conf/server.crt;
    ssl_certificate_key /usr/local/nginx/conf/server.key;
}

重启nginx。

上一篇下一篇

猜你喜欢

热点阅读