lnmp 编译安装

lnmp 通过一键安装包安装十分简单,但是为了更加熟悉,可以尝试通过编译源码安装,安装过程中,会遇到并解决很多问题,学习到更多内容。

Linux 系统准备

更新系统

安装之前,请确保系统已更新到最新,系统更新方法是:在terminal中输入

1
2
sudo apt-get update
sudo apt-get upgrade

安装 gcc 与 make

1
sudo apt-get install upgrade

安装 nginx

下载源码

http://nginx.org/en/download.html

1
2
3
4
mkdir -p ~/user/person 
cd ~/user/person
wget http://nginx.org/download/nginx-1.10.1.tar.gz
tar -zxf nginx-1.10.1.tar.gz (解压文件)

安装

1
2
3
4
5
cd nginx-1.10.1/
./configure --with-http_ssl_module --user=www-data --group=www-data --prefix=/usr/local/nginx
make
make test(可选)
sudo make install

解决报错

可能出现的错误:

1、./configure: error: the HTTP rewrite module requires the PCRE library.

解决方案:sudo apt-get install libpcre3 libpcre3-dev

2、./configure: error: SSL modules require the OpenSSL library.

解决方案:sudo apt-get install openssl libssl-dev

报错解决后,反复执行make,直到没有错误提示

安装 php

下载源码

http://www.php.net/downloads.php

1
2
cd ~/user/person
tar -zxf php-7.0.8.tar.gz

安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
./configure --prefix=/usr/local/php7 \
--with-readline \
--with-jpeg-dir \
--with-png-dir \
--enable-fpm \
--enable-opcache \
--enable-mbstring \
--enable-zip \
--enable-mysqlnd \
--with-gd \
--with-openssl \
--with-curl \
--with-mcrypt \
--with-pdo-mysql \
--with-fpm-user=www-data \
--with-fpm-group=www-data

make
make test
sudo make install

解决报错

报错:configure: error: xml2-config not found. Please check your libxml2 installation.”
解决方法:sudo apt-get install libxml2 libxml2-dev

报错:”Cannot find OpenSSL’s <evp.h>”
解决方法:sudo apt-get install libcurl4-openssl-dev pkg-config

报错:—with-gd “ configure: error: png.h not found.”
解决方法:sudo apt-get install libpng12-dev libjpeg-dev

报错:—with-mcrypt “configure: error: mcrypt.h not found. Please reinstall libmcrypt.”
解决方法:sudo apt-get install libmcrypt-dev

报错:call to undefined function imagecreatefromjpeg()
解决方法:sudo apt-get install libjpeg62-dev –with-jpeg-dir –with-png-dir

报错:configure error :Please reinstall the lib curl distribution -easy.h should be in / include /curl
解决方法:sudo apt-get install libcurl4-gnutls-dev

报错:configure: error: jpeglib.h not found.
解决方法:# sudo apt-get install libjpeg-dev

报错:configure: error: png.h not found.
解决办法:# sudo apt-get install libpng-dev

报错解决后,反复执行make,直到没有错误提示

安装mariadb

下载源码

1
2
3
4
5
6
sudo apt-get install git
cd user/person/
git clone https://github.com/MariaDB/server.git

fix "server certificate verification failed":
git config --global http.sslverify false

安装

1
2
3
4
cd server
cmake .
make
sudo make install