[Operation and Maintenance Engineer Learning Six] LAM Deployment and Building a Personal Discuz Forum
-
- 1. Uninstall Mariadb first and then install Mysql
- 2. MySQL official website rpm package download
- 3. Install the YUM Repo file under the rpm package path
- 4. Update the local database information of the software warehouse
- 5. Start deployment - php installation
- 6. Search for yum packages
- 7. Start deployment - configure apache to support php
- 8. Start deployment - configure apache to support php
- 9. Journalctl troubleshooting
- 10. Start deployment - create database
- 11. Create a separate account for discuz
- 12. Website Installer
1. Uninstall Mariadb first and then install Mysql
systemctl stop mariadb
yum remove mariadb
2. MySQL official website rpm package download
https://dev.mysql.com/downloads/repo/yum/
wget https://dev.mysql.com/get/你要下载的rpm包
wget https://dev.mysql.com/get/mysql80-community-release-el8-5.noarch.rpm
- Find the download location
ls /etc/yum.repos.d
- If it is not in the above position, it will be under the path just downloaded
ls
3. Install the YUM Repo file under the rpm package path
yum localinstall mysql80-community-release-el8-5.noarch.rpm
4. Update the local database information of the software warehouse
yum makecache
yum list | grep mysql
- If you have installed MairaDB before like me, please execute it after installing MySQL (only for versions before MySQL8.0, please read this article for versions starting from 8.0: https://blog.csdn.net/weixin_43576565/ article/details/131702483 )
mysql_upgrade -u root –p
- Update the database (the password is your previous MariaDB root password). So far the DB installation is complete.
5. Start deployment - php installation
The apache installed by default does not support php.
There are also php binary packages in the system’s own software warehouse, but the binary packages about php in the software warehouse are compiled separately according to functional components, that is, the main program of php is compiled into a package, and other components such as gd library, mysql library, xml library, etc. etc. are compiled separately. If these libraries need to be used in the website code, they all need to be installed. The documentation of the general code will explain which libraries are needed for support. After reading the readme file of Discuz, except for the description of the database, there is no description of the others, so only two are installed this time. Use the following installation commands:
yum install -y php php-mysql
- The reason for the error
Error: Unable to find a match: php-mysql
is that the name of the new version has changed. In order to avoid the change next time, use the next command to check the name before installing
6. Search for yum packages
yum search php-mysql
- Start the installation after changing the name
yum install -y php php-mysqlnd
7. Start deployment - configure apache to support php
(1) Configuration enables apache to execute php scripts
After installing php and related components (libraries), you need to make relevant configurations in apache to enable apache to execute php scripts (codes). The configuration is as follows:
Edit httpd.conf (the path of the apache configuration file installed by yum is /etc/httpd/conf/httpd.conf
) file
1, find AddType text/html .shtml
, add under others AddType application/x-httpd-php .php
2, find DirectoryIndex index.html
, and modify it toDirectoryIndex index.html index.php
(2) After modifying the configuration, restart apache to make the configuration take effect.
systemctl restart httpd
8. Start deployment - configure apache to support php
After configuring apache, you need to check whether apache supports php normally. The test method is to add a php file in the root directory of the website, the file name is arbitrary, such as phptest.php, and the file content is as follows:
<?php
phpinfo();
?>
This is the simplest php code because it has only one function phpinfo(). Since the function of this file is to detect whether the server supports PHP, this file is also called a probe. But this is the simplest probe file. There are many powerful php probe scripts on the Internet, which can be searched and downloaded to have a look.
Here I set phptest.php as the default startup page, which can be accessed directly through ip, of course, it can also be accessed through the path
9. Journalctl troubleshooting
If an error occurs during the configuration process and it cannot be started, you can use journalctl -xe to troubleshoot the error. For specific operations, please refer to the following example:
journalctl -xe
- Go to the specified file and delete the content of line 311
10. Start deployment - create database
create database discuz;
show databases;
11. Create a separate account for discuz
CREATE USER 'dztest'@'localhost'IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON discuz.* TO 'dztest'@'localhost';
- Upload the website code to apache specified DocumentRoot directory
Here, Xftp is used for uploading. After the upload is successful, please ensure that the owner of all files in the root directory of the website is the apache running user. The running user name of apache installed with yum is gee (here is changed to your user name), so after uploading the code file, I executed the permission modification command to ensure that the owner of all files on the website is gee. The command is as follows:
chown -R apache:gee /var/www/html
12. Website Installer
你的ip/upload/install/index.php
(1) Rely on supplements
- Search for the full name of the missing dependency through yum, here is the missing json dependency as an example (search for what is missing):
yum search php-json #search啥看你缺少啥,他会提示的,我这里缺少的是json
yum install php-json
- The database is created as the discuz created earlier, of course, you can use the default one as long as you maintain it later and know that it is the Discuz forum database.
- At this point, the installation is complete. The following shows Discuz's user management center, home page, and management background