背景
年齡大了,記性不好卑笨,以前過目不忘孕暇,現(xiàn)在一天也記不住一個(gè)命令,所以想陸續(xù)把這幾年學(xué)到的知識(shí)記錄下來赤兴,以備忘芭商。
安裝前準(zhǔn)備
一切安裝說明如果不介紹版本,都是在瞎逼逼搀缠。
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?節(jié)省后續(xù)各種權(quán)限不夠艺普,sudo的輸入簸州,懶人必備鉴竭。
1、設(shè)置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
如果開機(jī)出現(xiàn)錯(cuò)誤搏存,修改以下文件并重啟:
gedit /root/.profile
將mesg n替換成tty -s && mesg n
注意以上操作僅限學(xué)習(xí)用。如果想真正建站矢洲,還需要在安全的權(quán)限下進(jìn)行璧眠。
二、替換源
由于國內(nèi)墻限制读虏,系統(tǒng)自帶的源無法連接更新责静,所以要替換成國內(nèi)的源。
gedit?/etc/apt/source.list
把里面的內(nèi)容刪除盖桥,全部替換成以下內(nèi)容:
# 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
保存后灾螃,輸入以下命令更新系統(tǒng)。
apt update
apt upgrade
三揩徊、安裝apache2
1腰鬼、安裝:apt install apache2
2、編輯文件:gedit /etc/apache2/sites-available/000-default.conf
文件最后添加:
<Directory "/var/www/html">
? ? AllowOverride ALL
</Directory>
3塑荒、重啟服務(wù):service apache2 restart
4熄赡、瀏覽器輸入:http://127.0.0.1,有內(nèi)容顯示(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,如果能進(jìn)入表示安裝和配置成功纫溃。
六腰涧、安裝magento2
magento2 需要 apache2 啟用 rewrite mod
終端運(yùn)行命令:a2enmod rewrite
然后運(yùn)行:service apache2 restart
1、把magento2壓縮包解壓到/var/www/html/magento2文件夾內(nèi)
2紊浩、chown -R www-data.www-data /var/www/html/magento2
3窖铡、chmod -R 755 /var/www/html/magento2
4疗锐、瀏覽器輸入:localhost/magento2/setup
按提示安裝即可。