Build a blog website based on LAMP
1. First check the LAMP Environment
[root@cairui htdocs]# ps -ef | grep httpdphp 13160 1 0 Mar03 ? 00:00:00 /opt/apache2.2.34/bin/httpd -k startroot 19311 1 0 Mar03 ? 00:00:02 /opt/apache2.2.34/bin/httpd -k gracefulphp 19401 19311 0 Mar03 ? 00:00:00 /opt/apache2.2.34/bin/httpd -k gracefulphp 19402 19311 0 Mar03 ? 00:00:00 /opt/apache2.2.34/bin/httpd -k gracefulphp 19403 19311 0 Mar03 ? 00:00:00 /opt/apache2.2.34/bin/httpd -k gracefulroot 24835 24810 0 09:11 pts/0 00:00:00 grep httpd[root@cairui htdocs]# ps -ef | grep mysqlroot 1470 1 0 Mar01 ? 00:00:00 /bin/sh /opt/mysql-5.7.21/bin/mysqld_safe --datadir=/opt/mysql-5.7.21/data --pid-file=/opt/mysql-5.7.21/data/cairui.pidmysql 1557 1470 0 Mar01 ? 00:02:51 /opt/mysql-5.7.21/bin/mysqld --basedir=/opt/mysql-5.7.21 --datadir=/opt/mysql-5.7.21/data --plugin-dir=/opt/mysql-5.7.21/lib/plugin --user=mysql --log-error=cairui.err --pid-file=/opt/mysql-5.7.21/data/cairui.pidroot 24837 24810 0 09:11 pts/0 00:00:00 grep mysql[root@cairui htdocs]# lsof -i tcp:80COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEAliYunDun 1335 root 18u IPv4 9047 0t0 TCP 120.25.255.87:36408->106.11.68.13:http (ESTABLISHED)httpd 19311 root 3u IPv4 356362 0t0 TCP *:http (LISTEN)httpd 19402 php 3u IPv4 356362 0t0 TCP *:http (LISTEN)httpd 19403 php 3u IPv4 356362 0t0 TCP *:http (LISTEN)[root@cairui htdocs]# lsof -i tcp:3306COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEmysqld 1557 mysql 29u IPv4 9380 0t0 TCP *:mysql (LISTEN)
2. Configure the blog software (wordpress)
WordPress is a blog platform developed in PHP. you can build your own website on servers that support PHP and MySQL databases. WordPress can also be used as a Content Management System (CMS. WordPress is a personal blog system and gradually evolved into a content management system software. It is developed using PHP and MySQL databases. You can use your blog on servers that support PHP and MySQL databases. WordPress has many free templates developed by third parties, which are easy to install. However, to create your own template, you must have some professional knowledge. For example, you must understand at least the HTML code, CSS, PHP, and other related knowledge of an application under the standard General Markup Language. WordPress supports the Chinese version and third-party Chinese language packs developed by enthusiasts, such as the wopus Chinese Language Pack. WordPress has thousands of plug-ins and countless theme template styles.
[root@cairui software]# wget https://wordpress.org/latest.tar.gz--2018-03-04 09:16:34-- https://wordpress.org/latest.tar.gzResolving wordpress.org... 198.143.164.252Connecting to wordpress.org|198.143.164.252|:443... connected.HTTP request sent, awaiting response... 200 OKLength: 8565525 (8.2M) [application/octet-stream]Saving to: “latest.tar.gz”100%[=========================================================>] 8,565,525 2.83M/s in 2.9s 2018-03-04 09:16:38 (2.83 MB/s) - “latest.tar.gz” saved [8565525/8565525][root@cairui software]# lscmake-3.9.6 httpd-2.2.34 latest.tar.gz libiconv-1.15.tar.gz php-7.2.3cmake-3.9.6.tar.gz httpd-2.2.34.tar.gz libiconv-1.15 mysql-5.7.21 php-7.2.3.tar.gz[root@cairui software]# tar zxf latest.tar.gz [root@cairui software]# lscmake-3.9.6 httpd-2.2.34.tar.gz libiconv-1.15.tar.gz php-7.2.3.tar.gzcmake-3.9.6.tar.gz latest.tar.gz mysql-5.7.21 wordpresshttpd-2.2.34 libiconv-1.15 php-7.2.3[root@cairui software]# cd wordpress/[root@cairui wordpress]# lsindex.php wp-admin wp-content wp-load.php wp-signup.phplicense.txt wp-blog-header.php wp-cron.php wp-login.php wp-trackback.phpreadme.html wp-comments-post.php wp-includes wp-mail.php xmlrpc.phpwp-activate.php wp-config-sample.php wp-links-opml.php wp-settings.php[root@cairui wordpress]# cd ..[root@cairui software]# cp wordpress/* /opt/apache/htdocs/cp: overwrite `/opt/apache/htdocs/index.php'? ycp: omitting directory `wordpress/wp-admin'cp: omitting directory `wordpress/wp-content'cp: omitting directory `wordpress/wp-includes'
[root@cairui apache]# mv /home/cairui/software/wordpress/* /opt/apache/htdocs/
The above mv is caused by a cp error. view the Error Log
[Sun Mar 04 09:04:36 2018] [error] [client 114.239.215.144] File does not exist: /opt/apache2.2.34/htdocs/favicon.ico, referer: http://120.25.255.87/
Files are missing, so cp cannot copy them all. use mv
Enter 120.25.20.87 to go To the wordpress settings
3. Configure the database
The database is required for blog installation.
Mysql> create database wordpress default character set gbk collate gbk_chinese_ci; # create a gbk database. The default is the Latin character set Query OK, 1 row affected (0.02 sec) mysql> show databses; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'databse' at line 1 mysql> show databases; + -------------------- + | Database | + -------------------- + | information_schema | managerie | mysql | performance_schema | sys | test | wordpress | + ------------------ + 7 rows in set (0.00 sec) mysql> grant select, delete, insert, update, create on wordpress. * to wordpress @ localhost identified by 'wordpres'; # Set the permission Query OK for the user wordpress, 0 rows affected, 1 warning (0.08 sec) mysql> flush privileges; # refresh permission Query OK, 0 rows affected (0.00 sec) mysql> select user, host from mysql. user; + --------------- + ----------- + | user | host | + --------------- + ----------- + | mysql. session | localhost | mysql. sys | localhost | root | localhost | wordpress | localhost | + --------------- + ----------- + 4 rows in set (0.00 sec) mysql> show grants for wordpress @ localhost; + Grants + | Grants for wordpress @ localhost | + Grants + | grant usage on *. * TO 'wordpres' @ 'localhost' | grant select, INSERT, UPDATE, DELETE, create on 'wordpress '. * TO 'wordpress '@ 'localhost' | + rows + 2 rows in set (0.00 sec)
SET PASSWORD FOR 'wordpress'@'localhost' = PASSWORD('wordpress')
Insufficient permissions, because the httpd. conf user is changed to php
[root@cairui apache]# chown -R php.php /opt/apache/htdocs/[root@cairui apache]# cd htdocs/[root@cairui htdocs]# lsindex.php wp-admin wp-content wp-load.php wp-signup.phplicense.txt wp-blog-header.php wp-cron.php wp-login.php wp-trackback.phpreadme.html wp-comments-post.php wp-includes wp-mail.php xmlrpc.phpwp-activate.php wp-config-sample.php wp-links-opml.php wp-settings.php[root@cairui htdocs]# lltotal 188-rw-r--r-- 1 php php 418 Sep 25 2013 index.php-rw-r--r-- 1 php php 19935 Jan 7 03:32 license.txt-rw-r--r-- 1 php php 7413 Dec 12 2016 readme.html-rw-r--r-- 1 php php 5434 Sep 23 20:21 wp-activate.phpdrwxr-xr-x 9 php php 4096 Feb 6 23:49 wp-admin-rw-r--r-- 1 php php 364 Dec 19 2015 wp-blog-header.php-rw-r--r-- 1 php php 1627 Aug 29 2016 wp-comments-post.php-rw-r--r-- 1 php php 2853 Dec 16 2015 wp-config-sample.phpdrwxr-xr-x 4 php php 4096 Feb 6 23:49 wp-content-rw-r--r-- 1 php php 3669 Aug 20 2017 wp-cron.phpdrwxr-xr-x 18 php php 12288 Feb 6 23:49 wp-includes-rw-r--r-- 1 php php 2422 Nov 21 2016 wp-links-opml.php-rw-r--r-- 1 php php 3306 Aug 22 2017 wp-load.php-rw-r--r-- 1 php php 36583 Oct 13 10:10 wp-login.php-rw-r--r-- 1 php php 8048 Jan 11 2017 wp-mail.php-rw-r--r-- 1 php php 16246 Oct 4 08:20 wp-settings.php-rw-r--r-- 1 php php 30071 Oct 19 01:36 wp-signup.php-rw-r--r-- 1 php php 4620 Oct 24 06:12 wp-trackback.php-rw-r--r-- 1 php php 3065 Sep 1 2016 xmlrpc.php
mysql> use wordpressReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> show tables;+-----------------------+| Tables_in_wordpress |+-----------------------+| wp_commentmeta || wp_comments || wp_links || wp_options || wp_postmeta || wp_posts || wp_term_relationships || wp_term_taxonomy || wp_termmeta || wp_terms || wp_usermeta || wp_users |+-----------------------+12 rows in set (0.01 sec)
Error: the details page cannot be displayed. (The reason is that the link contains Chinese characters. Change the link to English)