Use Ubuntu+Nginx+Mariadb to quickly set up WordPress
The WordPress quick installation method does not take 10 minutes to follow the process, just keep copying and pasting, and a few parameters that need to be modified or noted will be reminded, and the test will be passed in Ubuntu 20.04.
This set of processes is tested and effective by the blogger himself. This BLOG is basically set up and down in this set of processes. Advanced security defenses are not explained in this process.
Firewall
System firewall I choose ufw firewall. If there are other protections outside the host, it is not necessary to set up a system firewall. For example, Microsoft Azure has a firewall in front of the VPS. When a single VPS serves externally, it is of little significance to set up a firewall in the system itself, but it will consume VPS resources.
# Check IPV6=yes
sudo vi /etc/default/ufw
# If you accidentally block your VPS ssh connection, you must use the method provided by the VPS manufacturer to allow the ssh connection.
ufw the allow SSH sudo # 80 is the default, if you do not need to change 8050 80 sudo ufw the allow 80 sudo ufw the allow 8050
# 443 cannot be changed, SSL must go to 443.
sudo ufw allow 443
# Take a look at the setting
sudo ufw status
sudo ufw enable
Database
The database chooses the commercial free Mariadb, which is highly compatible with MySQL.
sudo apt install mariadb-server
# Note that the account password of the database administrator is different from the account password of the database user.
sudo mysql_secure_installation
sudo mysql
# The following is the SQL command. Create a new user account with a lower authority to access a specific database.
DATABASE wpweb the CREATE; . * Wpweb the ON the TO ALL the GRANT 'account DB' @ 'localhost' IDENTIFIED BY ' DB password' the WITH the GRANT the OPTION; the FLUSH PRIVILEGES;
exit
# Test the account
mariadb -u DB account -p
input password'DB password'
# Test whether you have permission to use the database. If it fails, the permission setting is wrong.
use wpdb
exit
Web
Choose Nginx as the web server and install the php service.
APT Nginx the install the sudo the sudo APT the install PHP-PHP-MySQL FPM the sudo APT the install curl curl PHP-PHP-PHP-Gd Intl the mbstring PHP-PHP-SOAP-XML PHP-PHP-PHP the xmlrpc ZIP the sudo VI / etc / Nginx /sites-available/wpweb
If port 80 is not used (usually to set up other services in the future), it is recommended to set it before installing wordpress. After changing the port, it is no problem to match the reverse proxy, here is changed to 8050. Enter in wpweb:
{Server
the listen 8050;
the listen [::]: 8050; the root / var / WWW / wpweb; index the index.php index.html index.htm; server_name _; # the system installed here to change your name Domain LOCATION / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; # Note the version here, the blogger is 7.4 when installed, you can use ls Instruction to confirm the version fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; } }
sudo ln -s /etc/nginx/sites-available/wpweb /etc/nginx/sites-enabled/
sudo nginx -t
sudo rm /etc/nginx/sites-enabled/default
sudo systemctl reload nginx
Increase the upload file capacity.
sudo vi /etc/nginx/nginx.conf
http {
client_max_body_size 128m;
}
sudo mkdir /var/www/wpweb
sudo chown -R $USER:$USER /var/www/wpweb
Check the info.php path displayed in the Loaded Configuration File column, it may be different for different versions or systems.
sudo vi /etc/php/7.4/fpm/php.ini
upload_max_filesize = 128M
post_max_size = 128M
max_execution_time = 120
sudo systemctl restart php7.4-fpm.service
Take a look at the LOG for errors. There should be none at present, probably.
cat /var/log/nginx/error.log
PHP Testing page
Create a test business to test whether the web can provide php services normally, which is very useful when testing DNS settings.
sudo vi /var/www/wpweb/info.php
<?php phpinfo();
sudo rm /var/www/wpweb/info.php
Use your own IP to open http://{ip}:8050/info.php for the test. If you can’t open it, check the DNS settings first. Many times the problem lies in the DNS settings. Don’t mess around with the system settings.
WordPress
After the previous system configuration is correct, start to install the Wordpress body.
# Download the latest version from the official, or upload it to the server/tmp location.
cd /tmp curl -LO https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
sudo cp -a /tmp/wordpress/. /var/www/wpweb
sudo chown -R www-data:www-data /var/www/wpweb
# Here you will get a bunch of garbled things called salt. Copy them to other places and store them in wp-config.php. The length of the salt is omitted below.
curl -s https://api.wordpress.org/secret-key/1.1/salt/
define('AUTH_KEY','B)*T>….f9ksK9i');
define('SECURE_AUTH_KEY','_Jj(k&Ba…[d5jT:!l');
define('LOGGED_IN_KEY','*z)(|* EyU:-….Pr`w2`8n:?');
define('NONCE_KEY', '5Hku|~w)+3….vE]NN+%`');
define('AUTH_SALT','BMfwCiVeH-|… z8;N_(_]n0');
define('SECURE_AUTH_SALT','NcS…O;^c.');
define('LOGGED_IN_SALT', '6K3qi…;[L)Tn');
define('NONCE_SALT', 'H_<X/...xVp}Tj]');
Modify wp-config.php, set the database, and replace the empty part with the string of salt above.
sudo vi /var/www/blogwp/wp-config.php
Start installing Wordpress http://{ip}:8050
Other considerations
Since we haven't used SSL yet, the http to https friendly function of the browser will cheat you. You can turn it off temporarily.
chrome://net-internals/#hsts
Input'localhost' to'Delete domain security policies'.
Comments
Post a Comment