安装部署LNMP架构及Nginx、MYSQL、PHP+论坛

一,Nginx 安装

nginx 安装
yum install gcc gcc-c++ pcre-devel zlib-devel make    // 安装依赖包

useradd -M -s /sbin/nologin nginx

cd /opt

rz 
unzip LNMP-C7-6.22.zip

ls  //查看一下

tar zxvf nginx-1.15.9.tar.gz
cd nginx-1.15.9 

[root@localhost nginx-1.15.9]# ./configure /
./configure: error: invalid option "/"
[root@localhost nginx-1.15.9]# ./configure \
> --prefix=/usr/local/nginx \
> --user=nginx \
> --group=nginx \
> --with-http_stub_status_module

make && make install

nginx -t

 vim /lib/systemd/system/nginx.service

[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
PIDFile =/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/bin/kill -S HUP $MAINPID
ExecStop=/usr/bin/kill -S QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

[root@localhost nginx-1.15.9]# chmod 777 /lib/systemd/system/nginx.service
[root@localhost nginx-1.15.9]# systemctl stop nginx
[root@localhost nginx-1.15.9]# systemctl start nginx
[root@localhost nginx-1.15.9]# systemctl status nginx
● nginx.service - nginx
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: active (running) since 五 2021-06-25 15:16:56 CST; 27s ago
  Process: 12386 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=0/SUCCESS)
 Main PID: 12388 (nginx)
    Tasks: 2
   CGroup: /system.slice/nginx.service
           ├─12388 nginx: master process /usr/local/nginx/sbin/nginx
           └─12390 nginx: worker process

6月 25 15:16:56 localhost.localdomain systemd[1]: Starting nginx...
6月 25 15:16:56 localhost.localdomain systemd[1]: Failed to read PID from file...t
6月 25 15:16:56 localhost.localdomain systemd[1]: Started nginx.
Hint: Some lines were ellipsized, use -l to show in full.

[root@localhost nginx-1.15.9]# ss -antp | grep 80
LISTEN     0      128          *:80                       *:*                   users:(("nginx",pid=12390,fd=6),("nginx",pid=12388,fd=6))

在这里插入图片描述
安装MySQL服务

yum -y install ncyum -y install \
> ncurses \
> ncurses-devel \
> bison \
> cmake

 useradd -s /sbin/nologin mysql
#为mysql创建一个管理用户mysql

 cd /opt
 tar xzvf mysql-boost-5.7.20.tar.gz 
 ls
Discuz_X3.4_SC_UTF8.zip  mysql-boost-5.7.20.tar.gz  php-7.1.10.tar.bz2
LNMP-C7-6.22.zip         nginx-1.15.9               rh
mysql-5.7.20             nginx-1.15.9.tar.gz
 cd mysql-5.7.20/


[root@client mysql-5.7.20]# cmake \       ##开始进行编译
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
> -DSYSCONFDIR=/etc \
> -DSYSTEMD_PID_DIR=/usr/local/mysql \
> -DDEFAULT_CHARSET=utf8  \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
> -DMYSQL_DATADIR=/usr/local/mysql/data \
> -DWITH_BOOST=boost \
> -DWITH_SYSTEMD=1

 make && make install
 chown -R mysql.mysql /usr/local/mysql/

chown mysql.mysql /etc/my.cnf
#修改文件,mysql 可以通过sql_mode 来控制mysql 数据库的行为
 vim /etc/my.cnf

[client]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock

[mysql]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock

[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
character_set_server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES


 echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
echo 'export PATH' >> /etc/profile
 source /etc/profile

#初始化数据库
[root@client ~]# cd /usr/local/mysql/bin/
[root@client bin]# bin/mysqld \
> --initialize-insecure \
> --user=mysql \
> --basedir=/usr/local/mysql \
> --datadir=/usr/local/mysql/data



#用systemctl启动mysql
 cp usr/lib/systemd/system/mysqld.service /lib/systemd/system
 systemctl start mysqld.service
 netstat -antp | grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN      103161/mysqld  

#为mysql创建管理账户root,密码为abc123 
mysqladmin -u root -p password
Enter password: 
New password: 
Confirm new password: 
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

 mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.20 Source distribution

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

安装论坛

unzip Discuz_X2.5_SC_UTF8.zip
 ls
apr-1.6.2.tar.gz       Discuz_X2.5_SC_UTF8.zip  mysql-5.6.26         php-5.6.11.tar.bz2
apr-util-1.6.0.tar.gz  httpd-2.4.29             mysql-5.6.26.tar.gz  rh
dis                    httpd-2.4.29.tar.bz2     php-5.6.11
 cd dis
 ls
readme  upload  utility
 cp -r upload/ /usr/local/httpd/htdocs/bbq
cd /usr/local/httpd/htdocs/
 ls
bbq  index.php
 ls bbq
cd bbq
 ls
 chown -R daemon ./config
 chown -R daemon ./data
chown -R daemon ./uc_client
 chown -R daemon ./uc_server/data

在这里插入图片描述

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值