玩客云armbian安装mariadb+nginx+php
本来想装Apache2的,无耐armbian死活没装到,以试着看的态度装nginx,没想到装上了,那算了,只好用nginx+php吧,现在记录一下遇过的坑,玩客云机器是armbian 11系统,更新源后,能装php7.4,nginx 1.18,apache2死活装不上,能装上的是apache2.4版本,mysql也是装不上,不支持arm系统,那只能安装mariadb了
1.安装mariadb
直接装吧
sudo apt update sudo apt install mariadb-server
装好后看版本
mariadb --version
现在运行以下命令来启动 MariaDB 并使其在系统重启时自动启动:
sudo systemctl start mariadb sudo systemctl enable mariadb
默认情况下,MariaDB 未加固。您可以使用mysql_secure_installation
脚本保护 MariaDB
mysql_secure_installation
现在可以使用新密码连接到 MariaDB 服务器
mysql -u root -p
2.安装nginx
直接装吧
apt update sudo apt install nginx
运气好的话,可以直接装好,运气不行的话用下面方式:
sudo apt install aptitude aptitude install nginx
3.安装php
直接装吧
sudo apt-get install php php-mysql php-mbstring php-gd php-xml
也是那句,运气好的话,可以直接装好,运行不行的话用下面方式:
aptitude install php php-mysql php-mbstring php-gd php-xml php7.4-fpm
zblog一定要装 php-xml,MD,搞了我半天!还有php7.4-fpm,开始装不上的,后来不知道为什么又能装了
装好的PHP,需要修改两处地方
nano /etc/php/7.4/cli/php.ini # ctrl+\ 定位 date.,找到date.timezone,修改如下: date.timezone = PRC # 修改日志显示,MD,就这里搞了我半天,一直白屏不知道什么错误,明明是开了日志就是不显示 display_errors = On
修改好后,看看nginx如何配置吧!
nginx 默认装到这里/etc/nginx/,先说说这个目录,下面有两个文件夹,需要关注的:
1、sites-available
2、sites-enabled
根据问文心一言得知,配置的网站配置先放sites-available上,哪些网站需要解释的,就软链到sites-enabled目录,如果不想解释某个网站就删除软链,感觉一点不好用。
#哪个网站要解释的话软链过去 ln -s /etc/nginx/sites-available/eolinker_os /etc/nginx/sites-enabled/
现在测试一下,直接修改sites-available下的Default配置,配置如下:
## # You should look at the following URL's in order to grasp a solid understanding # of Nginx configuration files in order to fully unleash the power of Nginx. # https://www.nginx.com/resources/wiki/start/ # https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/ # https://wiki.debian.org/Nginx/DirectoryStructure # # In most cases, administrators will remove this file from sites-enabled/ and # leave it as reference inside of sites-available where it will continue to be # updated by the nginx packaging team. # # This file will automatically load configuration files provided by other # applications, such as Drupal or Wordpress. These applications will be made # available underneath a path with that package name, such as /drupal8. # # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. ## # Default server configuration # server { listen 80 default_server; listen [::]:80 default_server; # SSL configuration # # listen 443 ssl default_server; # listen [::]:443 ssl default_server; # # Note: You should disable gzip for SSL traffic. # See: https://bugs.debian.org/773332 # # Read up on ssl_ciphers to ensure a secure configuration. # See: https://bugs.debian.org/765782 # # Self signed certs generated by the ssl-cert package # Don't use them in a production server! # # include snippets/snakeoil.conf; #这里不改了,直接用这里吧 root /var/www/html; # Add index.php to the list if you are using PHP index index.php index.html index.htm index.nginx-debian.html; server_name _; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } # pass PHP scripts to FastCGI server # 把下面这段配置打开 location ~ \.php$ { include snippets/fastcgi-php.conf; # With php-fpm (or other unix sockets): fastcgi_pass unix:/run/php/php7.4-fpm.sock; # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:9000; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # 这段打也打开吧, location ~ /\.ht { deny all; } } # Virtual Host configuration for example.com # # You can move that to a different file under sites-available/ and symlink that # to sites-enabled/ to enable it. # #server { # listen 80; # listen [::]:80; # # server_name example.com; # # root /var/www/example.com; # index index.html; # # location / { # try_files $uri $uri/ =404; # } #}
生成一个phpinfo.php文件到/var/www/html目录下,内容如下:
<?php phpinfo(); ?>
一切就绪了,然后重启nginx和php
systemctl restart nginx systemctl restart php7.4-fpm #测试一下是否OK curl http://localhost/phpinfo.php #正常会打印一堆HTML,那表示OK了
记录一下常用命令:
#卸载以php开头的软件包,不会删除配置文件 sudo apt remove php* #清除以php开头的软件包,包含配置文件 sudo apt purge php* #删除不再需要的软件包及其依赖项 sudo apt autoremove
这次从刷机到重装花了两天半,接近3天,总算装好了!