Configure Apache, PHP5.6, MariaDB environment on Centos7 to build your own WordPress personal website.
Recently I wanted to build a WordPress personal website on my Tencent cloud server (CentOS 7.6). I also went to Baidu online for a long time, but the tutorials I saw always had various problems, so I am here Write down your own building steps.
Browse the website built by this tutorial
WordPress demand environment (Apache, MariaDB, php5.6)
Preparation: Log in to the server and enter the terminal, or use tools such as xshell to directly understand that the remote server enters the terminal
The first step is to install the Apache server
1. Install Apache
yum -y install httpd
2. Start hhtpd
systemctl start httpd.service
3. Set to boot
systemctl enable httpd.service
4. Install firewall, (execute the following commands one by one, the same is true below)
yum -y install firewalld firewall-config
systemctl start firewalld.service
systemctl enable firewalld.service
5. Configure firewall
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
The second step is to install MariaDB with its configuration
1. Install MariaDB
yum -y install mariadb-server mariadb
2. Set the boot
systemctl start mariadb.service
systemctl enable mariadb.service
3. Set the root password
mysql_secure_installation
To execute this statement, there will be several items that require you to receive the choice [y / n], enter all y
The third step is to install PHP.
这里使用yum命令安装时,默认是安装5.4版本的,但是wordpress要求php最低版本为5.6,
因此我们先安装默认的再去升级php版本至5.6即可。
1, yum command to install php
yum -y install php
2. Download PHP all components / dependency packages
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
3. Create a new PHP page to test PHP while viewing all components
vi /var/www/html/info.php
Go to the browser to test, http: // public ip / info.php
4. Upgrade php
yum provides php #自带的只有5.4版本
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm #更新源
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum remove php-common -y #移除系统自带的php-common
yum install -y php56w php56w-opcache php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-mysql php56w-intl php56w-mbstring #安装依赖包
5. Restart httpd service
systemctl restart httpd.service
The fourth step , database configuration
1. Open the database and create a database for the WordPress project.
mysql -u root -p
CREATE DATABASE wordpressdb;
2. Add a database user, username: wordpressuser password: 123456
CREATE USER wordpressuser@localhost IDENTIFIED BY '123456';
3. Modify user permissions and exit
GRANT ALL PRIVILEGES ON wordpressdb.* TO wordpressuser@localhost;
FLUSH PRIVILEGES;
exit
4. Restart the service
systemctl restart httpd.service
systemctl restart mariadb.service
The fifth step is to configure the wp-config.php file.
Copy the wp-config-sample.php file in the root directory of the local WordPress project and rename it to wp-config.php, and use the programming tool to open the modification. as follows:
/** WordPress数据库的名称 */
define( 'DB_NAME', 'wordpressdb' );
/** MySQL数据库用户名 */
define( 'DB_USER', 'wordpressuser' );
/** MySQL数据库密码 */
define( 'DB_PASSWORD', '123456' );
The sixth step is to use xftp to upload the WordPress project to the server
1. Create a new wp folder on the server to put the project. You can command to create a new one or you can right-click directly on xftp to create a new one.
2. All files in the template wordpress folder downloaded from the WordPress official website are pulled into the wp folder.
The seventh step is to copy the wp folder of the project directory to the / var / www / html directory (publish / access the project to the outside world)
cp -rf wordpress/* /var/www/html/
Restart related services here
systemctl restart httpd.service
systemctl restart mariadb.service
The eighth step , browser access to install WordPress
http://129.204.181.119/
Here will automatically jump to let you install, just enter the information as prompted.
The final result is shown in the figure:
so far, all is done, please leave a message if you have any questions.
Attachment:
Baidu network disk xftp download
Link: https://pan.baidu.com/s/18NsllS0VqVSCLaN82lCQQA
Extraction code: 4c6n