# Deploying WordPress on Fedora Server 43
wp_user / Admin!123
admin / Rx_NpzE-4Bh!e97
Fedora Server 43
Mount disk.
~]$ sudo lvcreate -L 10G -n www fedora | |
~]$ sudo mkfs.xfs /dev/fedora/www | |
~]$ sudo mkdir /www | |
~]$ sudo chown sakura:sakura /www | |
~]$ sudo blkid | |
~]$ sudo vim /etc/fstab | |
UUID=4d404327-74fe-465e-8d02-fbd6d1e7b483 /www xfs defaults 0 0 | |
~]$ sudo systemctl daemon-reload | |
~]$ sudo mount -a |
Install PHP.
# Update the package lists. | |
sudo apt update | |
# Install PHP. | |
sudo apt install -y php |
Download and extract.
~]$ mkdir soft | |
~]$ wget -P soft https://wordpress.org/latest.tar.gz | |
~]$ tar -P soft -zxvf soft/latest.tar.gz |
Install ftp.
~]$ sudo dnf install vsftpd ftp | |
~]$ sudo vim /etc/vsftpd/vsftpd.conf | |
listen=YES | |
listen_ipv6=NO | |
anonymous_enable=YES | |
~]$ sudo firewall-cmd --add-service=ftp --per | |
~]$ sudo firewall-cmd --reload | |
~]$ sudo systemctl enable --now vsftpd.service | |
~]$ systemctl status vsftpd.service |
Install MySQL.
~]$ sudo dnf install mysql8.0-server.x86_64 | |
~]$ sudo systemctl enable --now mysqld | |
~]$ systemctl status mysqld | |
~]$ mysql -uroot -p | |
mysql> CREATE DATABASE wordpress; | |
mysql> CREATE USER "sakura"@"%" IDENTIFIED BY "sakura"; | |
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO "sakura"@"%"; | |
mysql> FLUSH PRIVILEGES; | |
mysql> EXIT |
Install nginx.
~]$ sudo dnf install php | |
~]$ sudo dnf install php-mysqlnd.x86_64 | |
~]$ sudo dnf install nginx | |
~]$ sudo systemctl enable --now nginx | |
~]$ systemctl status nginx | |
~]$ sudo firewall-cmd --add-service=http | |
~]$ sudo firewall-cmd --add-service=http --per | |
~]$ mv soft/wordpress/ /www/ | |
~]$ sudo semanage fcontext -a -t httpd_sys_content_t '/www(/.*)?' | |
~]$ sudo semanage fcontext -a -t httpd_sys_rw_content_t '/www/wordpress(/.*)?' | |
~]$ restorecon -Rv /www | |
~]$ sudo vi /etc/nginx/conf.d/wordpress.conf | |
server { | |
listen 80; | |
root /www/wordpress; | |
index index.php index.html; | |
server_name sakurayumeno.top; | |
access_log /var/log/nginx/www.access.log; | |
error_log /var/log/nginx/www.error.log; | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_pass unix:/run/php-fpm/www.sock; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
location = /favicon.ico { | |
log_not_found off; | |
access_log off; | |
} | |
location = /robots.txt { | |
allow all; | |
log_not_found off; | |
access_log off; | |
} | |
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { | |
expires max; | |
log_not_found off; | |
} | |
} | |
~]$ sudo nginx -t | |
~]$ sudo systemctl reload nginx |
Config wp-config.php
~]$ cp soft/wordpress/wp-config-sample.php soft/wordpress/wp-config.php | |
~]$ vi soft/wordpress/wp-config.php | |
define( 'DB_NAME', 'wordpress' ); | |
define( 'DB_USER', 'sakura' ); | |
define( 'DB_PASSWORD', 'sakura' ); |
# Troubleshooting
Issue: An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration.
~]# sudo tail -f /var/log/audit/audit.log | |
type=AVC msg=audit(1764656108.632:8333): avc: denied { name_connect } for pid=5913 comm="php-fpm" dest=443 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket permissive=0 | |
type=AVC msg=audit(1764656108.632:8334): avc: denied { name_connect } for pid=5913 comm="php-fpm" dest=443 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket permissive=0 | |
type=AVC msg=audit(1764656108.634:8335): avc: denied { name_connect } for pid=5913 comm="php-fpm" dest=80 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket permissive=0 | |
~]# sudo tail -f /var/log/messages | |
Dec 2 14:45:02 wordpress setroubleshoot[14433]: SELinux is preventing php-fpm from name_connect access on the tcp_socket port 80. For complete SELinux messages run: sealert -l 060daf24-f64b-4a45-b1e9-08b62cf8f29a | |
Dec 2 14:45:02 wordpress setroubleshoot[14433]: SELinux is preventing php-fpm from name_connect access on the tcp_socket port 80.#012#012***** Plugin catchall_boolean (24.7 confidence) suggests ******************#012#012If you want to allow httpd to can network connect#012Then you must tell SELinux about this by enabling the 'httpd_can_network_connect' boolean.#012#012Do#012setsebool -P httpd_can_network_connect 1#012#012***** Plugin catchall_boolean (24.7 confidence) suggests ******************#012#012If you want to allow httpd to graceful shutdown#012Then you must tell SELinux about this by enabling the 'httpd_graceful_shutdown' boolean.#012#012Do#012setsebool -P httpd_graceful_shutdown 1#012#012***** Plugin catchall_boolean (24.7 confidence) suggests ******************#012#012If you want to allow httpd to can network relay#012Then you must tell SELinux about this by enabling the 'httpd_can_network_relay' boolean.#012#012Do#012setsebool -P httpd_can_network_relay 1#012#012***** Plugin catchall_boolean (24.7 confidence) suggests ******************#012#012If you want to allow nis to enabled#012Then you must tell SELinux about this by enabling the 'nis_enabled' boolean.#012#012Do#012setsebool -P nis_enabled 1#012#012***** Plugin catchall (3.53 confidence) suggests **************************#012#012If you believe that php-fpm should be allowed name_connect access on the port 80 tcp_socket by default.#012Then you should report this as a bug.#012You can generate a local policy module to allow this access.#012Do#012allow this access for now by executing:#012# ausearch -c 'php-fpm' --raw | audit2allow -M my-phpfpm#012# semodule -X 300 -i my-phpfpm.pp#012 |
Workaround:
Analyzing SELinux denial messages.
~]$ sealert -l 060daf24-f64b-4a45-b1e9-08b62cf8f29a |
Allow httpd to can network connect.
~]# sudo setsebool -P httpd_can_network_connect 1 |
# Reference
・ https://developer.wordpress.org/advanced-administration/before-install/howto-install/
・ https://geek-blogs.com/blog/linux-install-wordpress-detailed-guide/