1.安装Nginx
sudo apt-get install nginx
查看nginx
pstree |grep nginx
ps正在处理用于 systemd (237-3ubuntu10.33) 的触发器 ...
ysq@ysq-VirtualBox:~$ pstree |grep nginx
|-nginx---nginx
查看ip输入ifconfig,需要安装net-tools
ysq@ysq-VirtualBox:~$ ifconfig
Command 'ifconfig' not found, but can be installed with:
sudo apt install net-tools
执行安装 net-tools
重新启动Nginx服务:
sudo systemctl restart nginx
启动Nginx服务:
sudo systemctl start nginx
停止nginx服务:
sudo systemctl stop nginx
2.安装php
完全支持并建议将PHP 7.2(这是Ubuntu 18.04中的默认PHP版本)用于Magento 2.3。由于我们将Nginx用作Web服务器,因此我们还将安装PHP-FPM软件包。
运行以下命令以安装PHP和所有必需的PHP模块:
sudo apt install php7.2-common php7.2-cli php7.2-fpm php7.2-opcache php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-xsl php7.2-mbstring php7.2-zip php7.2-bcmath php7.2-soap
安装完成之后安装vim
sudo apt install vim
然后编辑 php.ini文件
vim /etc/php/7.2/cli/php.ini
memory_limit = 2G //单线程内存使用量
max_execution_time = 1800 、、最大执行时间
zlib.output_compression = On //打开压缩模式
memory_limit = 2G
max_execution_time = 1800
zlib.output_compression = On
修改保存,然后重新启动php
systemctl restart php7.2-fpm
3 .安装Mysql
如果您的服务器上安装了MySQL或MariaDB,则可以跳过此步骤;如果没有,则可以通过键入以下内容从Ubuntu的默认存储库中安装MySQL 5.7服务器软件包:
sudo apt install mysql-server mysql-client
启动mysql
sudo service mysql start
- 用户:root
- 密码:root123
登录mysql
sudo mysql
创建数据库
create database magento_shoes;
创建用户
create user magento_shoes IDENTIFIED BY 'mgtshow123!@#';
授予数据库用户权限
GRANT ALL ON shoes.* TO 'magento_shoes'@'localhost' IDENTIFIED BY 'mgtshow123!@#';
3. 安装和配置PHP
完全支持并建议将PHP 7.2(这是Ubuntu 18.04中的默认PHP版本)用于Magento 2.3。由于我们将Nginx用作Web服务器,因此我们还将安装PHP-FPM软件包。
运行以下命令以安装PHP和所有必需的PHP模块:
sudo apt install php7.2-common php7.2-cli php7.2-fpm php7.2-opcache php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-xsl php7.2-mbstring php7.2-zip php7.2-bcmath php7.2-soap
PHP-FPM服务将在安装过程完成后自动启动,您可以通过打印服务状态来进行验证:
sudo systemctl status php7.2-fpm
输出应指示fpm服务处于活动状态并且正在运行。
ysq@ysq-VirtualBox:/var/run/php$ sudo systemctl status php7.2-fpm
● php7.2-fpm.service - The PHP 7.2 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.2-fpm.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Fri 2020-05-08 08:55:13 EDT; 14min ago
Docs: man:php-fpm7.2(8)
Process: 594 ExecStart=/usr/sbin/php-fpm7.2 --nodaemonize --fpm-config /etc/php/7.2/fpm/php-fpm.conf (code=exited, status=0/SUCCESS)
Main PID: 594 (code=exited, status=0/SUCCESS)
Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
May 08 05:53:52 ysq-VirtualBox systemd[1]: Starting The PHP 7.2 FastCGI Process Manager...
May 08 05:53:52 ysq-VirtualBox systemd[1]: Started The PHP 7.2 FastCGI Process Manager.
ysq@ysq-VirtualBox:/var/run/php$ ls -al
total 4
drwxr-xr-x 2 www-data www-data 80 May 8 08:58 .
drwxr-xr-x 28 root root 860 May 8 08:27 ..
-rw-r--r-- 1 root root 4 May 8 08:58 php7.2-fpm.pid
srw-rw---- 1 www-data www-data 0 May 8 08:58 php7.2-fpm.sock
ysq@ysq-VirtualBox:/var/run/php$
4 使用以下命令登录到MySQL Shell:
sudo mysql
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database shoes;
Query OK, 1 row affected (0.00 sec)
mysql>
接下来,创建一个名为MySQL的用户帐户,magento
并通过运行以下命令向该用户授予必要的权限:
设置目录权限:
chmod -R 777 /var/www/html
创建magento文件夹,拷贝文件到magento
进入到网站的根目录,设置目录权限:
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
chown -R :www-data . # Ubuntu
chmod u+x bin/magento
操作完之后。修改nginx的配置文件
sudo vim magento.conf
添加内容为:
# /etc/nginx/sites-available/magento
upstream fastcgi_backend {
server unix:/run/php/php7.2-fpm.sock;
}
server {
listen 80;
server_name 192.168.33.10;
set $MAGE_ROOT /var/www/html/magento2ce;
include /var/www/html/magento2ce/nginx.conf.sample;
}
检查配置安全,然后重新加载nginx
ysq@ysq-VirtualBox:/etc/nginx/conf.d$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
ysq@ysq-VirtualBox:/etc/nginx/conf.d$ sudo nginx -s reload
ysq@ysq-VirtualBox:/etc/nginx/conf.d$
然后打开浏览器执行安装
设置模式:
命令:
sudo chmod -R 777 ./var/*
然后再
sudo php bin/magento deploy:mode:set developer
编译升级
sudo php bin/magento setup:upgrade
sudo php bin/magento setup:static-content:deploy -f