AlpineLinux下安装Nginx、PHP-fpm、Mariadb

安装Nginx

安装

apk add nginx

创建用户及网站路径

adduser -g 'Nginx www user' -h /home/www/ webmaster

配置Nginx

vim /etc/nginx/httpd.d/defaut
server {

    listen 80 default_server;
    listen [::]:80 default_server;
    root /home/www;
    # Everything is a 404
    location / {
            return 404;
    }

    # You may need this to prevent return 404 recursion.
    location = /404.html {
            internal;
    }
    location ~ \.php$ {
          fastcgi_pass      127.0.0.1:9000;
          fastcgi_index     index.php;
          include           fastcgi.conf;
}

}

启动Nginx,并加入系统

rc-service nginx start
rc-update add nginx default

安装Php

安装

apk add php7 php7-fpm php7-opcache

安装库

apk add php7-mysqli php7-mbstring php7-json php7-zlib php7-gd php7-intl php7-session

启动PHP,并加入系统

rc-service php-fpm7 start
rc-update add php-fpm7 default

安装Mariadb

安装

apk add mariadb mariadb-common mariadb-client

初始化

/etc/init.d/mariadb setup
/etc/init.d/mariadb start
mysql_secure_installation

启动Mariadb,并加入系统

rc-service mariadb restart
rc-update add mariadb default

AlpineLinux下,默认的sshd_config中AllowTcpForwarding设置为no,这样mysql等无法通过SSH tunnel访问,需要设为yes。

添加新评论