禁用sendmail: sysrc sendmail_enable="NONE" sysrc sendmail_submit_enable="NO" sysrc sendmail_outbound_enable="NO" sysrc sendmail_msp_queue_enable="NO"
先简单搜索显示MariaDB的多个版本
pkg search mariadb
安装mariadb
pkg install mariadb103-server-10.3.23 mariadb103-client-10.3.23
配置mariadb
首先改变 mysql数据存储目录为/www/mysql/data/这个目录
/usr/local/bin/mysql_install_db --datadir=/www/mysql/data --user=mysql
将 mysql加入开机启动
sysrc mysql_enable=YES sysrc mysql_dbdir=/www/mysql/data
vi /usr/local/etc/my.cnf
编辑 MYSQL 的优化文件
[mysqld] bind-address = :: port = 3306 socket = /tmp/mysql.sock datadir = /www/mysql/data #skip-innodb default_storage_engine = InnoDB #skip-name-resolve max_connections = 1000 max_connect_errors = 100 open_files_limit = 65535 binlog_cache_size = 64K thread_stack = 256K join_buffer_size = 1024K query_cache_type = 1 max_heap_table_size = 64M #skip-external-locking key_buffer_size = 8M max_allowed_packet = 1G table_open_cache = 32 sort_buffer_size = 256K net_buffer_length = 4K read_buffer_size = 128K read_rnd_buffer_size = 256K myisam_sort_buffer_size = 4M thread_cache_size = 4 query_cache_size = 4M tmp_table_size = 8M innodb_data_home_dir = /www/mysql/data innodb_data_file_path = ibdata1:10M:autoextend innodb_log_group_home_dir = /www/mysql/data innodb_buffer_pool_size = 384M innodb_log_file_size = 256M innodb_log_buffer_size = 128M innodb_flush_log_at_trx_commit = 1 innodb_lock_wait_timeout = 50 innodb_max_dirty_pages_pct = 90 innodb_read_io_threads = 1 innodb_write_io_threads = 1 log_error = /var/log/mysql/error.log expire_logs_days = 1 max_binlog_size = 100M character-set-server = utf8 collation-server = utf8_general_ci
把上面的参数保存
sysrc mysql_pidfile=/var/db/mysql/mysql.pid sysrc mysql_optfile=/usr/local/etc/my.cnf
启动 mysql
service mysql-server start
下面需要通过运行mysql_secure_installation脚本来保护MariaDB数据库。 在运行脚本时,会问一系列问题。所有问题上回答“ Y ”
/usr/local/bin/mysql_secure_installation
强制mysql网络套接字绑定到回送接口。这样是为了安全不允许远程登录 mysql数据库。只支持服务器本地登录。
sysrc mysql_args="--bind-address=127.0.0.1"
安装nginx
pkg search nginx pkg install nginx-1.16.1_12,2
配置nginx
sysrc nginx_enable=yes mkdir -p /usr/local/etc/nginx/vhost/ mkdir -p /www/logs mkdir -p /www/wwwroot cp /usr/local/etc/nginx/nginx.conf /usr/local/etc/nginx/nginx.conf.bak cp /usr/local/etc/nginx/fastcgi_params /usr/local/etc/nginx/fastcgi_params.default service nginx restart
安装PHP7.4
pkg install unzip php74 php74-bz2 php74-pdo_mysql php74-pdo php74-simplexml php74-calendar php74-curl php74-dba php74-exif php74-gd php74-gettext php74-iconv php74-imap php74-json php74-mbstring php74-mysqli php74-odbc php74-opcache php74-openssl php74-pspell php74-readline php74-session php74-sockets php74-sqlite3 php74-tidy php74-xml php74-xmlrpc php74-xsl php74-zip php74-zlib php74-filter php74-fileinfo
配置PHP7.4
sysrc php_fpm_enable=yes cp /usr/local/etc/php-fpm.d/www.conf /usr/local/etc/php-fpm.d/www.conf.bak cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
vi /usr/local/etc/php-fpm.d/www.conf
user = www group = www listen = /tmp/php7.4-fpm.sock 修改上面这些 下面这三个把文档默认的注释;去掉即可 listen.owner = www listen.group = www listen.mode = 0660 然后在文档最后添加下面的参数 php_admin_value[open_basedir] = /usr/local/www/phpMyAdmin:/tmp:/www/wwwroot php_admin_value[upload_max_filesize] = 50M php_admin_value[max_execution_time] = 60 php_admin_value[max_input_time] = 60 php_admin_value[memory_limit] = 256M php_admin_value[output_buffering] = 4096 php_admin_value[disable_functions] = system,exec,shell_exec,passthru,error_log,dl,sys_getloadavg,pfsockopen,openlog,syslog,readlink,symlink,link,leak,popen,escapeshellcmd,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,escapeshellarg,pcntl_exec,show_source,highlight_file,ini_restore,apache_child_terminate,apache_get_modules,apache_get_version,apache_getenv,apache_note,apache_setenv,virtual,mb_send_mail,set_time_limit,max_execution_time,php_uname,disk_free_space,diskfreespace,stream_copy_to_stream php_admin_flag[allow_url_fopen] = off php_admin_flag[expose_php] = Off php_admin_flag[display_errors] = Off pm = dynamic pm.max_children = 5 pm.start_servers = 1 pm.min_spare_servers = 1 pm.max_spare_servers = 2 chdir = /
保存退出
php-fpm -t
可以用这个命令测试一下参数配置是否有问题
service php-fpm restart
安装phpMyAdmin
pkg search phpMyAdmin pkg install phpMyAdmin-php74-4.9.5
配置phpmyadmin使起可以访问
vi /usr/local/etc/nginx/nginx.conf
在最后一个添加一个站点
server { listen 80; server_name phpmyadmin.qmun.com; access_log /var/log/nginx/phpmyadmin-access.log; error_log /var/log/nginx/phpmyadmin-error.log; location / { root /usr/local/www/phpMyAdmin; index index.php; } location ~ \.php$ { root /usr/local/www/phpMyAdmin; fastcgi_pass unix:/tmp/php7.4-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; }
安装 certbot已搭配nginx证书使用
pkg search certbot pkg install py37-certbot-nginx certbot --nginx -d blog.qmun.com 这里的blog.qmun.com可以改成你自己的域名。获取自己域名的免费SSL证书