Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the methods of establishing WordPress

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what are the methods of establishing WordPress". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what are the ways to build WordPress?"

[regular installation-LAMP or LNMP installation] prelude: environmental check

Operating system: Linux (most of what is used in this example works on CentOS 7.x x64 and Ubuntu 14.04.1 LTS 64-bit)

Service architecture: LAMP or LNMP

Note: here LAMP is Linux+Apache+MariaDB+PHP,LNMP and Linux+Nginx+MySQL+PHP

Software version: Apache 2.4, MariaDB5.5, PHP5

Configuration of LAMP on CentOS

This section is written according to the existing domain name. If you don't have a domain name or just want to configure a single website, you can take a look at the next section, "LNMP configuration on CentOS".

Apache HTTP Server (Apache for short), an open source web server of the Apache Software Foundation, is one of the most popular Web server-side software. Apache 2.4 is a major upgrade of Apache. The new version improves cache, proxy module, session control, asynchronous read and write, proxy_fcgi support, etc., and greatly improves concurrency performance.

Next, we will introduce the configuration of multi-domain name or existing domain name mode WordPress in Apache for reference.

Update the system

# yum update install and configure Apache network server

Apache 2.4 is the default in CentOS 7, and there is a good example of vhost.conf configuration on Apache's official website.

Installation

# yum install-y httpd

Backup configuration files (it is recommended that all configuration files be backed up before making any changes in order to deal with unknown errors)

# mkdir ~ / zningfbak# cp-R / etc/httpd ~ / zningbak

Where ~ represents the user folder of the currently logged in user; the-R parameter indicates recursion to all subdirectories

Configure a virtual host (/ etc/httpd/conf.d/vhost.conf)

# vim / etc/httpd/conf.d/vhost.conf

What needs to be filled in the document:

# # Host hosting zning.net# ServerAdmin admin@zning.net ServerName zning.net ServerAlias www # Note that there is no / DocumentRoot / srv/www/zning.net/html Options FollowSymLinks # at the end of the following line so that the next line can be set to use .htaccess AllowOverride All # in the directory of the website file. The next line is the new mechanism Require all granted ErrorLog / srv/www/ instead of Allow from all Zning.net/logs/error.log CustomLog / srv/www/zning.net/logs/access.log combined ServerSignature Off## host website qcloud.zning.net# this is another website located on the same server If not, delete this configuration # ServerAdmin admin@zning.net ServerName test.zning.net ServerAlias test DocumentRoot / srv/www/qcloud.zning.net/html Options FollowSymLinks AllowOverride All Require all granted ErrorLog / srv/www/qcloud.zning.net/logs/error.log CustomLog / srv/www/qcloud.zning.net/logs/access.log combined ServerSignature Off## host "for future access to phpMyAdmin, or other ports, such as 4444Listen 3366 hosts # phpMyAdmin Access address: http://12.34.56.78:3366/phpMyAdmin# ServerAdmin admin@zning.net DocumentRoot / srv/www/phpmyadmin/html Options FollowSymLinks AllowOverride None Require all granted ErrorLog / srv/www/phpmyadmin/logs/error.log CustomLog / srv/www/phpmyadmin/logs/access.log combined ServerSignature Off

Although the configuration file has been written, the httpd process cannot be started because the folders (site directories) set up above have not yet been created.

Create folders for each virtual host (add or delete as needed)

# mkdir / srv/www/zning.net/html-p # mkdir / srv/www/zning.net/logs# of Host 1 # mkdir / srv/www/qcloud.zning.net/html-p # mkdir / srv/www/qcloud.zning.net/logs# of Host 3 # mkdir / srv/www/phpmyadmin/html-p # mkdir / srv/www/phpmyadmin/logs

To be able to run the Apache server automatically when the system starts, you need to run the following directive:

# systemctl enable httpd

The output is similar to

# Created symlink from / etc/systemd/system/multi-user.target.wants/httpd.service to / usr/lib/systemd/system/httpd.service.

Then start the Apache service

# systemctl start httpd

If the above instruction indicates that httpd was already started, reload it

# systemctl reload httpd

Now you need to add the http service to the firewall to allow external access. First enable the firewall service, if the firewall is not started by default, the following directive will prompt an error, "FirewallD is not running".

# systemctl enable firewalld & & systemctl start firewalld

Where & & indicates that the two instructions are executed in turn.

After startup, re-execute the following instructions:

