In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to use workpress to build a personal blog website". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Previous articles have described how to build a LNMP environment under Linux:
1. Install MySQL/MariaDB
two。 Install PHP
3. Install Nginx
4.nginx configure virtual host
Next, start using workpress to build a personal blog site:
Workpress official website: https://cn.wordpress.org/
Download workpress:
[root@linux ~] # wget https://cn.wordpress.org/latest-zh_CN.tar.gz
Decompress:
[root@linux ~] # tar-zxvf latest-zh_CN.tar.gz
Create a blog site directory:
[root@linux] # mkdir-p / data/www/test.blog.com
Move the files in the workpress installation package to the blog site directory:
[root@linux ~] # mv wordpress/* / data/www/test.blog.com/
Modify the nginx virtual host configuration file:
[root@linux ~] # vi / etc/nginx/conf.d/default.conf
Modify the following:
1. Define the custom domain name of the blog site (if there is a real domain name, you can use the real domain name)
two。 Define the directory of a blog site
3. Add index.php (WordPress uses php)
4. Remove the comment symbol # from the php section at the bottom of the profile and define the directory of the website
5. Modify / scripts to the website directory path
Verify the configuration file and reload:
[root@linux ~] # nginx-tnginx: the configuration file / etc/nginx/nginx.conf syntax is oknginx: configuration file / etc/nginx/nginx.conf test is successful [root@linux ~] # nginx-s reload
Modify the hosts file on Windows to:
Open a browser to access test.blog.com:
# the page of wordpress has been displayed successfully
Next, create a database of blog sites:
Login:
[root@linux] # mysql-uroot-p123456Welcome to the MariaDB monitor. Commands end with; or\ g.Your MariaDB connection id is 12Server version: 10.3.18-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.MariaDB [(none)] >
Create the database:
MariaDB [(none)] > create database wordpress;Query OK, 1 row affected (0.000 sec)
Create a user:
MariaDB [(none)] > grant all on wordpress.* to 'blog'@'127.0.0.1' identified by' test123';Query OK, 0 rows affected (0.029 sec)
# create user blog, password test123, and authorize a connection from 127.0.0.1
Modify the owner of the website directory file:
[root@linux] # cd / data/www/test.blog.com/ [root@linux test.blog.com] # chown-R php-fpm.
Open a browser to access test.blog.com to start configuring database information:
# enter database information and click submit
Start the installation:
# define website title, user name and password (email address is required, but email service is not configured to send email)
Click install after completion to show success:
Visit the custom domain name test.blog.com again to display the blog page:
Click Log in at the bottom of the page to go to the background management page:
Then you are free to edit the blog's home page layout, appearance style, permissions and other settings.
Discuz official website: https://www.discuz.net/forum.php
Install git:
[root@linux ~] # yum-y install git
Clone the discuz package to the local machine by git:
[root@linux ~] # git clone https://gitee.com/ComsenzDiscuz/DiscuzX.git
Copy the upload directory in the discuz package to the / data/www/ path and repeat the command directory:
[root@linux] # cp-r DiscuzX/upload/ / data/www/test.bbs.com
Add a nginx virtual host profile:
[root@linux ~] # cd / etc/nginx/conf.d/ [root@linux conf.d] # cp default.conf bbs.conf
Edit the configuration file:
[root@linux conf.d] # vi bbs.conf
Modify the following:
1. Define the custom domain name of the bbs website (if there is a real domain name, you can use the real domain name)
two。 Define the directory of the bbs site
3. Add index.php (discuz uses php)
4. Remove the comment symbol # from the php section at the bottom of the profile and define the directory of the bbs website
5. Modify / scripts to bbs site directory path
Verify the configuration file and reload:
[root@linux conf.d] # nginx-tnginx: the configuration file / etc/nginx/nginx.conf syntax is oknginx: configuration file / etc/nginx/nginx.conf test is successful [root@linux conf.d] # nginx-s reload
Change the directory owner:
[root@linux conf.d] # cd / data/www/test.bbs.com/root@linux test.bbs.com] # chown-R php-fpm config/ data/ uc_server/data/ uc_client/data/
Modify the Windows system C:\ Windows\ System32\ drivers\ etc\ hosts file: (use the real domain name and resolve to the server IP address to omit this step)
# add custom domain name: test.bbs.com
Open the browser to access the domain name to start the installation:
Click "I agree" and then click "next" to configure database information:
Log in to the database:
[root@linux test.bbs.com] # mysql-uroot-p123456Welcome to the MariaDB monitor. Commands end with; or\ g.Your MariaDB connection id is 92Server version: 10.3.18-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.MariaDB [(none)] >
Create a bbs website database:
MariaDB [(none)] > create database bbs;Query OK, 1 row affected (0.000 sec)
Create an authorized user:
MariaDB [(none)] > grant all on bbs.* to 'bbsuser'@'127.0.0.1' identified by' test123';Query OK, 0 rows affected (0.005 sec)
# create user bbsuser, password test123, and authorize a connection from 127.0.0.1
Fill in the database information:
# fill in the newly created database information, and the administrator information can set the password by yourself. The mailbox is available by default.
After the installation, the bbs website is built:
Log in to the backend using the administrator account:
Then you are free to set up the bbs website!
-
Nginx configures multiple domain names:
Edit the nginx virtual host profile:
[root@linux ~] # vi / etc/nginx/conf.d/default.conf
Add the domain name www.blog.com to the server_name item:
Verify the configuration and reload:
[root@linux] # nginx-t & & nginx-s reload
The website can then be accessed through the new domain name www.blog.com:
Nginx configure domain name redirection / redirect:
Edit the nginx virtual host profile:
[root@linux ~] # vi / etc/nginx/conf.d/default.conf
Add the following:
If ($host = test.blog.com) {rewrite / (. *) http://www.blog.com/$1 permanent;}
Verify the configuration and reload:
[root@linux] # nginx-t & & nginx-s reloadnginx: the configuration file / etc/nginx/nginx.conf syntax is oknginx: configuration file / etc/nginx/nginx.conf test is successful
Test:
[root@linux] # curl-x127.0.0.1 test.blog.comHTTP/1.1 80-I test.blog.comHTTP/1.1 301 Moved PermanentlyServer: nginx/1.16.1Date: Sun, 13 Oct 2019 15:24:43 GMTContent-Type: text/htmlContent-Length: 169Connection: keep-aliveLocation: http://www.blog.com/
# http status code 301 test.blog.com location: http://www.blog.com/. The request for test.blog.com has been successfully redirected to www.blog.com. For search engines, test.blog.com is considered to be the old domain name, and the new domain name www.blog.com is given priority.
Permanent redirection: permanent http status code: 301 (use of domain name redirection, transfer of domain name weight)
Temporary redirection: redirect http status code: 302 (for non-domain name redirection, such as file redirection)
Edit the nginx virtual host profile:
[root@linux ~] # vi / etc/nginx/conf.d/default.conf
Nginx add File Jump:
Rewrite / 1.txt / 2.txt redirect
Verify the configuration and reload:
[root@linux] # nginx-t & & nginx-s reloadnginx: the configuration file / etc/nginx/nginx.conf syntax is oknginx: configuration file / etc/nginx/nginx.conf test is successful
Test:
[root@linux] # curl-x127.0.0.1 www.blog.com/1.txtHTTP/1.1 80-I www.blog.com/1.txtHTTP/1.1 302 Moved TemporarilyServer: nginx/1.16.1Date: Sun, 13 Oct 2019 15:45:17 GMTContent-Type: text/htmlContent-Length: 145Location: http://www.blog.com/2.txtConnection: keep-alive
# http status code: 302 moment location: http://www.blog.com/2.txt, the file is redirected successfully
Nginx dual user authentication:
Suitable for the important pages of some websites (such as the background management page where the administrator logs in), the effect of double authentication is to verify the user name and password of double authentication before entering the account password on the important page.
Open the personal blog webmaster login page:
Modify the nginx virtual host configuration file to add double user authentication to the current page wp-login.php:
[root@linux ~] # vi / etc/nginx/conf.d/default.conf
Add the following:
Location ~ wp-login.php {auth_basic "Auth"; auth_basic_user_file / etc/nginx/user_passwd; fastcgi_pass 127.0.0.1 Auth 9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME / data/www/test.blog.com$fastcgi_script_name Include fastcgi_params;}
And remove the location of root and index items to make it a global configuration:
Since the added configuration defines double user authentication as / etc/ngninx/user_passwd, but there is no such file at present, you need to use the htpasswd command to generate this file:
Install the httpd-tools package:
[root@linux ~] # yum-y install httpd-tools
Generate a configuration file and add an authenticated user:
[root@linux ~] # htpasswd-c / etc/nginx/user_passwd admin1New password: Re-type new password: Adding password for user admin1
# generate user_passwd file and add authentication user admin1 and set password.-c parameter: create, generate authentication configuration file for the first time
New authenticated users need to use the-m parameter (MD5 encryption):
[root@linux ~] # htpasswd-m / etc/nginx/user_passwd admin2New password: Re-type new password: Adding password for user admin2
By viewing the user authentication profile, you can see the added account for authentication:
[root@linux] # cat / etc/nginx/user_passwd admin1:$apr1 $Qn57LBlw$fE4QyHrsQReHUrSvPdmxs/admin2:$apr1 $VH2Qe1nW$zn.1Hzn3QaF2RwJJDheGN.
Reload nginx:
[root@linux ~] # nginx-tnginx: the configuration file / etc/nginx/nginx.conf syntax is oknginx: configuration file / etc/nginx/nginx.conf test is successful [root@linux ~] # nginx-s reload
Open the personal blog webmaster login page again to display the double user authentication dialog box:
# enter the administrator account password to log in to the backend after double user authentication
Nginx location priority details:
Location configuration for nginx:
Nginx location grammar rules: location [= |\ ~ |\ ~ * | ^ ~ | /] / uri/ {… }
The location matching variable of nginx is $uri
Symbol description = exact match ^ ~ indicates that uri begins with a specified character or string ~ indicates a case-sensitive regular match ~ * indicates a case-insensitive regular match / universal match, and any request will match to the
Priority rules:
= higher than ^ ~ higher than * equals to higher than /
Example of rules:
Location = "/ 12.jpg" {...}
Such as:
Www.test.com/12.jpg matching
Www.test/abc/12.jpg mismatch
Location ^ ~ "/ abc/" {...}
Such as:
Www.test/abc/123.html matching
Www.test.com/a/abc/123.jpg mismatch
Location ~ "png" {...}
Such as:
Www.test.com/aaa/bbb/ccc/123.png matching
Www.test.com/aaa/png/123.html matching
Location ~ * "png" {...}
Such as:
Www.test.com/aaa/bbb/ccc/123.PNG matching
Www.test.com/aaa/png/123.html matching
Location / admin/ {...}
Such as:
Www.test.com/admin/aaa/1.php matching
Www.test.com/123/admin/1.php mismatch
Contrast / and ~
Example 1:
Server {listen 80; server_name www.test.com; root / tmp/123.com; location / abc/ {echo "/";} location ~ 'abc' {echo "~";}}
Test command: curl-x127.0.0.1 purl 80 'www.test.com/abc/1.png'
The result is: ~
* * compare ~ and ~ * *
Example 2:
Server {listen 80; server_name www.test.com; root / tmp/123.com; location ~ 'abc' {echo' ~';} location ~ * 'abc' {echo' ~ *;}}
Test command: curl-x127.0.0.1 purl 80 'www.test.com/abc/123.html'
The result is: ~
Example 3:
Server {listen 80; server_name www.test.com; root / tmp/123.com; location ~ * 'abc' {echo' ~ *;} location ~ 'abc' {echo';}}
Test command: curl-x127.0.0.1 purl 80 'www.test.com/abc/123.html'
The result is ~ *
Conclusion: the priority of ~ and ~ * is actually the same. If both meet the conditions, which location comes first and which takes effect in the configuration file.
Compare ^ ~ and ~
Example 4:
Server {listen 80; server_name www.test.com; root / tmp/123.com; location ~'/ abc' {echo'~';} location ^'/ abc' {echo'^';}}
Test command: curl-x127.0.0.1 purl 80 'www.test.com/abc/123.html
The result is: ^ ~
Contrast = and ^ ~
Example 5:
Server {listen 80; server_name www.test.com; root / tmp/123.com; location ^'/ abc.html' {echo'^';} location ='/ abc.html' {echo'=';}}
Test command: curl-x127.0.0.1 purl 80 'www.test.com/abc.html
The result is: =
The Nginx access log mainly records site access data deployed on nginx, and the log format is defined in the nginx main configuration file.
Nginx main configuration file: / etc/nginx/nginx.conf
View the nginx main configuration file:
[root@linux ~] # cat / etc/nginx/nginx.conf
The format of the defined nginx access log is shown in the red box below:
# main: format name
$remote_addr: the IP that visits the website
$remote_user: if user authentication is configured, indicates the user name of the user authentication
$time_local: access time
$request:http method, requested link, http version
$status:http status code
$body_bytes_sent: request size
$http_referer: the referer of the client request. Generally speaking, the request is redirected through which link.
$http_user_agent: client operating system and browser identity
$http_x_forwarded_for: if an agent is used, record the agent IP
Access log configuration path:
Configure access logs for a single nginx virtual host:
1. Edit the nginx virtual host profile:
[root@linux ~] # vi / etc/nginx/conf.d/default.conf
two。 Define the storage path and format of the access log:
3. Reload nginx:
[root@linux ~] # nginx-tnginx: the configuration file / etc/nginx/nginx.conf syntax is oknginx: configuration file / etc/nginx/nginx.conf test is successful [root@linux ~] # nginx-s reload
4. Log information can be generated after the browser visits the web site configured by the virtual host:
[root@linux] # cat / data/logs/nginx.log 192.168.234.1-- [15/Oct/2019:14:48:15 + 0800] "GET /? HTTP/1.1 1 HTTP/1.1" 200 57931 "http://www.blog.com/"" Mozilla/5.0 (Windows NT 10.0; Win64 X64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.75 Safari/537.36 "-" 192.168.234.1-[15/Oct/2019:14:48:15 + 0800] "GET / wp-includes/js/comment-reply.min.js?ver=5.2.3 HTTP/1.1" 301 169 "http://www.blog.com/?p=1"" Mozilla/5.0 (Windows NT 10.0; Win64 X64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.75 Safari/537.36 "-" 192.168.234.1-[15/Oct/2019:14:48:15 + 0800] "GET / wp-includes/js/comment-reply.min.js?ver=5.2.3 HTTP/1.1" 2234 "http://www.blog.com/?p=1"" Mozilla/5.0 (Windows NT 10.0; Win64 X64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.75 Safari/537.36 ""-"how to build a personal blog site using workpress" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.