ubuntu 搭建(编译)生产力版的LNMP环境

来源:互联网 发布:js隐藏标签 编辑:程序博客网 时间:2024/06/18 05:02

ubuntu 搭建(编译)生产力版的LNMP环境

解释一下什么是LNMP

Linux+Nginx+Mysql+php 的服务器环境

ps:

这段时间工作实在是太忙了,好不容易抽点时间写写博客,mysql的安装就直接apt-get了
解决mysql的中文字符集乱码就看我另一篇博文

准备的材料


ubuntu 15.10 64位
nginx 1.8.1 源码
php 7.0.2 源码
OpenSSL 1.0.1r 源码
zlib 1.2.8 源码
pcre 8.38 源码

首先先配置编译环境


apt-get install build-essential
apt-get install libtool

安装 Nginx 依赖包 OpenSSL zlib pcre

ps:建议不要用wegt方式现在,直接到相关的官网去下载源码包,我用的版本是

OpenSSL  1.0.1rzlib     1.2.8pcre     8.38

将源码都解压放置/usr/local/src

安装 OpenSSL


cd openssl-1.0.1r/
./config --prefix=/usr/local --openssldir=/usr/local/ssl
make && make install
./config shared --prefix=/usr/local --openssldir=/usr/local/ssl
make clean
make && make install

安装 zlib 库


cd zlib-1.2.8/
./configure --prefix=/usr/local
make && make install

安装 pcre 库


cd pcre-8.38/
./configure --prefix=/usr/local
make && make install

安装 Nginx

将源码都解压放置/usr/local/src


cd nginx-1.8.1/
./configure --sbin-path=/usr/local/nginx/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--with-http_ssl_module \
--with-pcre=/usr/local/src/pcre-8.39 \
--with-zlib=/usr/local/src/zlib-1.2.8 \
--with-openssl=/usr/local/src/openssl-1.0.1r
make
make install

启动Nginx


cd /usr/local/nginx
./nginx

编译安装php7

将源码都解压放置/usr/local/src


cd php-7.0.2
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts
make
make install

期间遇到的错误和解决方案

错误


configure: error: xml2-config not found. Please check your libxml2 installation.

解决


apt-get install libxml2-dev

错误


configure: error: Please reinstall the libcurl distribution -easy.h should be in <curl-dir>/include/curl/

解决


apt-get install libcurl4-gnutls-dev

错误


configure: error: jpeglib.h not found.

解决


apt-get install libjpeg-dev

错误


configure: error: png.h not found.

解决


apt-get install libpng-dev

错误


configure: error: freetype-config not found.

解决


apt-get install libfreetype6-dev

错误


configure: error: mcrypt.h not found. Please reinstall libmcrypt.

解决


apt-get install libmcrypt-dev

php7与nginx集成


cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
cd /usr/local/php/etc/php-fpm.d
cp www.conf.default www.conf
vim www.conf
修改
user = www-data
group = www-data
如果www-data用户不存在,那么先添加www-data用户
groupadd www-data
useradd -g www-data www-data

启动php-fpm


/usr/local/php/sbin/php-fpm

0 0
原创粉丝点击