1. Construction environment description
Server: Red Hat Enterprise Linux Server release 7.9 (Maipo)
PHP:php-8.2.4
Nginx: 1.24.0
http://nginx.org/en/download.html
WordPress:6.2
Mysql:5.7.22 MySQL Community Server (GPL)
For local WordPress construction, except Mysql uses the existing data, the others are all using the latest version. Next, we will build them one by one, and we will also write down the problems encountered in the middle.
2. PHP installation
Through "wget https://www.php.net/distributions/php-8.2.4.tar.gz" we download the php installation package, the file is very large, we need to wait patiently.
After downloading, use the "tar -zxvf php-8.2.4.tar.gz" command to decompress and enter the decompression directory for installation
Execute the configuration command command:
./configure --prefix=/u01/tool/wp/php8 --with-config-file-path=/u01/tool/wp/php8/etc --enable-fpm --enable-mysqlnd --enable-opcache --enable-pcntl --enable-mbstring --enable-soap --enable-calendar --enable-bcmath --enable-exif --enable-ftp --enable-intl --with-mysqli --with-pdo-mysql --with-openssl --with-curl --with-gettext --with-mhash --with-openssl --with-tidy --with-zlib
During the configuration process, you will find that many packages are missing, and you will sort out the error solutions later, and finally the following interface will appear after successful execution
Execute compilation + install "make & make install", this time is also very long, please wait patiently. The following interface appears, indicating that the installation is successful.
Passing the "/u01/tool/wp/php8/bin/php --version" test means that the installation is successful, and an interface appears to indicate success.
2.1. Configure and start php-fpm
- Generate php.ini configuration file
Execute the command "cp -r php.ini-production /u01/tool/wp/php8/etc/php.ini" in the php decompression directory
[root@elk php-8.2.4]# ls
appveyor config.log CONTRIBUTING.md libs Makefile.fragments php.ini-development sapi UPGRADING
build config.nice docs libtool Makefile.objects php.ini-production scripts UPGRADING.INTERNALS
buildconf config.status ext LICENSE modules README.md tests win32
buildconf.bat configure EXTENSIONS main NEWS README.REDIST.BINS travis Zend
CODING_STANDARDS.md configure.ac include Makefile pear run-tests.php TSRM
[root@elk php-8.2.4]# cp -r php.ini-production /u01/tool/wp/php8/etc/php.ini
[root@elk php-8.2.4]# ll /u01/tool/wp/php8/etc
总用量 84
-rw-r--r-- 1 root root 5391 4月 13 20:14 php-fpm.conf.default
drwxr-xr-x 2 root root 30 4月 13 20:14 php-fpm.d
-rw-r--r-- 1 root root 73924 4月 13 20:18 php.ini
- Generate www.conf configuration file
[root@elk wp]# cd /u01/tool/wp/php8/etc/php-fpm.d/
[root@elk php-fpm.d]# ls
www.conf.default
[root@elk php-fpm.d]#
[root@elk php-fpm.d]# cp www.conf.default www.conf
[root@elk php-fpm.d]#
[root@elk php-fpm.d]# ls
www.conf www.conf.default
[root@elk php-fpm.d]#
- Generate configuration files for php-fpm
[root@elk php-fpm.d]# cd /u01/tool/wp/php8//etc/
[root@elk etc]# ls
php-fpm.conf.default php-fpm.d php.ini
[root@elk etc]# cp -r php-fpm.conf.default php-fpm.conf
[root@elk etc]#
[root@elk etc]# ls
php-fpm.conf php-fpm.conf.default php-fpm.d php.ini
[root@elk etc]#
- Generate php-fpm startup file
[root@elk etc]#
[root@elk etc]# mkdir /u01/tool/wp/php8/daemon
[root@elk etc]#
[root@elk etc]# cp -r /u01/tool/wp/php-8.2.4/sapi/fpm/init.d.php-fpm /u01/tool/wp/php8/daemon/php-fpm
[root@elk etc]#
[root@elk etc]# chmod 740 /u01/tool/wp/php8/daemon/php-fpm
[root@elk etc]#
- start php-fpm
[root@elk etc]# /u01/tool/wp/php8/daemon/php-fpm start
Starting php-fpm done
[root@elk etc]#
- Check if the process is started
[root@elk etc]# ps -ef|grep php
root 83167 1 0 20:23 ? 00:00:00 php-fpm: master process (/u01/tool/wp/php8/etc/php-fpm.conf)
nobody 83168 83167 0 20:23 ? 00:00:00 php-fpm: pool www
nobody 83169 83167 0 20:23 ? 00:00:00 php-fpm: pool www
root 83222 178010 0 20:23 pts/1 00:00:00 grep --color=auto php
[root@elk etc]#
- View the port guarded by php-fpm by default
[root@elk etc]# ss -lntp | grep php
LISTEN 0 4096 127.0.0.1:9000 *:* users:(("php-fpm",pid=83169,fd=5),("php-fpm",pid=83168,fd=5),("php-fpm",pid=83167,fd=7))
[root@elk etc]#
2.2, configuration error resolution
- mistake one
configure: error: Package requirements (libxml-2.0 >= 2.9.0) were not met:
Package 'libxml-2.0', required by 'virtual:world', not found
Solution: Install via "dnf install libxml2-devel"
- error two
configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
Package 'sqlite3', required by 'virtual:world', not found
Solution: Install via "dnf install sqlite-devel"
- Mistake three
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution
Solution: install via "dnf -y install bzip2-devel"
- Mistake four
configure: error: Package requirements (libcurl >= 7.29.0) were not met:
Package 'libcurl', required by 'virtual:world', not found
Solution: Install via "dnf -y install libcurl-devel"
- Mistake five
configure: error: Package requirements (libpng) were not met:
Package 'libpng', required by 'virtual:world', not found
Solution: Install via "dnf -y install libpng-devel"
- Mistake six
configure: error: Package requirements (libjpeg) were not met:
Package 'libjpeg', required by 'virtual:world', not found
Solution: Install via "dnf -y install libjpeg-devel"
- mistake seven
configure: error: Package requirements (freetype2) were not met:
Package 'freetype2', required by 'virtual:world', not found
Solution: Install via "dnf -y install freetype-devel"
- Mistake eight
configure: error: Package requirements (icu-uc >= 50.1 icu-io icu-i18n) were not met:
Package 'icu-uc', required by 'virtual:world', not found
Package 'icu-io', required by 'virtual:world', not found
Package 'icu-i18n', required by 'virtual:world', not found
Solution: Install via: "dnf -y install libicu-devel"
- mistake nine
configure: error: Package requirements (oniguruma) were not met:
Package 'oniguruma', required by 'virtual:world', not found
Solution: Try installing via "dnf install oniguruma-devel"
Failing that, use the ultimate workaround at https://pkgs.org/
This website finds the required packages by itself and then downloads them through wget and installs them through "yum install xx.rpm"
- error ten
configure: error: Package requirements (libxslt >= 1.1.0) were not met:
Package 'libxslt', required by 'virtual:world', not found
Solution: Install via "dnf -y install libxslt-devel"
- error eleven
configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:
Package 'libzip', required by 'virtual:world', not found
Solution: Install via "dnf -y install libzip-devel"
3. Nginx installation
Through "wget http://nginx.org/download/nginx-1.24.0.tar.gz" we download the nginx installation package.
Decompress through "tar -zxvf nginx-1.24.0.tar.gz" and enter the decompression directory
Execute the "./configure --prefix=/u01/tool/wp/nginx --with-http_ssl_module --with-http_stub_status_module" command to configure nginx, and an interface will appear indicating that the configuration is successful and complete
The "--prefix" option is the nginx installation directory, which will be automatically generated after the installation is successful
Then execute the "make & make install" command to install. After a long wait, an interface will appear indicating that the installation is successful.
The installation directory has been created
Test start Execute the "/u01/tool/wp/nginx/sbin/nginx &" command, access the IP through the browser, if the following interface appears, it means success
3.1, through Nginx proxy PHP test
Create the info.php file in the "/u01/tool/wp/nginx/html" directory as follows
<?php
phpinfo();
?>
Modify the nginx configuration file "/u01/tool/wp/nginx/conf/nginx.conf" and add the following content
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Restart Nginx: "/u01/tool/wp/nginx/sbin/nginx -s reload" , the browser accesses " http://server IP/info.php ", and an interface appears to indicate success
4. WordPress installation
- The first step is to download the installation package and extract it to the website and directory
Website and directory: /u01/tool/wp/nginx/html/wordpress
Download command: "wget https://cn.wordpress.org/latest-zh_CN.zip"
Unzip: "unzip latest-zh_CN.zip"
Effect:
[root@elk html]# ls
50x.html index.html info.php latest-zh_CN.zip wordpress
[root@elk html]# pwd
/u01/tool/wp/nginx/html
[root@elk html]#
Modify the root directory of the nginx configuration file to "/u01/tool/wp/nginx/html/wordpress", and the final configuration file content is as follows
root /u01/tool/wp/nginx/html/wordpress;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location /wordpress {
try_files $uri $uri/ /wordpress/index.php?$args;
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
After configuring and restarting nginx, the browser directly accesses http:IP and the following interface appears, indicating success.
After configuring the database connection and account password configuration login effect
website front end
So far, building a personal website system through Nginx+WordPress has been successful. The website construction is not difficult, but the subsequent operation is difficult. I hope that every friend who has a dream will go further and further in the operation of the personal website system.
5. WordPress uses exception handling
- Failed to upload file
Modify php.ini, my php.ini file is in "/u01/tool/wp/php8/etc", modify the following values
upload_max_filesize = 128M
post_max_size = 128M
max_execution_time = 300
modify nginx limit
client_max_body_size 128M