Centos7 quickly build blog

一、系统环境
[root@ecs-35f2 ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[root@ecs-35f2 ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether fa:16:3e:49:29:b4 brd ff:ff:ff:ff:ff:ff
inet 192.168.2.181/24 brd 192.168.2.255 scope global dynamic eth0
valid_lft 86260sec preferred_lft 86260sec
inet6 fe80::f816:3eff:fe49:29b4/64 scope link
valid_lft forever preferred_lft forever

 

To facilitate testing, the boot does not start and stop the firewall, the production environment adjusted as needed
[the root @ ECS-35f2 ~] STOP # systemctl firewalld
[@ ECS the root-35f2 ~] # systemctl disable firewalld
disposed = Disabled SELinux
[the root @ ecs- 35f2 ~] # CAT / etc / SELinux / config
# This File Controls The State of the SELinux ON The System.
# the SELINUX = CAN Take One of THESE Three values:
# enforcing - the SELinux Security Policy IS enforced is.
# to permissive - the SELinux Prints Represents warnings INSTEAD . of enforcing
# Disabled - No SELinux Policy IS loaded.
SELINUX Disabled =
# = CAN SELINUXTYPE the Take One of Three TWO values:
# Targeted - Targeted Processes are protected,
# Minimum - Targeted Modification of Policy Only the Selected Processes are protected.. 
# MLS -. Multi Level Security Protection
SELINUXTYPE = Targeted 
two, yum install Apache + PHP + MySQL (LAMP) environment, (or search XAMPP integrated package installed directly, there is not demo)
1, install the Apache
yum installed httpd
[root @ ecs ~ -35f2] # yum the install the httpd -Y
[@ ECS the root-35f2 ~] # RPM -qa | grep the httpd
the httpd-Manual-2.4.6-67.el7.centos.6.noarch
the httpd-Tools-2.4.6- 67.el7.centos.6.x86_64
httpd-2.4.6-67.el7.centos.6.x86_64
start httpd boot and disposed
[the root @ ECS-35f2 ~] # systemctl start httpd.service
[@ ECS the root-35f2 ~] # systemctl enable httpd.service
use the browser to open a local IP View

2, mounting the PHP
yum mounted PHP
[@ ECS the root-35f2 ~] # yum the install PHP-PHP MySQL -Y
[@ ECS the root-35f2 ~] # RPM -qa | grep PHP
PHP-CLI-5.4.16-43. el7_4.x86_64
PHP-MySQL-5.4.16-43.el7_4.x86_64
PHP-Common-5.4.16-43.el7_4.x86_64
PHP-5.4.16-43.el7_4.x86_64
PHP-PDO-5.4.16-43. el7_4.x86_64
create a trailing .php pages directory in the Apache php file and restart the httpd service, testing whether the normal access
[root @ ecs-35f2 ~] # vim /var/www/html/test.php
[root @ ecs ~ -35f2] # systemctl restart httpd.service
[root @ ecs-35f2 ~] # CAT /var/www/html/test.php
<PHP?
phpinfo ();
?>
use your browser to open a local IP View

3, to install the database, Centos7 renamed MariaDB
install yum manner
[the root @ ECS-35f2 ~] # yum the install MariaDB -Y-Server
[@ ECS the root-35f2 ~] # RPM -qa | grep MariaDB
MariaDB-5.5.56-2 .el7.x86_64
MariaDB-Server-5.5.56-2.el7.x86_64
MariaDB-libs-5.5.56-2.el7.x86_64
started and the boot is provided
[the root @ ECS-35f2 ~] # systemctl start mariadb.service
[ root @ ecs-35f2 ~] # systemctl enable mariadb.service
initialization database
[root @ ecs-35f2 ~] # mysql_secure_installation

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 current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for (enter for none ) root: ( Enter the original root password, without the Enter)
the OK, password Used successfully, Moving ON ...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y(是否设置root密码)
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y / n ] y ( whether to remove the anonymous user)
... skipping.

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y / n] n ( whether to prohibit remote root login)
... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y / n] y ( whether to delete the test database)
... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y / n] y ( reload)
... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
Create a database and user wordpress, pay attention to the same value here and inferior installation of wordpress-config.php inside WP
[root @ ecs-35f2 ~] # MySQL-uroot--ppass
is available for purchase at The MariaDB to Monitor . Commands End with; or \ G.
Your MariaDB Connection the above mentioned id IS 7
Server Version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database wpdb character set utf8;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on wpdb.* to 'root'@'localhost' identified by 'pass';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> Exit
Bye
Third, install wordpress, here using wget to download to the local, the download link to the official website: https: //cn.wordpress.org/ 
first yum install wget, and then download the installation package wordpress
[root @ ecs-35f2 ~] # yum install wget -y

