Project

General

Profile

Install on Debian 11 » History » Version 1

Gareth Eaton, 05/06/2023 05:53 AM

1 1 Gareth Eaton
h1. Install on Debian 11
2
3
4
Use sudo -i command is used to open a root shell & update the system.
5
6
<pre>
7
sudo -i
8
apt update
9
apt upgrade -y
10
</pre>
11
12
Install Apache, MariaDB, PHP, and necessary PHP extensions:
13
<pre>
14
apt install apache2 mariadb-server php libapache2-mod-php php-mysql php-curl php-gd php-xml php-mbstring
15
</pre>
16
17
Start the Apache and MariaDB services:
18
19
<pre>
20
systemctl enable apache2
21
systemctl start apache2
22
systemctl enable mariadb
23
systemctl start mariadb
24
</pre>
25
26
Secure the MariaDB installation:
27
<pre>
28
mysql_secure_installation
29
</pre>
30
31
Follow the on-screen prompts to set a root password, remove anonymous users, disable remote root login, and remove the test database.
32
33
Create a new database and user for WordPress:
34
<pre>
35
mysql -u root -p
36
</pre>
37
38
Enter your MariaDB root password when prompted.
39
40
Then, run the following SQL commands to create a new database and user for WordPress:
41
42
*NOTE: Replace wordpressuser and password with your desired username and password.*
43
44
<pre>
45
CREATE DATABASE wordpress;
46
GRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'password';
47
FLUSH PRIVILEGES;
48
EXIT;
49
</pre>
50
51
Download and extract WordPress:
52
53
<pre>
54
cd /tmp
55
wget https://wordpress.org/latest.tar.gz
56
tar xzvf latest.tar.gz
57
</pre>
58
59
Move the WordPress files to the Apache web root directory:
60
61
<pre>
62
mv /tmp/wordpress/* /var/www/html/
63
</pre>
64
65
66
For WordPress, it is recommended to set file permissions to 644 and directory permissions to 755. This is because WordPress needs to read and write files in its installation directory and subdirectories, but does not require execute permissions on these files.
67
68
Setting file permissions to 644 allows the web server to read and write files, while preventing unauthorized modification. This is important for security reasons, as it prevents attackers from modifying important files like PHP scripts or configuration files.
69
70
Setting directory permissions to 755 allows the web server to read and execute directories, while preventing unauthorized access or modification of files in the directory.
71
<pre>
72
chown -R www-data:www-data /var/www/html/
73
find /var/www/html/ -type d -exec chmod 755 {} \;
74
find /var/www/html/ -type f -exec chmod 644 {} \;
75
</pre>
76
77
This will set the ownership of the WordPress files and directories to the www-data user and group, and set the file permissions to 644 and directory permissions to 755.
78
79
Edit the WordPress configuration file:
80
81
<pre>
82
cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php
83
nano /var/www/html/wp-config.php
84
</pre>
85
86
Update the following lines with your database details:
87
Replace the following lines with the appropriate credentials
88
89
<pre>
90
define('DB_NAME', 'wordpress');
91
define('DB_USER', 'wordpressuser');
92
define('DB_PASSWORD', 'password');
93
define('DB_HOST', 'localhost');
94
</pre>
95
96
Save and exit the file.
97
98
Restart Apache to apply the changes:
99
100
<pre>
101
systemctl restart apache2
102
</pre>
103
104
105
NOTES:
106
107
While setting directory permissions to 755 and file permissions to 644 is a good practice for security and performance reasons, it is possible that some plugins or themes may require different permissions. In such cases, you may need to adjust the permissions accordingly.
108
109
Additionally, running the chown command may cause issues if you have modified the ownership of files or directories within /var/www/html/ manually. In such cases, you may need to restore the original ownership or take additional steps to ensure that your files and directories are accessible to the web server.
110
111
If you have already manually modified the ownership of any files or directories in /var/www/html/, running the chown command again may cause issues. In such cases, you may need to restore the original ownership of those files or directories before running the chown command.
112
113
To avoid this issue, it is recommended that you do not manually modify the ownership of files or directories in /var/www/html/ and instead rely on the chown command to set the correct ownership for all files and directories in that directory.
114
115
It is also worth noting that while securing your WordPress installation is important, it is just one aspect of website security. You should also take other measures such as using strong passwords, keeping your software up to date, and regularly backing up your data.