LAMP:
-
L:linux
-
A:apache (httpd)
-
M:mysql, mariadb
-
P:php, perl, python
wordpress :
WordPress是一个开源的内容管理系统,最初于2003年被开发用来简化个人在线写作,但随着时间的发展,它已经成长为一个全功能的网站框架。WordPress使用PHP编写,使用MySQL作为数据库管理系统。
搭建lamp+wordpress
下载需要的软件包
[root@node1 ~]# yum -y mariadb mariadb-server httpd
启动数据库和httpd
[root@node1 ~]# systemctl restart mariadb
[root@node1 ~]# systemctl enable mariadb
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
[root@node1 ~]#
配置数据库,初始化数据库
[root@node1 ~]# 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
haven't set the root password yet, you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n]
Enabled successfully!
Reloading privilege tables..
... Success!
You already have your root account protected, so you can safely answer 'n'.
Change the 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 // 移除匿名
... Success!
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 // 远程连接
... 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 // 是否删除原来的默认表
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y // 是否同步初始化
... 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@node1 ~]#
安装php
[root@node1 ~]# yum -y install php php-cli php-fpm php-gd php-curl php-zip php-mbstring php-opcache php-intl php-mysqlnd
配置php文件 设置php的时区,并启动php
vim /etc/php.ini
date.timezone = Asia/Shanghai
root@node1 ~]# systemctl enable php-fpm
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
[root@node1 ~]#
为php做一个网页
[root@node1 ~]# cd /var/www/html/
[root@node1 html]# vim index.php
[root@node1 html]# cat index.php
<?php
phpinfo
?>
[root@node1 html]#
更改apache的配置文件,是其支持php的网页
vim /etc/httpd/conf/httpd.conf
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
浏览器访问网页,看到默认的网页,
基本架构已经做好。
基于此架构将wordpress做好
准备好wordpress的包,解压,
[root@node1 software]# ls
wordpress wordpress-6.5.5.tar.gz
[root@node1 software]# cp -r wordpress /var/www/html/ // 移动到默认网页下面
[root@node1 software]# ls /var/www/html/
index.php wordpress
[root@node1 software]#
更改wordpress的所属主所属组,更改权限为775
[root@node1 html]# ll -ld wordpress/
drwxr-xr-x 5 root root 4096 Jul 16 09:47 wordpress/
[root@node1 html]# chown -R apache.apache /var/www/html/wordpress/
[root@node1 html]# ll -ld wordpress/
drwxr-xr-x 5 apache apache 4096 Jul 16 09:47 wordpress/
[root@node1 html]# chmod -R 775 /var/www/html/wordpress/
[root@node1 html]# ll -ld wordpress/
drwxrwxr-x 5 apache apache 4096 Jul 16 09:47 wordpress/
[root@node1 html
为数据库做配置
[root@node1 html]# mysql -u root -p // 登录数据库
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 10.5.22-MariaDB MariaDB Server
Copyright (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 database sjk_db; // 创建数据表
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> create user 'wordpress_user'@'localhost' identified by 'linux' // 设置用户名和密码
-> ;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> grant all on sjk_db.* to 'wordpress_user'@'localhost' // 为用户设置权限
-> ;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> flush privileges; // 同步设置
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]>
使用虚拟主机来配置apache,更改配置文件
[root@node1 html]# cp -r /usr/share/doc/httpd-core/httpd-vhosts.conf /etc/httpd/conf.d
[root@node1 html]# vim /etc/httpd/conf.d/httpd-vhosts.conf
<VirtualHost 192.168.100.10:80>
DocumentRoot "/var/www/html/wordpress"
<Directory "/var/www/html/wordpress">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
配置好配置文件后启动httpd,访问ip查看网页内容
登录