lamp配置部署

一 mysql的部署
使用MySQL社区版本
下载源码包
链接
在这里插入图片描述在这里插入图片描述1.解压

tar zxf mysql-boost-5.7.31.tar.gz
[root@server1 bin]# cd /mnt/mysql-5.7.31/
[root@server1 mysql-5.7.31]# ls
archive_output_directory  find_libevent_version.c  rapid
boost                     include                  README
BUILD                     info_macros.cmake        regex
client                    INSTALL                  scripts
cmake                     install_manifest.txt     source_downloads
CMakeCache.txt            libbinlogevents          sql
CMakeFiles                libbinlogstandalone      sql-common
cmake_install.cmake       libmysql                 storage
CMakeLists.txt            libmysqld                strings
cmd-line-utils            libservices              support-files
config.h.cmake            LICENSE                  testclients
configure.cmake           make_dist.cmake          unittest
CPackConfig.cmake         Makefile                 VERSION
CPackSourceConfig.cmake   man                      VERSION.dep
CTestTestfile.cmake       mysql-test               vio
dbug                      mysys                    win
Docs                      mysys_ssl                zlib
Doxyfile-perfschema       packaging
extra                     plugin

2.编译
一定要在顶级路径

[root@server1 mysql-5.7.31]# yum install -y cmake
[root@server1 mysql-5.7.31]# cd boost/boost_1_59_0/
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql

一旦出现报错:

CMake Error: The source directory "/mnt/mysql-5.7.31/boost/boost_1_59_0" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

解决依赖性

yum install ncurses-devel.x86_64 gcc-c++ bison cmake -y
rm -rf CMakeCache.txt
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BOOST=/mnt/mysql-5.7.31/boost/boost_1_59_0

完成后继续编译

[root@server1 mysql-5.7.31]# make

漫长等待到100%
向/usr/local/mysql连续写入数据

[root@server1 mysql-5.7.31]# make install

3.拷贝,为mysql初始化作准备

[root@server1 mysql-5.7.31]# cd /usr/local/mysql/
[root@server1 mysql]# du -sh
1.9G	.
[root@server1 mysql]# ls
bin   include  LICENSE  mysql-test  README-test  support-files
docs  lib      man      README      share
[root@server1 mysql]# cd support-files/
[root@server1 support-files]# ls
magic  mysqld_multi.server  mysql-log-rotate  mysql.server
[root@server1 support-files]# cp mysql.server /etc/init.d/mysqld
[root@server1 support-files]# ll /etc/init.d/mysqld 
-rwxr-xr-x. 1 root root 10576 Apr 10 21:03 /etc/init.d/mysqld
[root@server1 support-files]# cd /mnt/mysql-5.7.31/
[root@server1 mysql-5.7.31]# cd mysql-test/
[root@server1 mysql-test]# pwd
/mnt/mysql-5.7.31/mysql-test
[root@server1 mysql-test]# vim /etc/my.cnf

vim /etc/my.cnf内容
在这里插入图片描述

vim ~/.bash_profile 
[root@server1 bin]# source ~/.bash_profile 
[root@server1 bin]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin:/usr/local/ngnix/sbin:/usr/local/mysql/bin
[root@server1 bin]# useradd -u 1001 -M -d /usr/local/mysql/data -s /sbin/nologin mysql

vim的内容:

在这里插入图片描述4.在/usr/local/mysql下没有data目录,需要做一个初始化
此时如果安装了mariadb需要卸载,不然mysql用户会提示已经存在

[root@server1 bin]# mysqld --initialize --user=mysql
[root@server1 bin]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/usr/local/mysql/data/server1.err'.
 SUCCESS! ``

装密码:

[root@server1 bin]# mysql_secure_installation 

第一次要输入的密码是刚才生成的临时密码,接下来输入自己设置的密码。后面开始前两步都选择回车,后四步都是Y

[root@server1 bin]# mysql -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.7.31 Source distribution

Copyright (c) 2000, 2020, 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.

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

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> 

二 nginx的部署
1.解压
解压后是源码,nginx是C语言,需要源码编译(安装gcc)

[root@server1 mnt]# tar zxf nginx-1.18.0.tar.gz 
[root@server1 mnt]# ls
mysql-5.7.31  mysql-boost-5.7.31.tar.gz  nginx-1.18.0  nginx-1.18.0.tar.gz
[root@server1 mnt]# cd nginx-1.18.0/
[root@server1 nginx-1.18.0]# ls
auto     CHANGES.ru  configure  html     man     src
CHANGES  conf        contrib    LICENSE  README
[root@server1 nginx-1.18.0]# 

进入nginx的目录,如果看见目录中有configure脚本,说明是gmake
gmake:GNU组织的make,开源的
cmake:商业化

[root@server1 nginx-1.18.0]# yum install gcc pcre-devel openssl-devel -y
[root@server1 nginx-1.18.0]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module

完成
2.优化二进制程序
删除之前的内容

[root@server1 nginx-1.18.0]# cd /usr/local/nginx/
[root@server1 nginx]# du -sh 
5.8M	.
[root@server1 nginx]# rm -fr *	//删除,重新来
[root@server1 nginx]# ls
[root@server1 nginx]# du -sh 
0	.

删除之前的nginx的目录,也可以执行make clean命令
关闭debug

[root@server1 nginx]# cd -		//回到源码包中
/test/nginx-1.18.0
[root@server1 nginx-1.18.0]# vim auto/cc/gcc 
###注释172行
[root@server1 nginx-1.18.0]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-file-aio
[root@server1 nginx-1.18.0]# make	//重新编译,当然也可以执行make clean 命令
[root@server1 nginx-1.18.0]# make install
[root@server1 nginx-1.18.0]# cd /usr/local/nginx/
[root@server1 nginx]# du -sh 
984K	.

执行make和make install

make[1]: Leaving directory `/mnt/nginx-1.18.0'

直到出现这一行
3.nginx的启动脚本

[root@server1 nginx]# cd sbin/
[root@server1 sbin]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@server1 sbin]# vim /root/.bash_profile 
[root@server1 sbin]# source /root/.bash_profile
[root@server1 sbin]# cat /root/.bash_profile 
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/local/nginx/sbin	//添加到这里

export PATH
[root@server1 sbin]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin:/usr/local/nginx/sbin
[root@server1 sbin]# which nginx 
/usr/local/nginx/sbin/nginx
[root@server1 sbin]# nginx					//直接启动

4.查看操作系统所用的端口

[root@server1 sbin]# yum install net-tools -y
[root@server1 sbin]# netstat -antlpe
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name    
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      0          57828      17285/nginx: master 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      0          23482      3462/sshd           
tcp        0      0 172.25.44.1:22          172.25.44.250:40788     ESTABLISHED 0          33031      4099/sshd: root@pts 
tcp6       0      0 :::3306                 :::*                    LISTEN      1001       51994      2858/mysqld         
tcp6       0      0 :::22                   :::*                    LISTEN      0          23493      3462/sshd  
[root@server1 sbin]# curl localhost

在这里插入图片描述已经开启了nginx就不能再次重复开启,否则,会报错
因为端口会被冲突了

[root@server1 html]# nginx -s reload	//重载
[root@server1 html]# nginx -s stop		//关闭
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值