Ubuntu 安装 magento2

背景

年龄大了,记性不好,以前过目不忘,现在一天也记不住一个命令,所以想陆续把这几年学到的知识记录下来,以备忘。

安装前准备

一切安装说明如果不介绍版本,都是在瞎逼逼

Ubuntu:ubuntu-16.04.2-desktop-amd64.iso

Magento:Magento-CE-2.2.4_sample_data-2018-05-01-09-59-08.tar.bz2

开始

一、开启root登录

为何要开启root?节省后续各种权限不够,sudo的输入,懒人必备。

1、设置root密码:sudo passwd root

2、修改文件并保存:sudo gedit /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf

autologin-user=root

user-session=ubuntu

greeter-show-manual-login=true

如果开机出现错误,修改以下文件并重启:

gedit /root/.profile

将mesg n替换成tty -s && mesg n

注意以上操作仅限学习用。如果想真正建站,还需要在安全的权限下进行

二、替换源

由于国内墙限制,系统自带的源无法连接更新,所以要替换成国内的源。

gedit /etc/apt/source.list

把里面的内容删除,全部替换成以下内容:

# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted

deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted

deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties

deb http://mirrors.aliyun.com/ubuntu/ xenial universe

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe

deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse

deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties

deb http://archive.canonical.com/ubuntu xenial partner

deb-src http://archive.canonical.com/ubuntu xenial partner

deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties

deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe

deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

保存后,输入以下命令更新系统。

apt update

apt upgrade

三、安装apache2

1、安装:apt install apache2

2、编辑文件:gedit /etc/apache2/sites-available/000-default.conf

文件最后添加:

    AllowOverride ALL

3、重启服务:service apache2 restart

4、浏览器输入:http://127.0.0.1,有内容显示(It works!)表示安装成功。

四、安装php

1、apt install php7.0 libapache2-mod-php7.0 php7.0-common php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-curl php7.0-intl php7.0-xsl php7.0-mbstring php7.0-zip php7.0-bcmath php7.0-iconv php7.0-soap

2、php-v

3、service apache2 restart

五、安装mysql

1、apt install mysql-server mysql-client

2、mysql_secure_installation

3、mysql -u root -p

4、create database magento2_db;

5、GRANT ALL ON magento2_db.* TO magento@localhost IDENTIFIED BY 'magento';

6、flush privileges;

7、最后在终端输入:mysql -u magento -p,如果能进入表示安装和配置成功。

六、安装magento2

magento2 需要 apache2 启用 rewrite mod

终端运行命令:a2enmod rewrite

然后运行:service apache2 restart

1、把magento2压缩包解压到/var/www/html/magento2文件夹内

2、chown -R www-data.www-data /var/www/html/magento2

3、chmod -R 755 /var/www/html/magento2

4、浏览器输入:localhost/magento2/setup

按提示安装即可。

你可能感兴趣的:(Ubuntu 安装 magento2)