一、安装配置mysql
# apt-get update
# apt-get install mysql-server //输入两次以设置mysql的root密码 ubuntu默认安装最新版本
# sudo mysql_install_db
# sudo mysql_secure_installation //输入root密码,后续操作按一直 Enter 即可
如果要开启mysql可本地远程连接的话,执行以下几条命令:
# vi /etc/mysql/mysql.conf.d/mysqld.cnf //编辑找到 bind-address 设置其值为 0.0.0.0 然后保存 (或者注释该行也行)
# mysql -u root -p
# use mysql; //切换到mysql数据库
#GRANT ALL PRIVILEGES ON . TO 'root'@'%'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
# FLUSH PRIVILEGES;
# exit;
# service mysql restart //重启mysql
注意:要想mysql能够远程连接,要去阿里云配置一下安全组才能生效
二、安装Nginx
Ubuntu16.04有Nginx安装包,我们可以安装。
# apt-get -y install nginx
三、安装 PHP 7
# apt-get -y install php7.0-fpm
四、配置nginx
# sudo nano /etc/nginx/sites-available/default
server {
listen 80 default_server;
index index.php index.html index.htm;
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
# service nginx restart //重启nginx
开启端口:
五、上传代码
六、测试网站