Add port 80, which is used by default by HTTP, to the firewall allow list

# firewall-cmd-add-service=http-permanent

The-permanent parameter indicates that this is a permanent firewall rule. If you do not add this parameter, there will be no such rule after restarting the system.

For custom port 3366 for phpMyAdmin, you also need to add corresponding firewall rules. Because it is a non-standard port, it can be expressed directly by numbers.

# firewall-cmd-zone=public-add-port=3366/tcp-permanent

Restart Firewalld for the rule to take effect

# systemctl restart firewalld

To view the firewall rules after joining, use the instruction

# firewall-cmd-list-all

The display result is similar to that of

Public (default) interfaces: sources: services: dhcpv6-client http ssh ports: 3366/tcp masquerade: no forward-ports: icmp-blocks: rich rules:

If you have done the DNS domain name resolution, you should be able to see the test page of Apache by opening the domain name with a browser.

Install and configure the MariaDB database service

MariaDB is a database software rebuilt on the basis of MySQL, and all Linux distributions have switched from MySQL to MariaDB one after another. CentOS defaults to MariaDB starting at 7.

Installation

# yum install-y mariadb-server mariadb

Join with system startup

# systemctl enable mariadb

The output is similar to

Created symlink from / etc/systemd/system/multi-user.target.wants/mariadb.service to / usr/lib/systemd/system/mariadb.service.

Start the MariaDB daemon (mysqld)

# systemctl start mariadb

Its default user name is still mysql.

# top-u mysql

You can view the memory footprint.

Security configuration MariaDB

Configure using MariaDB's built-in security configuration script

# mysql_secure_installation

Here you need to configure the mysql root and password, clear other users, clear unwanted databases, and so on. The output is similar to the following execution process, in which what we need to enter from the keyboard is annotated with *:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the currentpassword for the root user. If you've just installed MariaDB, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.Enter current password for root (enter for none): OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation.Set root password? Enter your password here (it will not be displayed) * Re-enter new password:*** re-enter * Password updated fulfilled Reloading privilege tables.. ... Success!By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.Remove anonymous users? [YBO] yearly * enter yearly * here. Successful normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [YBO] yearly * enter yearly * here. Successful by default, MariaDB comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [YBO] yearly * enter yearly *-Dropping test database... here ... Success!-Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [YBO] yearly * enter yearly * here. Success!Cleaning up...All done! If you've completed all of the above steps, your MariaDBinstallation should now be secure.Thanks for using MariaDB!

Then log in using MySQL's root account (unlike Linux's root account, which just set a password).

# mysql-u root-p

Enter the password and enter. The following is an example of the output. You can see that the command prompt changes to MariaDB [(none)] >

Welcome to the MariaDB monitor. Commands end with; or\ g.Your MariaDB connection id is 20Server version: 5.5.44-MariaDB MariaDB ServerCopyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.MariaDB [(none)] >

Create a new database for WordPress to use (here it is called wpzning, or you can use another name)

MariaDB [(none)] > create database wpzning

Create a new user and give him permissions for the database (here is an example, the user name is zningwp_us and the password is zningwp2016)

MariaDB [(none)] > grant all on wpzning.* to 'zningwp_us' identified by' zningwp2016'

Update permissions

MariaDB [(none)] > flush privileges

Exit the database

MariaDB [(none)] > quit

The general output of the execution is as follows:

MariaDB [(none)] > create database wpzning;Query OK, 1 row affected (0.00 sec) MariaDB [(none)] > grant all on wpzning.* to 'zningwp_us' identified by' zningwp2016';Query OK, 0 rows affected (0.00 sec) MariaDB [(none)] > flush privileges;Query OK, 0 rows affected (0.00 sec) MariaDB [(none)] > quitBye

Backup configuration fil

# cp / etc/my.cnf ~ / zningbak/my.cnf.bak

Don't do the rest, and then use the phpMyAdmin of the graphical interface to do it.

Install and configure PHP

Install PHP5

# yum install-y php

Backup configuration file / etc/php.ini, as well as php.conf and 10-php.conf

# cp / etc/php.ini ~ / zningbak/php.ini.bak# cp / etc/httpd/conf.d/php.conf ~ / zningbak/httpd/conf.d/php.conf.bak# cp / etc/httpd/conf.modules.d/10-php.conf ~ / zningbak/httpd/conf.modules.d/10-php.conf.bak

