玩客云armbian安装mariadb+nginx+php

canca8个月前 (09-24)Linux413

         本来想装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天,总算装好了!

相关文章

debian系统如何搭建 Samba服务器

debian系统如何搭建 Samba服务器

几乎所有的 Linux 发行版都提供了一个很好的工具 Samba来轻松实现文件共享。最近在Nanopi2 上安装了 debian 系统,然后准备搭建Samba 服务器来实现文件的共享,以下步骤仅供参考...

armbian修改为中文环境,解决中文乱码

step1:输入 dpkg-reconfigure locales选 zh_CN.UTF-8 ,空格打钩,tab 到确定按钮即可。第二个画面 选择默认语言,随便选,这一步主要是为了安装 zh_CN.U...

Debian更新系统时间

Debian更新时间A 更新源,并安装ntpdate:0.date 查看当前的系统时间1.sudo apt-get update 更新源2.sudo apt-get install...

Rsync自动同步工具

开机自启动 vi /etc/rc.local/usr/bin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf Linux(Debia...

armbian安装zerotier

#使用这行命令安装ZeroTier Onecurl -s https://install.zerotier.com/ | sudo bash复制下面代...

Debian 开机自动同步时间

简介之前写过 如何同步 Debian 服务器的时间,其中介绍了如何同步服务器的时间。但是有客户反映,这样做以后,服务器时间是同步了。但是服务器重启后时间还是错的。那么这篇文档将一劳永逸的解决...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。