ubuntu 搭建(編譯)生產力版的LNMP環境

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.1r
zlib     1.2.8
pcre     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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章