How To Setup a Web Server Using Debian or Ubuntu and Install LiteCart

Titolo

OldNew
1How To Setup Debian Web Server And Install Litecart1How To Setup a Web Server Using Debian or Ubuntu and Install LiteCart

Collegamento permanente

Nessun cambiamento

contenuto

OldNew
1# How to setup a web server using Debian/Ubuntu and install LiteCart1# How To Setup a Web Server Using Debian or Ubuntu and Install LiteCart
22
3For this guide we will assume you have a minimal install of a Debian 113(For Debian 11, Debian 12, Debian 13, Ubuntu 22, Ubuntu 23, and Ubuntu 24.)
4or Ubuntu 22.x based server installation. The following commands can be4
5copy pasted to your SSH or Terminal window.5For this guide we will assume you have a minimal install of a based server installation.
66The following commands can be copy pasted to your SSH or Terminal window.
7```bash7
88```sh
9# Become root if not already9# Become root (if not already)
1010su
11su11
1212# Set timezone (if not already)
13# Make sure that the OS is up to date13timedatectl set-timezone Europe/London
1414
15apt update apt upgrade15# Make sure that the OS is up to date
1616apt update
17# Install additional locales if missing (Example:17apt upgrade
18 language-pack-{language_code})18
1919# Install some basic utilities (in case we don't have it)
20apt -y install language-pack-es language-pack-fr language-pack-de20apt -y install curl nano unzip
2121
22# Install some basic utils and software22# Install the server software
2323apache2 libapache2-mod-php mariadb-server php php-common php-cli php-fpm php-apcu php-curl php-dom php-gd php-imagick php-mysql php-simplexml php-mbstring php-intl php-zip php-xml
24apt -y install curl nano unzip apache2 libapache2-mod-php mariadb-server24
25php php-common php-cli php-fpm php-apcu php-curl php-dom php-gd25# Install additional locales if missing (Example: language-pack-{language_code})
26php-imagick php-mysql php-simplexml php-mbstring php-intl php-zip26apt -y install language-pack-es language-pack-fr language-pack-de
27php-xml27
2828# Enable some required Apache modules
29# Enable some required Apache modules29a2enmod rewrite headers setenvif
3030
31a2enmod rewrite headers proxy_fcgi setenvif31# Secure your MySQL/MariaDB server (Recommend that you use the default options, just set the password)
3232mysql_secure_installation
33# Secure your MySQL/MariaDB server (Recommend that you use the default33
34 options, just set the password)34# Alternatively run a handsfree command for securing MariaDB/MySQL
3535mysql -uroot <<END
36mysql_secure_installation36ALTER USER 'root'@'localhost' IDENTIFIED BY '{desired_root_password_here}';
3737GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
38# Alternatively run a handsfree command for securing MariaDB/MySQL38DROP USER IF EXISTS ''@'localhost';
3939DROP DATABASE IF EXISTS test;
40mysql -uroot40FLUSH PRIVILEGES;
41END
42
43# Let's make som changes to the PHP configuration (See appendix PHP Configuration)
44# Note: For Ubuntu 22 the config directory is /etc/php/8.1/
45sed -ri 's/;?memory_limit\s*=\s*[^\s]*/memory_limit = 256M/' /etc/php/8.3/apache2/php.ini
46sed -ri 's/;?upload_max_filesize\s*=\s*[^\s]*/upload_max_filesize = 64M/' /etc/php/8.3/apache2/php.ini
47sed -ri 's/;?date\.timezone\s*=\s*[^\s]*/date.timezone = Europe\/Stockholm/g' /etc/php/8.3/apache2/php.ini
48
49# Edit edit the default apache virtualhost configuration (or create a new one e.g. mydomain.tld.conf)
50# Refer to Appendix: Virtual Host Configuration
51nano /etc/apache2/sites-enabled/000-default.conf
52
53# Allow incoming HTTP traffic through the Firewall
54ufw allow http
55ufw allow https
56
57# Restart Apache to apply all changes
58systemctl restart apache2
59```
60
61## Install LiteCart
62
63Go to the document root for your site, remove default index page, download the LiteCart web installer and setting the correct permissions:
64
65```sh
66# Create the LiteCart database in MariaDB/MySQL
67read -p "New database name: " newdb_name
68read -p "New database user: " newdb_user
69read -sp "Password for database user '$newdb_user': " newdb_password
70
71mysql -u root -p -e "CREATE DATABASE $newdb_name; \
72CREATE USER '$newdb_user'@'localhost' IDENTIFIED BY '$newdb_password'; \
73GRANT ALL PRIVILEGES ON $newdb_name.* TO '$newdb_user'@'localhost' WITH GRANT OPTION; \
74FLUSH PRIVILEGES;"
75
76# Go to the document root for your site
77cd /var/www/html
78
79# Remove the default index page
80rm index.html
81
82# Download the LiteCart web installer
83curl --output index.php https://raw.githubusercontent.com/litecart/installer/master/web/index.php
84
85# Change owner of the files to apache
86chown -R www-data:www-data ./
87
88##########################################################################
89# Open your browser and visit your website to begin installing LiteCart. #
90# https://myvirtualhost.tld/ #
91##########################################################################
92
93# When the LiteCart web installation is completed, do some cleanup:
94rm -Rf install/
95```
96
97## Install Let's Encrypt free SSL certificates
98
99```sh
100# Install snapd package installer (in case we don't have it)
101apt install certbot python3-certbot-apache
102
103# To issue a SSL certificate run the following:
104certbot --apache -d myvirtualhost.tld
105```
106
107NOTE: You need to have a hostname configured in the Apache conf and the host record pointing to your server in the DNSes, otherwise it will fail.
108
109Now you have LiteCart installed with SSL. Happy times.
110
111## Appendixes
112
113
114### PHP Configuration
115
116Note: LiteCart doesn't need a lot of memory, but image resampling does.
117
118**/etc/php/8.1/apache2/php.ini:**
119```ini
120
121...
122memory_limit = 256M
123...
124upload_max_filesize = 64M
125...
126date.timezone = Europe/London
127...
128```
129
130### Virtual Host Configuration
131
132**/etc/apache2/sites-enabled/000-default.conf:**
133```conf
134
135<VirtualHost *:80>
136 ServerName myvirtualhost.tld;
137 ServerAdmin webmaster@localhost
138 DocumentRoot /var/www/html
139
140 ErrorLog ${APACHE_LOG_DIR}/error.log
141 CustomLog ${APACHE_LOG_DIR}/access.log combined
142
143 <Directory /var/www/html>
144 Options FollowSymLinks
145 AllowOverride All
146 Require all granted
147 </Directory>
148</VirtualHost>
149```

Modificato da tim il 2 nov 2024 alle 13:39

This website uses no cookies and no third party tracking technology. We think we can do better than others and really think about your privacy.