How to setup an OpenLiteSpeed webserver running LiteCart

Titolo

OldNew
11How to setup an OpenLiteSpeed webserver running LiteCart

Collegamento permanente

OldNew
11how_to_setup_openlitespeed_web_server_running_litecart

contenuto

OldNew
11# How to setup an OpenLiteSpeed webserver running LiteCart
2
3LiteSpeed web server is a high performance drop in replacement for Apache2. This article will guide you into setting up a webserver running LiteCart with OpenLiteSpeed.
4
5```bash
6# Become root (or you will need to pass `sudo` before every command)
7# (If a password is not previously set, first set a root password with the command: sudo passwd root)
8su
9
10# Set timezone (if not already)
11timedatectl set-timezone Europe/London
12
13# Make sure that the OS and software is up to date
14apt update && apt full-upgrade -y
15
16# Install some server components
17apt install curl nano unzip
18
19# Install OpenLiteSpeed repository
20bash -c "$(curl https://repo.litespeed.sh)"
21
22# Install OpenLiteSpeed, MariaDB and PHP 8.3
23apt install -y openlitespeed mariadb-server lsphp83 lsphp83-common lsphp83-apcu lsphp83-curl lsphp83-imagick lsphp83-mysql lsphp83-intl
24
25# List which PHP modules for LiteSpeed that are installed
26/usr/local/lsws/lsphp83/bin/php -m
27
28# List additional php modules that can be installed
29apt search lsphp |more
30
31# Install additional locales if missing (Example: language-pack-{language_code})
32apt -y install language-pack-es language-pack-fr language-pack-de
33
34# Set admin password for OpenLiteSpeed
35/usr/local/lsws/admin/misc/admpass.sh
36
37# Make LiteSpeed listen to incoming traffic on port 80 instead of 8080
38sed -ri 's/\*:8088/*:80/' "/usr/local/lsws/conf/httpd_config.conf"
39
40# Let's make som changes to the PHP configuration
41sed -ri 's/;?memory_limit\s*=\s*[^\s]*/memory_limit = 256M/' "/usr/local/lsws/lsphp83/etc/php/8.3/litespeed/php.ini"
42sed -ri 's/;?upload_max_filesize\s*=\s*[^\s]*/upload_max_filesize = 64M/' "/usr/local/lsws/lsphp83/etc/php/8.3/litespeed/php.ini"
43sed -ri 's/;?date\.timezone\s*=\s*[^\s]*/date.timezone = Europe\/London/g' "/usr/local/lsws/lsphp83/etc/php/8.3/litespeed/php.ini"
44
45# Start MariaDB database service and enable autostart after reboot
46systemctl start mariadb
47systemctl enable mariadb
48
49# Secure your MySQL/MariaDB server
50# Alternatively run a handsfree command for securing MariaDB/MySQL:
51# mysql -uroot <<END
52# ALTER USER 'root'@'localhost' IDENTIFIED BY '{desired_root_password_here}';
53# GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
54# DROP USER IF EXISTS ''@'localhost';
55# DROP DATABASE IF EXISTS test;
56# FLUSH PRIVILEGES;
57# END
58mysql_secure_installation
59
60# Start web server service and enable autostart after reboot
61systemctl start lshttpd
62systemctl enable lshttpd
63
64# If you have the UFW firewall installed, allow some incoming traffic
65ufw allow ssh http https 7080/tcp
66
67# Connect to http://your-server-ip:7080/ using your web browser to access the OpenLiteSpeed's web admin interface
68# From there you can setup your virtual host configurations
69```
70
71# Setup a New Website
72
73```bash
74# Add the domain name to the hosts file for local resolving
75# (For other machines and for the world to discover this website a public DNS record is required pointing the domain name to your machine's public WAN IP.)
76cat <<EOF | tee -a /etc/hosts > /dev/null
77127.0.0.1 mywebsite.tld
78127.0.0.1 www.mywebsite.tld
79EOF
80
81# Create some necessary directories for your website
82mkdir -p /var/www/mywebsite.tld/public_html
83mkdir /var/www/mywebsite.tld/logs
84mkdir /usr/local/lsws/conf/vhosts/mywebsite.tld
85
86# Create a virtualhost configuration
87cat <<EOF > /usr/local/lsws/conf/vhosts/mywebsite.tld/vhconf.conf
88docRoot /var/www/mywebsite.tld/public_html
89vhDomain mywebsite.tld
90vhAliases www.mywebsite.tld
91adminEmails webmaster@mywebsite.tld
92enableGzip 1
93
94errorlog /var/www/mywebsite.tld/logs/error.log {
95 useServer 1
96 logLevel ERROR
97 rollingSize 10M
98 keepDays 30
99}
100
101accesslog /var/www/mywebsite.tld/logs/access.log {
102 useServer 1
103 rollingSize 10M
104}
105
106rewrite {
107 enable 1
108 autoLoadHtaccess 1
109}
110
111context / {
112 location $DOC_ROOT/
113 allowBrowse 0
114 indexFiles index.html, index.php
115}
116EOF
117
118# Set owner and permissions for configurations
119chown -R lsadm:nogroup /usr/local/lsws/conf/vhosts/mywebsite.tld/
120chmod -R 0750 /usr/local/lsws/conf/vhosts/mywebsite.tld/
121
122# Add a mapping of the virtualhost config to main config
123cat <<EOF >> /usr/local/lsws/conf/httpd_config.conf
124virtualhost mywebsite.tld {
125 vhRoot /usr/local/lsws/conf/vhosts/mywebsite.tld/
126 configFile /usr/local/lsws/conf/vhosts/mywebsite.tld/vhconf.conf
127}
128EOF
129
130# Add virtualhost to mapping of listening ports
131cat <<EOF >> /usr/local/lsws/conf/httpd_config.conf
132listener Mywebsite80 {
133 address mywebsite.tld:80, mywebsite.tld:80
134 secure 0
135 map mywebsite.tld mywebsite.tld
136}
137EOF
138
139# Restart web server
140systemctl restart lsws
141
142# Download LiteCart's web installer to the document root of your virtualhost directory
143curl --output /var/www/mywebsite.tld/public_html/index.php https://raw.githubusercontent.com/litecart/installer/master/web/index.php
144
145# Set file permissions to LiteSpeed's web user
146chown -R nobody:nogroup /var/www/mywebsite.tld/public_html
147
148# Now try accessing your website using your browser, and you should see the LiteCart Installer
149# Example: https:///mywebsite.tld/
150```
151
152# Enable Secure HTTPS and Create a Certificate
153
154```bash
155# Install certbot
156apt install certbot python3-certbot-apache
157
158# Generate an SSL Certificate using Let's Encrypt
159certbot certonly --webroot -w /var/www/mywebsite.tld -d mywebsite.tld
160
161# Make LiteSpeed listen to incoming secure traffic on port 443
162cat <<EOF >> /usr/local/lsws/conf/httpd_config.conf
163listener Mywebsite443 {
164 address mywebsite.tld:443, mywebsite.tld:443,
165 secure 1
166 keyFile /etc/letsencrypt/live/mywebsite.tld/privkey.pem
167 certFile /etc/letsencrypt/live/mywebsite.tld/fullchain.pem
168 map mywebsite.tld mywebsite.tld
169}
170EOF
171
172# Restart Apache web server for SSL
173systemctl restart lsws
174```

Modificato da tim il 12 mar 2025 alle 19:34

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.