debian怎么配置静态ip地址
308
2022-10-20
树莓派中alpine容器的博客实现
在整篇文章中我的树莓派服务器ip地址为:10.1.30.87
参考文章:Docker从零构建php-nginx-alpine镜像的方法
地址:树莓派升级
# apt-get update
# 树莓派安装容器
curl -fsSL -o get-docker.sh
sudo sh get-docker.sh
查看容器版本
docker version
# 测试容器
然后运行hello world试试:
$ sudo docker run hello-world
出现:
Hello from Docker!
This message shows that your installation appears to be working correctly.
表示成功了!
从镜像到容器
下载“alpine”镜像
docker pull alpine
从“alpine”启动容器
容器命名为alpine-2201,同时开放ssh、web两个端口,且分别映射为2201、8081
docker run -itd --name alpine-2201 -p 2201:22 -p 8081:80 alpine-sshd
容器初始化
安装环境
apk add openrc openssh bash
安装openrc
openrc是Alpine服务控制器,负责Alpine服务启动,添加、删除、更新及启动停止等。安装它有助于将MySQL服务管理起来。
# apk add openrc --no-cache
安装完成后执行命令rc-status可以查看本地机上服务的当前状态
其他具体配置过程,暂时后补。
远程进入容器
ssh -p 2201 root@10.1.30.87
开始配置容器
安装nginx
apk add nginx
使nginx可启动
需要先创建pid文件,否则nginx运行不了
touch /run/nginx/nginxpidservice nginx start
测试:
安装php7
apk add php7
安装php扩展包
apk add php7-mysqli php7-pdo_mysql php7-mbstring php7-json php7-zlib php7-gd php7-intl php7-session php7-fpm php7-memcached
目录结构
php7目录: /etc/php7nginx目录: /etc/nginx
关闭nginx服务
关闭两次才能顺利关闭
service nginx stopservice nginx stop
其他命令
启动/usr/sbin/nginx停止/usr/sbin/nginx -s stop重新加载/usr/sbin/nginx -s reload
查看端口
netstat -nptl
初步运行服务
先运行php,再运行nginx
/usr/sbin/php-fpm7/usr/sbin/nginx
配置 php-fpm
# vi /etc/php7/php-fpm.d/conf暂时没必要修改
配置nginx网页目录
创建网页主目录为/mkdir /chmod -R 755 /修改配置文件# vi /etc/nginx/This is a default site configuration which will simply return 404, preventing# chance access to any other virtualhost.server { listen 80 default_server; listen [::]:80 default_server; Everything is a 404 location / { return 404; } # You may need this to prevent return 404 recursion. location = /404.html { internal; }}修改后内容:# This is a default site configuration which will simply return 404, preventing# chance access to any other virtualhost.server { listen 80 default_server; listen [::]:80 default_server; # Everything is a 404 #location / { # return 404; #} location / { root / index index.php index.html index.htm; } # You may need this to prevent return 404 recursion. location = /404.html { internal; }}
配置nginx的php支持
修改配置文件# vi /etc/nginx/This is a default site configuration which will simply return 404, preventing# chance access to any other virtualhost.server { listen 80 default_server; listen [::]:80 default_server; # Everything is a 404# location / {# return 404;# } location / { root / index index.php index.html index.htm; } location ~ \.php$ { root / fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi.conf; } # You may need this to prevent return 404 recursion. location = /404.html { internal; }}
测试主页
inedx.php 文件
/usr/sbin/nginx -s reloadecho '' > /mariadb mariadb-client
创建数据库
# /etc/init.d/mariadb setup输出如下内容: * Creating a new MySQL database ...Installing MariaDB/MySQL system tables in '/var/lib/mysql' ...OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemTwo all-privilege accounts were created.One is root@localhost, it has no password, but you need tobe system 'root' user to connect. Use, for example, sudo mysqlThe second is mysql@localhost, it has no password either, butyou need to be the system 'mysql' user to connect.After connecting you can set the password, if you would need to beable to connect as any of these users with a password and without sudoSee the MariaDB Knowledgebase at can start the MariaDB daemon with:cd '/usr' ; /usr/bin/mysqld_safe --datadir='/var/lib/mysql'You can test the MariaDB daemon with mysql-test-run.plcd '/usr/mysql-test' ; perl mysql-test-run.plPlease report any problems at latest information about MariaDB is available at joining MariaDB's strong and vibrant community: [ ok ]
启动mariadb
4beb45a6d1f2:~# service mariadb start * Caching service dependencies ...Service `hwdrivers' needs non existent service `dev'Service `machine-id' needs non existent service `dev' [ ok ] * Starting mariadb ...220421 03:16:57 mysqld_safe Logging to syslog.220421 03:16:57 mysqld_safe Starting mariadbd daemon with databases from /var/lib/mysql [ ok ]
配置mariadb
4beb45a6d1f2:~# mkdir -p /run/mysqld4beb45a6d1f2:~# chown -R mysql:mysql /run/mysqld4beb45a6d1f2:~# chown -R mysql:mysql /var/lib/mysql4beb45a6d1f2:~# mysql_install_db --user=mysql --ldata=/var/lib/mysql设置数据库管理员密码# mysqladmin -u root password "000000"
登录数据库
4beb45a6d1f2:~# mysql -u root -p000000Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 4Server version: 10.6.7-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]>
创建一个wordpress数据库
4beb45a6d1f2:~# mysql -uroot -p000000 -e"create database wordpress;show databases;"+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys || test || wordpress |+--------------------+4beb45a6d1f2:~#
配置wordpress
下载wordpress
4beb45a6d1f2:~# wget to cn.wordpress.org (198.143.164.252:443)saving to 'latest-zh_CN.tar.gz'latest-zh_CN.tar.gz 100% |**********************************| 18.5M 0:00:00 ETA'latest-zh_CN.tar.gz' saved4beb45a6d1f2:~#
剩下的操作
4beb45a6d1f2:~# tar zxvf latest-zh_CN.tar.gz 4beb45a6d1f2:~# mv wordpress/ /The base configuration for WordPress * * The wp-config.php creation script uses this file during the installation. * You don't have to use the web site, you can copy this file to "wp-config.php" * and fill in the values. * * This file contains the following configurations: * * * Database settings * * Secret keys * * Database table prefix * * ABSPATH * * @link * * @package WordPress */// ** Database settings - You can get this info from your web host ** ///** The name of the database for WordPress */define( 'DB_NAME', 'wordpress' );/** Database username */define( 'DB_USER', 'root' );/** Database password */define( 'DB_PASSWORD', '000000' );/** Database hostname */define( 'DB_HOST', 'localhost' );/** Database charset to use in creating database tables. */define( 'DB_CHARSET', 'utf8mb4' );/** The database collate type. Don't change this if in doubt. */define( 'DB_COLLATE', '' );/**#@+ * Authentication unique keys and salts. * * Change these to different unique phrases! You can generate these using * the {@link WordPress.org secret-key service}. * * You can change these at any point in time to invalidate all existing cookies. * This will force all users to have to log in again. * * @since 2.6.0 */define( 'AUTH_KEY', ';y>&-aE)g:_=.y %-2NT+PVj7|MQgRbRJqIh DaHpVfK>OK3diuy1.)nM3yvVPU&' );define( 'SECURE_AUTH_KEY', '6r)@]_NxYPeHQ;pxZIb1C^H?8gum~
对以上内容我进行了如下加工:
# cd /echo ''> wp-config.php# vi wp-config.php然后就是复制上面系统生成的“wp-config.php”的内容,然后继续
至此,全文完成。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~