[root@localhost ~]# cat /etc/centos-release //发行版本
CentOS Linux release 7.6.1810 (Core)
[root@localhost ~]# uname -r //内核
3.10.0-957.el7.x86_64
[root@localhost opt]# ls
Discuz_X3.4_SC_UTF8.zip mysql-boost-5.7.20.tar.gz nginx-1.15.9.tar.gz php-7.1.10.tar.bz2 rh
[root@localhost opt]#
[root@localhost sbin]# yum -y install gcc gcc-c++ pcre-devel zlib-devel make
Nginx服务程序默认以nobody身份运行,建议为其创建专门的用户账号,以便更准确地控制其访问权限,增加灵活性、降低安全风险
[root@localhost ~]# useradd -M -s /sbin/nologin nginx
[root@localhost ~]# cd /opt/nginx-1.15.9/
[root@localhost ~]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module
[root@localhost ~]# make && make install
为了使Nginx服务器的运行更加方便,可以为主程序nginx创建链接文件,以便管理员直接执行“nginx"命令就可以调用Nginx的主程序
[root@localhost ~]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ //加入环境变量
[root@localhost ~]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost ~]#
[root@localhost ~]# yum -y install ncurses ncurses-devel bison cmake
[root@localhost ~]# useradd -s /sbin/nogin mysql
[root@localhost ~]# cd /opt/mysql-5.7.20/
[root@localhost 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
[root@localhost mysql-5.7.20]# make && make install
[root@localhost mysql-5.7.20]# chown -R mysql:mysql /usr/local/mysql
[root@localhost mysql-5.7.20]# vim /etc/my.cnf
[client] #client用户程序
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock ##连接数据库的数据端
[mysql] #mysql软件内容
port = 3306 #端口
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysqld] #以后对msq1配置时更多的会针对于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 ##PID文件目录
socket = /usr/local/mysql/mysql.sock ##通讯文件
server-id = 1 ##服务id,在之后的mysql集群中用于标识mysq1服务器
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 ##模块,默认加载
[root@localhost mysql-5.7.20]# chown mysql:mysql /etc/my.cnf
[root@localhost bin]# echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
[root@localhost bin]# echo 'export PATH' >> /etc/profile
[root@localhost bin]# source /etc/profile
[root@localhost bin]# /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
[root@localhost mysql]# cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system //mysql自带控制脚本,直接复制到系统服务文件夹中
[root@localhost mysql]# systemctl start mysqld //开启服务
[root@localhost mysql]# netstat -antp | grep 3306 //查看状态
tcp6 0 0 :::3306 :::* LISTEN 95872/mysqld
[root@localhost mysql]# mysqladmin -uroot -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.
[root@localhost mysql]#
[root@localhost mysql]# yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel curl curl-devel openssl openssl-devel
[root@localhost php-7.1.10]# cd /opt/php-7.1.10/
[root@localhost php-7.1.10]# ./configure --prefix=/usr/local/php --with-mysql-sock=/usr/local/mysql/mysql.sock --with-mysqli --with-zlib --with-curl --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-openssl --enable-fpm --enable-mbstring --enable-xml --enable-session --enable-ftp --enable-pdo --enable-tokenizer --enable-zip
[root@localhost php-7.1.10]# make && make install
[root@localhost ~]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@localhost ~]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
[root@localhost ~]# cp /opt/php-7.1.10/php.ini-development /usr/local/php/lib/php.ini
[root@localhost ~]# vim /usr/local/php/lib/php.ini
[root@localhost ~]# /usr/local/php/sbin/php-fpm -c /usr/local/php/lib/php.ini
[root@localhost ~]# netstat -antp | grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 104224/php-fpm: mas
[root@localhost ~]#
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
LNMP与LAMP相比,由Nginx代替了Apache,PHP在LAMP中只是作为后台程序运行,在LNMP中开启了pid功能,以9000端口的方式运行起来