文章目录
- Linux环境(我用的是vmware workstation centos7.6)
- nginx安装目录:/root/vslnmp/nginx.1.16,记得不要在root目录下面进行安装目录的创建,因为这个问题,在安装中出现了权限问题,排查很麻烦。
- php安装目录:/usr/local/lnmp/php/7.0.0
- mysql安装目录:/usr/local/lnmp/mysql.5.7
1. Nginx
1.1 准备工作
- nginx源码包(点击官网下载)
- 上传至linux服务器
[root@localhost src]# ls
nginx-1.16.1.tar.gz
- 安装编译所需工具
[root@localhost src]# yum install gcc gcc-c++ zlib-devel openssl openssl-devel
1.2 安装
# 创建nginx安装目录
[root@localhost ~]# mkdir /root/vslnmp/nginx.1.16
# 解压缩nginx源码包
[root@localhost src]# tar -zxvf nginx-1.16.1.tar.gz
# 进入解压后的目录
[root@localhost nginx-1.16.1]# pwd
/usr/local/src/nginx-1.16.1
[root@localhost nginx-1.16.1]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src
# 编译前工具安装
[root@localhost nginx-1.16.1]# yum install gcc gcc-c++ pcre pcre-devel zlib-devel openssl openssl-devel -y
# 进行编译
[root@localhost nginx-1.16.1]# ./configure --prefix=/root/vslnmp/nginx.1.16 --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre --with-http_gzip_static_module --with-http_dav_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module
# 编译成功后执行安装命令
[root@localhost nginx-1.16.1]# make && make install
# 添加nginx用户
[root@localhost nginx-1.16.1]# useradd -s /sbin/nologin -M nginx
[root@localhost ~]# ln -s /root/vslnmp/nginx.1.16/sbin/nginx /usr/local/sbin/
# 编写服务启动脚本
[root@localhost ~]# vim /etc/init.d/nginx
#!/bin/bash
PROG="/root/vslnmp/nginx.1.16/sbin/nginx"
PIDF="/root/vslnmp/nginx.1.16/logs/nginx.pid"
case "$1" in
start)
$PROG
;;
stop)
kill -3 $(cat $PIDF)
;;
restart)
$0 stop &> /dev/null
if [ $? -ne 0 ] ; then continue ; fi
$0 start
;;
reload)
kill -1 $(cat $PIDF)
;;
*)
echo "Userage: $0 { start | stop | restart | reload }"
exit 1
esac
exit 0
# 启动nginx
[root@localhost ~]# /etc/init.d/nginx start
# 查看是否有nginx进程
[root@localhost ~]# ps -ef|grep nginx
root 13165 1 0 14:26 ? 00:00:00 nginx: master process /root/vslnmp/nginx.1.16/sbin/nginx
root 13166 13165 0 14:26 ? 00:00:00 nginx: worker process
root 13221 7355 0 15:05 pts/1 00:00:00 grep --color=auto nginx
访问nginx页面:http://ip
至此,nginx安装完成
2. mysql
2.1 准备工作
- mysql源码包点击下载
- boost安装包下载
- 上传至linux服务器
[root@localhost src]# ll
total 5351148
-rw-r--r-- 1 root root 83709983 Sep 16 16:48 boost_1_59_0.tar.gz
-rw-r--r-- 1 root root 51433090 Sep 16 15:42 mysql-5.7.17.tar.gz
- 安装编译所需工具
[root@localhost src]# yum install -y gcc gcc-c++ automake autoconf make cmake libtool bison bison-devel ncurses ncurses-devel libaio-devel
2.2 安装
- 编译前准备
# 解压缩 boost与mysql源码包
[root@localhost src]# tar -zxvf mysql-5.7.17.tar.gz
[root@localhost src]# tar -zxvf boost_1_59_0.tar.gz
# 添加mysql用户
[root@localhost src]# useradd -r -g mysql -s /sbin/nologin mysql
# 创建mysql安装目录、数据目录以及boost目录
[root@localhost src]# mkdir /root/vslnmp/mysql.5.7
[root@localhost src]# mkdir /root/vslnmp/mysql.5.7/data
[root@localhost src]# mkdir /usr/local/boost
- 编译安装
# 进入mysql解压目录,进行cmake
[root@localhost src]# cmake -DCMAKE_INSTALL_PREFIX=/root/vslnmp/mysql.5.7 -DMYSQL_UNIX_ADDR=/root/vslnmp/mysql.5.7/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/root/vslnmp/mysql.5.7/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DWITH_BOOST=/usr/local/boost/boost_1_59_0
见如下图表示cmake成功…
<