And make sure you have the following statement in / etc/php.ini (modify what is different, add what you don't have, and adjust some values later, which is for a simple configuration of a server running WordPress):

Error_reporting = E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_ERROR | E_CORE_ERRORdisplay_errors = Offlog_errors = Onmax_execution_time = 300memory_limit = 32m

Install PHP-MYSQL

In order to use MySQL in PHP, you also need to install this php-mysql package:

# yum install-y php-mysql install and configure phpMyAdmin (optional)

The latest PHP, MySQL, and phpMyAdmin Yum installation packages are available on the Remi installation source for easy installation and update. However, the software packages on CentOS 7, the Linux distribution you are using, may have different version requirements, so use the Yum installation source priority plug-in to control it.

Install using EPEL REPOSITORY

Select the appropriate source address to install, refer to the method: install using EPEL installation source.

Go to the EPEL home page:

Http://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F

Find The newest version of 'epel-release' for EL7, click on the link to open a new page, and copy the epel-release-latest-7.noarch.rpm (the number may change, the current version is 7). Install directly using the following methods:

# yum install-y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Install PHPMYADMIN

# yum install-y phpmyadmin

Configuration

The default installation directory for phpMyAdmin is / usr/share/phpMyAdmin, and the virtual host configuration file / etc/httpd/conf.d/phpMyAdmin.conf (case sensitive) is automatically created in the configuration file directory of Apache.

Similarly, back up the configuration file first in case of errors in the modification

# cp / etc/httpd/conf.d/phpMyAdmin.conf ~ / zningbak/httpd/conf.d/phpMyAdmin.conf.bak

Then modify the settings in the configuration file (vim / etc/httpd/conf.d/phpMyAdmin.conf):

Alias / phpMyAdmin / usr/share/phpMyAdminAlias / phpmyadmin / usr/share/phpMyAdmin

That is, we can access phpMyDdmin by binding to any domain name on the Apache server. For example, it can be accessed through zning.net/phpmyadmin or zning.net/phpMyAdmin. But in this way, the content of phpMyAdmin is mixed with the content of the site, and it feels like phpMyAdmin has become a directory of the site. But in fact, we don't want others to visit this page. Therefore, we use the usual address plus port 3366 (instead of the default port 80, just change to our favorite port, such as 3344), that is, access phpMyAdmin in the form of IP:port/phpMyAdmin links, and add # to comment out the above Apache Alias rules:

# Alias / phpMyAdmin / usr/share/phpMyAdmin#Alias / phpmyadmin / usr/share/phpMyAdmin

And will

.

Inside.

Require ip 127.0.0.1Require ip:: 1

Change to

Require all granted

Save exit so that it can be accessed from anywhere. If the local computer is fixed IP, for security, you can also change the above Require all granted to Require ip. Our ADSL won't get this kind of treatment.

Because phpMyAdmin was configured with a virtual host with port 2082 when the virtual host profile / etc/httpd/conf.d/vhost.conf was created earlier, the phpMyAdmin can only be accessed through that virtual host (port). Because / srv/www/phpmyadmin/public_html is configured as the virtual host directory of phpMyAdmin, create a symbolic connection for this directory to the phpMyAdmin installation directory (/ usr/share/phpMyAdmin):

# ln-sf / usr/share/phpMyAdmin / srv/www/phpmyadmin/html

Back up and then modify the configuration file for phpMyAdmin

# cp / etc/phpMyAdmin/config.inc.php ~ / zningbak/config.inc.php.bak

Edit the file:

# vim / etc/phpMyAdmin/config.inc.php

Find the following code snippet:

$cfg ['blowfish_secret'] =' just fill in a messy string of characters, letters, numbers, etc., preferably longer than 16'.

Follow the prompts above to fill in the blowfish_secret string. Others do not need to be modified, save and exit.

Restart APACHE to make the configuration effective

# systemctl restart httpd

You can now access the phpMyAdmin through ip:port/phpMyAdmin (change IP to the IP of your Tencent CVM, and the port is the virtual host port of the phpmyadmin set above, pay attention to case).

Log in to phpMyAdmin using the username and password you created earlier (the username and password contained in the grant statement in 2.3.4).

# install WordPress

Domain name configuration

First, configure the domain name DNS. Here we take DNSPod as an example. The screenshot also explains the relevant records. Other methods can also be used to configure domain name resolution through this tutorial.

The detailed explanation of DNSPod analysis is shown in the figure:

Installation

Transfer directory to relevant directory

# cd / srv/www/qcloud.zning.net/html

Download WordPress

# wget https://cn.wordpress.org/wordpress-4.5.2-zh_CN.tar.gz

Extract the file

# tar zxvf wordpress-4.5.2-zh_CN.tar.gz

Move Fil

# mv / srv/www/qcloud.zning.net/html/wordpress/* / srv/www/qcloud.zning.net/html

Visit the website qcloud.zning.net for the final step of the installation.

Enter the database information that has been created:

The reason for the error in this step is that the site itself does not have read and write access to the html folder. For a specific solution, please see the explanation of site user rights in the Resources link in this section. Here we can follow the prompts, through ssh, enter vim / srv/www/qcloud.zning.net/html/wp-config.php to create, and copy the content already provided by WordPress, save and continue

Here that you have connected to the database, you can continue with the installation by providing website management information.

Dashboard controls the background interface:

Configuration of LNMP on CentOS

Nginx is a lightweight Web server and is distributed under a BSD-like protocol. Developed by Igor Sysoev, a Russian programmer, for use by Russia's large portal and search engine Rambler. It is characterized by less memory and strong concurrency.

Next, we will introduce the configuration of WordPress in single website mode in Nginx for reference.

Install Nginx service program

Install Nginx:

# yum install-y nginx

Enable Nginx to boot automatically:

# systemctl enable nginx

The output is similar to

Created symlink from / etc/systemd/system/multi-user.target.wants/nginx.service to / usr/lib/systemd/system/nginx.service.

Restart Nginx:

# systemctl restart nginx.service

After the installation is complete, visit the IP address, and the welcome screen on the following page appears, indicating that the installation is complete.

On this page, we see

This is the default index.html page that is distributed with nginx on Fedora. It is located in / usr/share/nginx/html.You should now put your content in a location of your choice and edit the root configuration directive in the nginx configuration file / etc/nginx/nginx.conf.

These two sentences tell us where the default configuration file for Nginx is and where the access path is, that is, where we need to place the WordPress. Write it down first. It will be useful later.

Nginx here is the simplest installation method, in fact, the most appropriate installation method is the installation after the completion of cross-compilation in the local environment, which is not particularly troublesome. For more information on the tutorial, please see: nginx server installation and configuration file details.

Install PHP service program and MariaDB database service program

This step is the same as in the previous section, please refer to the steps in the relevant sub-section of the previous section.

However, after installing PHP according to the steps in the previous section, you need to install a php-fpm plug-in

# yum install-y php-fpm

Create a daemon, set it up and start it:

# systemctl enable php-fpm# systemctl start php-fpm

Output something like this:

Created symlink from / etc/systemd/system/multi-user.target.wants/php-fpm.service to / usr/lib/systemd/system/php-fpm.service.

After the configuration is completed and started, we can see the listening status of the process with the following command:

# netstat-antl | grep 9000 # ps-ef | grep php-cgi

Output something like this:

[root@QCLOUD share] # ps-ef | grep php-cgiroot 12838 8024 0 10:23 pts/0 00:00:00 grep-- color=auto php-cgi [root@QCLOUD share] # netstat-antl | grep 9000tcp 00 127.0.0.1 ef 9000 0.0.0.0 * LISTEN install WordPress

First configure nginx.conf and enter the editor with the following command:

# vim / etc/nginx/nginx.conf

In

Location / {index index.html index.php;}

Add in

Index index.html index.php

And start another line after} and add the following:

Location ~\ .php$ {root html; fastcgi_pass 127.0.0.1 root html; fastcgi_pass 9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;}

After the addition is completed, the code for the server code section is as follows:

Location / {index index.html index.php;} location ~\ .php$ {root html; fastcgi_pass 127.0.0.1 location 9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;}

Then, enter the path just listed:

# cd / usr/share/nginx/html

Download WordPress

# wget https://cn.wordpress.org/wordpress-4.5.2-zh_CN.tar.gz

Here may be affected by the server, Beijing computer room download speed is good, Shanghai may be slower.

Extract the file

# tar zxvf wordpress-4.5.2-zh_CN.tar.gz

Change and back up existing files in the html folder:

# mv index.html index.html.bak

Move Fil

# mv / usr/share/nginx/html/wordpress/* / usr/share/nginx/html

Access the IP address of your server for the final step of installation.

At this point, I believe you have a deeper understanding of "what are the methods of establishing WordPress?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report