Postfix+Dovecot+Roundcube开源邮件系统搭建系列5:Roundcube安装配置(含Nginx+PHP部署配置)
# 更新系统
sudo apt-update
sudo apt-upgrade -y
# 安装Nginx
sudo apt-get install -y nginx
# 安装PHP及常用扩展
sudo apt-get install -y php-fpm php-mysql php-imap php-json
# 安装Roundcubemail
sudo apt-get install -y roundcubemail
# 配置Nginx为Roundcube代理
echo "
server {
listen 80;
server_name roundcube.example.com;
root /usr/share/roundcubemail;
index index.php;
location / {
try_files \$uri \$uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\. {
deny all;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
}
" | sudo tee /etc/nginx/sites-available/roundcube.conf
sudo ln -s /etc/nginx/sites-available/roundcube.conf /etc/nginx/sites-enabled/
# 重启Nginx
sudo systemctl restart nginx
# 配置Roundcube
sudo roundcubemail-setup
# 测试配置是否正确
sudo nginx -t
# 重启Nginx和PHP-FPM
sudo systemctl restart nginx php7.4-fpm
在这个代码实例中,我们首先更新了系统,然后安装了Nginx和PHP及其必要的扩展。接着安装了Roundcubemail,并配置了Nginx以便代理Roundcube的请求。最后,我们运行了Roundcube的设置向导,检查配置文件的正确性,并重启了Nginx和PHP-FPM服务以应用更改。
评论已关闭