Last active
May 16, 2024 05:27
-
-
Save amanjuman/6bcdbc328a4f9a7c03f6cb139b560915 to your computer and use it in GitHub Desktop.
Install Sendy on LAMP with No Error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Update and Upgrade Repos | |
sudo su | |
sudo apt update -y && sudo apt upgrade -y && sudo apt dist-upgrade -y && sudo apt autoremove -y | |
## Setup SWAP | |
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 | |
sudo /sbin/mkswap /var/swap.1 | |
sudo /sbin/swapon /var/swap.1 | |
sudo sh -c 'echo "/var/swap.1 swap swap defaults 0 0 " >> /etc/fstab' | |
## Setup Hostname | |
sudo hostnamectl set-hostname subdomain.domain.tld | |
## Install Dependence | |
sudo add-apt-repository ppa:ondrej/php -y | |
sudo apt install -y apache2 libapache2-mod-php8.1 mariadb-server php8.1-{bcmath,bz2,curl,fpm,intl,gd,mbstring,mysql,xml,zip} software-properties-common python3-certbot-apache unzip zip | |
## Tweak PHP ini | |
sudo sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php/8.1/fpm/php.ini && \ | |
sudo sed -i 's/max_execution_time = 30/max_execution_time = 120/g' /etc/php/8.1/fpm/php.ini && \ | |
sudo sed -i 's/memory_limit = 128M/memory_limit = 512M/g' /etc/php/8.1/fpm/php.ini && \ | |
sudo sed -i 's/post_max_size = 8M/post_max_size = 1024M/g' /etc/php/8.1/fpm/php.ini && \ | |
sudo sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 512M/g' /etc/php/8.1/fpm/php.ini && \ | |
sudo sed -i 's/max_input_time = 60/max_input_time = 120/g' /etc/php/8.1/fpm/php.ini && \ | |
sudo sed -i 's/max_input_vars = 1000/max_input_vars = 5000/g' /etc/php/8.1/fpm/php.ini && \ | |
sudo sed -i 's/short_open_tag = Off/short_open_tag = On/g' /etc/php/8.1/fpm/php.ini && \ | |
sudo sed -i 's/zlib.output_compression = Off/zlib.output_compression = On/g' /etc/php/8.1/fpm/php.ini && \ | |
sudo sed -i 's/;opcache.enable=1/opcache.enable=1/g' /etc/php/8.1/fpm/php.ini && \ | |
sudo sed -i 's/;opcache.save_comments=1/opcache.save_comments=1/g' /etc/php/8.1/fpm/php.ini && \ | |
sudo sed -i 's/session.gc_maxlifetime = 1440/session.gc_maxlifetime = 7200/g' /etc/php/8.1/fpm/php.ini && \ | |
sudo sed -i 's/;date.timezone.*/date.timezone = UTC/' /etc/php/8.1/fpm/php.ini && \ | |
sudo sed -i 's|^;*\s*session.save_path\s*=.*|session.save_path = "/var/lib/php/sessions"|' /etc/php/8.1/fpm/php.ini | |
## Enable Mods | |
a2enmod rewrite | |
sudo a2enmod http2 | |
## Restart Services | |
sudo service apache2 restart | |
sudo service php8.1-fpm restart | |
## For MySQL Server | |
sudo echo 'sql_mode = "STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"' >> /etc/mysql/mysql.conf.d/mysqld.cnf | |
## For MariaDB Server | |
sudo echo 'sql_mode = "STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"' >> /etc/mysql/mariadb.conf.d/50-server.cnf | |
## Restart MySQL Service | |
sudo service mysql restart | |
## Create Database | |
mysql -u root -p | |
Enter Password: | |
CREATE DATABASE sendydb; | |
CREATE USER 'sendyuser'@'%' IDENTIFIED BY 'password'; | |
# MySQL 5.7 | |
GRANT ALL ON sendydb.* TO 'sendyuser'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; | |
# MariaDB 10 Up | |
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, CREATE VIEW, EVENT, TRIGGER, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EXECUTE ON `sendydb`.* TO 'sendyuser'@'%'; | |
FLUSH PRIVILEGES; | |
EXIT; | |
## Apache2 Virtual Host | |
sudo nano /etc/apache2/sites-enabled/subdomain.domain.tld.conf | |
# You may use this settings if you have subdomain as Sendy | |
<VirtualHost *:80> | |
ServerName subdomain.domain.tld | |
DocumentRoot /var/www/subdomain.domain.tld | |
Protocols h2 http/1.1 | |
<Directory /var/www/subdomain.domain.tld> | |
Options FollowSymLinks | |
AllowOverride All | |
Require all granted | |
</Directory> | |
ErrorLog ${APACHE_LOG_DIR}/subdomain.domain.tld.log warn | |
CustomLog ${APACHE_LOG_DIR}/subdomain.domain.tld-access.log combined | |
</VirtualHost> | |
#Recommand to use ServerName in apache config file instead of Virtual Host File | |
## Install Lets Encrypt SSL | |
sudo service apache2 restart | |
sudo certbot --apache --agree-tos --register-unsafely-without-email --redirect -d subdomain.domain.tld | |
sudo certbot renew --dry-run | |
## Download Sendy | |
cd /var/www/ | |
wget https://sendy.co/download/?license=LICENSE-KEY -O sendy.zip | |
unzip sendy.zip && mv sendy/ subdomain.domain.tld | |
## Setup Folder Permission | |
sudo chown www-data:www-data /var/www/subdomain.domain.tld/ -R | |
sudo chmod -R 775 /var/www/subdomain.domain.tld/ | |
sudo chmod -R 777 /var/www/subdomain.domain.tld/uploads/ | |
## Cronjob Setup | |
sudo crontab -e | |
*/5 * * * * php /var/www/subdomain.domain.tld/scheduled.php > /dev/null 2>&1 | |
*/1 * * * * php /var/www/subdomain.domain.tld/autoresponders.php > /dev/null 2>&1 | |
*/1 * * * * php /var/www/subdomain.domain.tld/import-csv.php > /dev/null 2>&1 | |
*/15 * * * * php /var/www/subdomain.domain.tld/update-segments.php > /dev/null 2>&1 | |
## Edit Sendy Config File and Put Database information. | |
nano /var/www/subdomain.domain.tld/includes/config.php | |
## Sendy Upgrade | |
cd /opt/ && rm -rf sendy/ && wget https://sendy.co/download/?license=LICENSE-KEY -O sendy.zip && unzip sendy.zip && rm sendy.zip | |
cd /opt/sendy/ && rm -rf .htaccess includes/config.php | |
rsync -ar --progress /opt/sendy/ /var/www/subdomain.domain.tld/ | |
sudo chown www-data:www-data /var/www/subdomain.domain.tld/ -R |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This package is No longer required!