$ sudo -i
$ dnf update
$ dnf install tmux -y
# Fix known issue with CentOS/Redhat. Ref: https://stackoverflow.com/a/68841102/8724367
$ setsebool -P httpd_can_network_connect 1
# Add 4GB Swap. Ref https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-centos-7#create-a-swap-file
$ dd if=/dev/zero of=/swapfile count=4096 bs=1MiB
$ ls -lh /swapfile
$ chmod 600 /swapfile
$ ls -lh /swapfile
$ mkswap /swapfile
$ swapon /swapfile
$ swapon -s
# Make the swap permanent. Ref https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-centos-7#make-the-swap-file-permanent
$ cp /etc/fstab ~/fstab.bak
$ echo "/swapfile swap swap sw 0 0" >> /etc/fstab
# Install MySQL 8.0 Community. https://www.sqliz.com/posts/install-mysql8-on-centos-stream-9/
$ dnf install https://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm -y
$ dnf config-manager --enable mysql80-community
$ dnf install mysql-server -y
# disable MySQL performance monitoring to reduce memory consumption
$ vim /etc/my.cnf
performance_schema=0
$ systemctl start mysqld
$ systemctl enable mysqld
$ grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}'
$ mysql_secure_installation
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password: sijeeg6loi3ye{ux7ohch}oh4sai/dae3co0Che#da5iet{eera6OovieK0aiko*e3iel?oofeobooj5quaefohw8ee7uech9aeD
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
# Create database for WordPress
$ mysql -h localhost -u root -p
Enter password:
mysql> CREATE DATABASE wp_mywordpress_app;
mysql> CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'AeTu0wa5iec;ooch1oce#e8Cah*c@ahf';
mysql> GRANT ALL PRIVILEGES ON wp_mywordpress_app.* TO 'wordpress'@'localhost';
mysql> exit
# Install Nginx
$ dnf install nginx -y
$ systemctl start nginx
$ systemctl enable nginx
# Install PHP 8. https://wiki.crowncloud.net/?How_to_Install_PHP_8_2_in_CentOS_9_Stream
$ dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm -y
$ dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm -y
$ dnf module list php
$ dnf module install php:remi-8.3 -y
$ dnf install php-gd php-mysqlnd -y
$ dnf update -y
$ php -v
# Configure PHP-FPM
$ vim /etc/php-fpm.d/www.conf
user = nginx
group = nginx
$ systemctl start php-fpm.service
$ systemctl enable php-fpm.service
# Install WordPress https://wiki.crowncloud.net/?How_to_Install_WordPress_with_LEMP_on_CentOS_Stream_9
$ dnf install wget -y
$ cd /var/www/html
$ wget https://wordpress.org/wordpress-6.4.2.tar.gz
$ ls
$ tar xvzf wordpress-6.4.2.tar.gz
$ chown -R nginx:nginx /var/www/html/wordpress
$ chmod -Rf 775 ./wordpress/
$ cat <<EOT > /etc/nginx/conf.d/wordpress.conf
server {
listen 80;
server_name mysite.example.com;
root /var/www/html/wordpress;
index index.php index.html index.htm;
client_max_body_size 100m;
location / {
try_files \$uri \$uri/ /index.php?\$args;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)\$ {
expires max;
log_not_found off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ \.php\$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_param PHP_VALUE "upload_max_filesize=100M; \n post_max_size=100M; \n post_max_size=128M; \n memory_limit=256M;";
}
}
EOT
$ cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
# Generate WordPress keys
$ curl -s https://api.wordpress.org/secret-key/1.1/salt/ > /var/www/html/wordpress/salt.txt && cat /var/www/html/wordpress/salt.txt
define('AUTH_KEY', '+:1>hvtYfguW~[#XmXr#QFUzzN~ W(`^_{HPDxY^m6V^,rh|3t<T)E|cx7d}k[2`');
define('SECURE_AUTH_KEY', '4wG| ky/6nTNG-@%HAYudjd<HMEubbbxxx}x#l-O/_x{?:|%v6-FA8eo[{q<X_+e');
define('LOGGED_IN_KEY', '[#$?R]G5[h9wAmmb>N6V-?]+H+(u =wbLiYn<u.}-[mcE-/Ua-eHF>0~},1s-%%H');
define('NONCE_KEY', 'aWEO)TZNU+e;u jGtbu%Lg.GkUB-M 45t:6pLIt>PAM0@*i{Xdz]T24l@NVsO+=o');
define('AUTH_SALT', 'ec vK^pH!f0uF~U?m]Hn<3X0pua,L]#9=}Ez1+h(..k]5^^D-N^pKH!fri8+K~=3');
define('SECURE_AUTH_SALT', 'W/m)K{`y A /3EHSQS)MC`7skc|IW9YZ->+p, gT-:iAD)FkK[z$y_^eQ*JR%}[t');
define('LOGGED_IN_SALT', '~x-($e*n/1,{!q-1WKRD=i)/`c*#Z=QRmSgoz~T);_,pA+Idu6z+dQ{8%5haWLMr');
define('NONCE_SALT', '@+|tp+|or8`|{S~+]}i;qzoGHus7J-m/I~t+L[q-t+|++q~|-v+k(2-,2TyXp&*.');
# Setup WordPress keys
$ vim /var/www/html/wordpress/wp-config.php
< Update with the values from /var/www/html/wordpress/salt.txt >
# Update WordPress database connection
$ vim /var/www/html/wordpress/wp-config.php
...
// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wp_mywordpress_app' );
/** Database username */
define( 'DB_USER', 'wordpress' );
/** Database password */
define( 'DB_PASSWORD', 'AeTu0wa5iec;ooch1oce#e8Cah*c@ahf' );
/** Database hostname */
define( 'DB_HOST', 'localhost' );
/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
...
# Installing snap on CentOS. https://snapcraft.io/docs/installing-snap-on-centos
$ dnf install epel-release
$ dnf upgrade
$ yum install snapd -y
$ systemctl enable --now snapd.socket
$ ln -s /var/lib/snapd/snap /snap
# Install Certbot. Install Certbot
$ snap install --classic certbot
$ ln -s /snap/bin/certbot /usr/bin/certbot
$ certbot --nginx
$ certbot renew --dry-run
Created
July 3, 2024 09:37
-
-
Save lnxph-devops-sareno/55859baceeeb0468e7a19df5db0f2cd7 to your computer and use it in GitHub Desktop.
Instaling WordPress+Nginx on CentOS Stream 9
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment