linux作业

该博客详细介绍了如何在CentOS7系统中安装和配置LAMP(Linux, Apache, MySQL, PHP)环境,包括安装nginx、php、mariadb数据库,并设置了相应的权限和用户。接着,它演示了如何下载和安装WordPress,配置数据库连接,并创建了所需的数据库和用户。最后,文章提到了一些用于测试数据库连接的方法和重要的端口号。
摘要由CSDN通过智能技术生成

一、安装nginx

yum install nginx -y
二、安装php


默认使用9000端口,

 1、安装php
其它版本的系统可能有自带的php5.4;需要手动卸载下。
yum remove php-mysql-5.4 php php-fpm php-common
配置php的第三方源
[root@nginx ~]# vim /etc/yum.repos.d/php.repo
[php-webtatic]
name = PHP Repository
baseurl = http://us-east.repo.webtatic.com/yum/el7/x86_64/
gpgcheck = 0
安装依耐,需要有epel源
yum install libmcrypt-devel
[root@web01 ~]# yum -y install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb
3、统一php和nginx的用户。
## 先创建
[root@web01 ~]# groupadd www -g 666
[root@web01 ~]# useradd www -u666 -g666 -s /sbin/nologin -M
4、让nginx使用www用户
[root@web01 ~]# vi /etc/nginx/nginx.conf 
user  www;
启动nginx,并开机自启。
[root@web01 ~]# systemctl start nginx
[root@web01 ~]# systemctl enable nginx
5、修改php的启动用户,找到相应的配置用户和组的字段配置即可
## 有两个配置文件php-fpm.conf管理php进程的配置文件。
## php.ini管理php程序的相关配置文件。
[root@web01 ~]# vi /etc/php-fpm.d/www.conf 
; Start a new pool named 'www'.
[www]
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = www
; RPM: Keep a group allowed to write in log dir.
group = www
## 启动php,开机自启
[root@web01 ~]# systemctl start php-fpm
[root@web01 ~]# systemctl enable php-fpm
三、安装数据库

1、安装数据库
[root@web01 ~]# yum install -y mariadb-server
2、启动服务,开机自启。
[root@web01 ~]# systemctl start mariadb
[root@web01 ~]# systemctl enable mariadb
3、设置连接数据库的密码。
[root@web01 ~]# mysqladmin -uroot password '123'
4、链接数据库
[root@web01 ~]# mysql -u root -p123
5、创建数据库
MariaDB [(none)]> create database wp;
6、查看数据库
MariaDB [(none)]> show database;
7、创建WordPress连接数据库的用户和密码
MariaDB [(none)]> grant all on wp.* to wp_user@'localhost' identified by '111';
    [root@web01 ~]# vi /etc/my.cnf
    [mysqld]
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    skip_name_resolve
8、给站点目录授权
[root@web01 ~]# chown www.www /code/php/ -R
## 测试是否可以连接数据库的方法。
# 把默认页的代码改成这样访问网站可直接测试:
[root@web02 /code/php]# vi index.php
<?php
    $servername = "localhost";
    $username = "wp_user";
    $password = "111";
    // 创建连接
    $conn = mysqli_connect($servername, $username, $password);
    // 检测连接
    if (!$conn) {
        die("Connection failed: " . mysqli_connect_error());
    }
   ?>
端口:ftp:21、ssh:22、telnet:23、rsync:873、http:80、php:9000、mysql:3306
四、安装wordpress

下载wordpress
wget https://cn.wordpress.org/wordpress-5.4-zh_CN.tar.gz
解压并复制wordpress到nginx根目录下
tar -zxvf wordpress-4.8.1-zh_CN.tar.gz
cp -R wordpress /nginx/html
复制配置文件
cd nginx/html/wordpress/
cp wp-config-sample.php wp-config.php
修改配置文件
vim wp-config.php
配置数据库信息:
/** WordPress数据库的名称 */
define('DB_NAME', 'wpdb');
/** MySQL数据库用户名 */
define('DB_USER', 'wpadmin');
/** MySQL数据库密码 */
define('DB_PASSWORD', 'pass');
/** MySQL主机 */
define('DB_HOST', 'localhost');
/** 创建数据表时默认的文字编码 */
define('DB_CHARSET', 'utf8');
进入mysql并创建wordpress数据库及用户
mysql -u root -p
create database wpdb character set utf8;
grant all privileges on wpdb.* to 'wpadmin'@'localhost' identified by 'pass';
flush privileges;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值