Debian10手动安装LNMP教程软件LinuxServer

印迹发布于:2019-12-1 1048

分享Debian10手动安装LNMP的教程。没比面板复杂,安装速度有质的飞跃。

安装流程:

先升级系统组件到最新:

apt update && apt dist-upgrade

安装常用组件:

apt install cron rsync openssl xinetd haveged sshguard lsb-release ca-certificates apt-transport-https

创建/www目录:

mkdir /www

安装Nginx:

apt install nginx
service nginx start

假如我有abc.com,用SFTP建立网站配置/etc/nginx/conf.d/abc.conf:

server {
        listen 80;
        server_name abc.com www.abc.com;
        index index.html index.htm index.php;
        root /www/abc;
        if ($scheme != https) { //强制HTTPS
                rewrite ^/(.*) https://$server_name/$1 permanent;
        }
        location ~* \.php$ {
                include fastcgi_params;
                fastcgi_pass unix:/var/php.sock;
                fastcgi_param SCRIPT_FILENAME $request_filename;
                fastcgi_param PHP_VALUE "open_basedir=$document_root:/tmp/:/proc/";
        }
}

配置完重启Nginx:

service nginx restart

安装SSL申请系统:

wget https://dl.eff.org/certbot-auto --no-check-certificate && chmod a+x certbot-auto

按提示输入需要证书的域名,安装证书:

./certbot-auto --nginx --no-redirect

编辑计划任务,定时续期SSL:

crontab -e

计划任务这里需要使用nano编辑器,粘贴此命令到文件底部,按Ctrl+X退出并选择保存。

0 1 * * * /root/certbot-auto renew --post-hook "service nginx reload"

安装最新版PHP,数据库自行选择用sqlite还是mysql:

apt install php-fpm php-xml php-opcache php-mbstring php-gd
apt install php-sqlite3
apt install php-mysql

建立快捷方式,等PHP7.4有了以后,升级PHP并重新关联php7.4-fpm.sock就行:

ln -s /run/php/php7.3-fpm.sock /var/php.sock
service php*-fpm start

安装MariaDB,不用MySQL的可以跳过了:

apt install mariadb-server
service mariadb start

启动MariaDB配置向导,跟着向导走就行,配置root密码:

mysql_secure_installation

建立数据库(比如abc):

CREATE DATABASE `abc` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

建立数据库用户(比如abc,密码123):

CREATE USER 'abc'@'localhost' IDENTIFIED BY '123';

把用户授权到数据库:

GRANT ALL ON abc.* TO 'abc'@'localhost';

之后就可以用(用户abc,密码123)登录数据库abc了。


http://www.virplus.com/thread-378.htm
转载请注明:2019-12-1 于 VirPlus 发表

推荐阅读
最新回复 (0)

    ( 登录 ) 后,可以发表评论!

    返回