How To Setup a Web Server Using Debian or Ubuntu and Install LiteCart
Titolo
Old | New | ||
---|---|---|---|
1 | How To Setup | 1 | How To Setup a Web Server Using Debian or Ubuntu and Install LiteCart |
Collegamento permanente
Nessun cambiamentocontenuto
Old | New | ||
---|---|---|---|
1 | # How to setup a web server using Debian/Ubuntu and install LiteCart | 1 | # How To Setup a Web Server Using Debian or Ubuntu and Install LiteCart |
2 | 2 | ||
3 | For this guide we will assume you have a minimal install of a Debian 11 | 3 | (For Debian 11, Debian 12, Debian 13, Ubuntu 22, Ubuntu 23, and Ubuntu 24.) |
4 | or Ubuntu 22.x based server installation. The following commands can be | 4 | |
5 | copy pasted to your SSH or Terminal window. | 5 | For this guide we will assume you have a minimal install of a based server installation. |
6 | 6 | The following commands can be copy pasted to your SSH or Terminal window. | |
7 | ```bash | 7 | |
8 | 8 | ```sh | |
9 | # Become root if not already | 9 | # Become root (if not already) |
10 | 10 | su | |
11 | su | 11 | |
12 | 12 | # Set timezone (if not already) | |
13 | # Make sure that the OS is up to date | 13 | timedatectl set-timezone Europe/London |
14 | 14 | ||
15 | apt update apt upgrade | 15 | # Make sure that the OS is up to date |
16 | 16 | apt update | |
17 | # Install additional locales if missing (Example: | 17 | apt upgrade |
18 | language-pack-{language_code}) | 18 | |
19 | 19 | # Install some basic utilities (in case we don't have it) | |
20 | apt -y install language-pack-es language-pack-fr language-pack-de | 20 | apt -y install curl nano unzip |
21 | 21 | ||
22 | # Install some basic utils and software | 22 | # Install the server software |
23 | 23 | apache2 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 | |
24 | apt -y install curl nano unzip apache2 libapache2-mod-php mariadb-server | 24 | |
25 | php php-common php-cli php-fpm php-apcu php-curl php-dom php-gd | 25 | # Install additional locales if missing (Example: language-pack-{language_code}) |
26 | php-imagick php-mysql php-simplexml php-mbstring php-intl php-zip | 26 | apt -y install language-pack-es language-pack-fr language-pack-de |
27 | php-xml | 27 | |
28 | 28 | # Enable some required Apache modules | |
29 | # Enable some required Apache modules | 29 | a2enmod rewrite headers setenvif |
30 | 30 | ||
31 | a2enmod rewrite headers proxy_fcgi setenvif | 31 | # Secure your MySQL/MariaDB server (Recommend that you use the default options, just set the password) |
32 | 32 | mysql_secure_installation | |
33 | # Secure your MySQL/MariaDB server (Recommend that you use the default | 33 | |
34 | options, just set the password) | 34 | # Alternatively run a handsfree command for securing MariaDB/MySQL |
35 | 35 | mysql -uroot <<END | |
36 | mysql_secure_installation | 36 | ALTER USER 'root'@'localhost' IDENTIFIED BY '{desired_root_password_here}'; |
37 | 37 | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION; | |
38 | # Alternatively run a handsfree command for securing MariaDB/MySQL | 38 | DROP USER IF EXISTS ''@'localhost'; |
39 | 39 | DROP DATABASE IF EXISTS test; | |
40 | mysql -uroot | 40 | FLUSH PRIVILEGES; |
41 | END | ||
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/ | ||
45 | sed -ri 's/;?memory_limit\s*=\s*[^\s]*/memory_limit = 256M/' /etc/php/8.3/apache2/php.ini | ||
46 | sed -ri 's/;?upload_max_filesize\s*=\s*[^\s]*/upload_max_filesize = 64M/' /etc/php/8.3/apache2/php.ini | ||
47 | sed -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 | ||
51 | nano /etc/apache2/sites-enabled/000-default.conf | ||
52 | |||
53 | # Allow incoming HTTP traffic through the Firewall | ||
54 | ufw allow http | ||
55 | ufw allow https | ||
56 | |||
57 | # Restart Apache to apply all changes | ||
58 | systemctl restart apache2 | ||
59 | ``` | ||
60 | |||
61 | ## Install LiteCart | ||
62 | |||
63 | Go 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 | ||
67 | read -p "New database name: " newdb_name | ||
68 | read -p "New database user: " newdb_user | ||
69 | read -sp "Password for database user '$newdb_user': " newdb_password | ||
70 | |||
71 | mysql -u root -p -e "CREATE DATABASE $newdb_name; \ | ||
72 | CREATE USER '$newdb_user'@'localhost' IDENTIFIED BY '$newdb_password'; \ | ||
73 | GRANT ALL PRIVILEGES ON $newdb_name.* TO '$newdb_user'@'localhost' WITH GRANT OPTION; \ | ||
74 | FLUSH PRIVILEGES;" | ||
75 | |||
76 | # Go to the document root for your site | ||
77 | cd /var/www/html | ||
78 | |||
79 | # Remove the default index page | ||
80 | rm index.html | ||
81 | |||
82 | # Download the LiteCart web installer | ||
83 | curl --output index.php https://raw.githubusercontent.com/litecart/installer/master/web/index.php | ||
84 | |||
85 | # Change owner of the files to apache | ||
86 | chown -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: | ||
94 | rm -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) | ||
101 | apt install certbot python3-certbot-apache | ||
102 | |||
103 | # To issue a SSL certificate run the following: | ||
104 | certbot --apache -d myvirtualhost.tld | ||
105 | ``` | ||
106 | |||
107 | NOTE: 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 | |||
109 | Now you have LiteCart installed with SSL. Happy times. | ||
110 | |||
111 | ## Appendixes | ||
112 | |||
113 | |||
114 | ### PHP Configuration | ||
115 | |||
116 | Note: 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 | ... | ||
122 | memory_limit = 256M | ||
123 | ... | ||
124 | upload_max_filesize = 64M | ||
125 | ... | ||
126 | date.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