[root @ ecs-35f2 ~] # wget https://cn.wordpress.org/wordpress-4.9.1-zh_CN.tar.gz
decompress wordpress installation package and copy all files to / var / www / html, add the config.php-WP
[@ ECS the root-35f2 ~] # -xvzf WordPress the tar-4.9.1-zh_CN.tar.gz
[@ ECS the root-35f2 ~] # LL
Total 9920
-rw -------. On Sep 1138 the root 12 is the root. 1 12:24 Anaconda-the ks.cfg
drwxr XR-4096 65534-X. 5 the nobody 30-Nov 20:20 WordPress
-rw-R & lt - r-- the root 10.13071 million. 1 the root-Nov-30 20:20 4.9 WordPress zh_CN.tar.gz-.1
[the root @ ECS-35f2 ~] -R & lt WordPress CP # / * / var / WWW / HTML /
modify bit here (can be ignored, if the external network to access other pages blank further modification ) [the
root @ ECS-35f2 ~] -R & lt #chown Roo: the root / var / WWW / HTML /

Copy Profile
[root @ ecs-35f2 html] # cp wp-config-sample.php wp-config.php
Alternatively, bother to verify, directly change the permissions
[root @ ecs-35f2 ~] #chmod 777 / var / www / html / wp-config.php
modify wp-config.php configuration file, where user name, password, character encoding is just to initialize the database defined the
[root @ ecs-35f2 HTML] # vim wp-config.php
// ** MySQL settings - specific information from the host you are using ** //
name / ** WordPress database * /
the DEFINE ( 'DB_NAME', 'WPDB');

/ ** MySQL database user name * /
DEFINE ( 'DB_USER', 'the root');

/ ** MySQL database password * /
DEFINE ( 'DB_PASSWORD', 'Pass');

/ ** MySQL host * /
DEFINE ( 'DB_HOST', 'localhost');

When the default / ** Create a data character encoding table * /
DEFINE ( 'db_charset', 'UTF8');

/ ** database finishing type. The uncertainty, do not change * /
DEFINE ( 'DB_COLLATE', '');
restart the database and the httpd
[@ ECS-35f2 the root HTML] # systemctl the restart mariadb.service
[@ ECS-35f2 the root HTML] # systemctl the restart httpd.service
network access test

 

Cloud Hosting public IP access test, due to the need to record 80-port, 88-port therefore modify httpd. It should be noted that point, first modify the port in the web page back to the server to modify httpd port

[@ ECS-35f2 the root HTML] # Vim /etc/httpd/conf/httpd.conf
the Listen 88
either occurs, can pass telnet port, but the web access exceptions, as the network is mapped public IP 192.168.2.181

Restart the httpd service
[root @ ecs-35f2 html] # systemctl restart httpd.service
before encountered a problem, including network access within other cloud host server IP and public IP network are normal, but the machine outside the network to access the public network IP page blank. (Here is a platform for cloud hosting test results)
within the internal network host access other cloud network IP:

Other cloud hosts within the network access the public network IP:

External network devices to access the public network IP server display abnormal picture appears:

Approach is to configure once again successful:
1, WP replace other data name, other do not change.
[root @ ecs-35f2 HTML] # vim WP-config.php
// ** MySQL settings - specific information from the host you are using ** //
name / ** WordPress database * /
the DEFINE ( 'DB_NAME', ' wordpress');

/ ** MySQL database user name * /
DEFINE ( 'DB_USER', 'the root');

/ ** MySQL database password * /
DEFINE ( 'DB_PASSWORD', 'Pass');

/ ** MySQL host * /
DEFINE ( 'DB_HOST', 'localhost');

When the default / ** Create a data character encoding table * /
DEFINE ( 'db_charset', 'UTF8');

/ ** database finishing type. If in doubt, do not change * /
the DEFINE ( 'DB_COLLATE', ''); /
2, re-initialize data and configuration database, use the original password

[root@ecs-35f2 ~]# mysql_secure_installation

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 current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for (enter for none ) root: ( Enter the original root password, without the Enter)
the OK, password Used successfully, Moving ON ...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y(是否设置root密码)
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y / n ] y ( whether to remove the anonymous user)
... skipping.

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y / n] n ( whether to prohibit remote root login)
... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y / n] y ( whether to delete the test database)
... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y / n] y ( reload)
... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

[root@ecs-35f2 ~]# mysql -uroot -ppass
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 7
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database wpdb character set utf8;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on wordpress.* to 'root'@'localhost' identified by 'pass';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> Exit
Bye
then restart httpd and data services, you can visit, and here I remember with 88 port access modified, due to the virtual machine has been deleted not map presentation. carry out!

Guess you like

Origin www.cnblogs.com/xuehu666/p/11057418.html