微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ubuntu最基础的LNMP环境搭建

下载源码

wget http://Nginx.org/download/Nginx-1.8.0.tar.gz

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz

wget http://cn2.PHP.net/get/PHP-5.6.16.tar.gz/from/this/mirror

wget http://www.memcached.org/files/memcached-1.4.25.tar.gz

wget http://dev.MysqL.com/get/Downloads/mysql-5.6/mysql-5.6.28.tar.gz

以上版本太老,几年前用的可自行下载。

一.Nginx安装

1.解压安装,先安装pcre

# useradd -M -s /sbin/nologin Nginx 

# tar -zxvf pcre-8.38.tar.gz 

# apt-get install  make gcc g++ 

# ./configure && make -j2 && make install 

解压Nginx

# tar -zxvf Nginx-1.8.0.tar.gz 

安装依赖

# apt-get install  openssl   libssl-dev 

# ./configure --prefix=/user/local/Nginx   --conf-path=/etc/Nginx.conf --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module  --with-pcre

&& make                                      && make install

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

You can either do not enable the modules, or install the OpenSSL library

into the system, or build the OpenSSL library statically from the source

with Nginx by using --with-openssl=<path> option.

出现错误

# /user/local/Nginx/sbin/Nginx  直接运行启动

 * Starting Nginx Server...                                                                             

/user/local/Nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

                                                                                                  [fail]

跟进情况执行一下操作

# ln -s /usr/local/lib/libpcre.so.1 /lib64         64位

# ln -s /usr/local/lib/libpcre.so.1 /lib            32位

3.配置

#user  nobody

user  Nginx;                              //修改名字
location / {

            root   html;
            index index.PHP  index.html index.htm;

        }

location ~ \.PHP$ {

            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.PHP;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;

        }


location ~ /\.ht {
            deny  all;

        }

二.安装MysqL

1. 解压安装

# useradd -M -s /sbin/nologin MysqL

# apt-get install libncurses5-dev cmake   openssl    libssl-dev   gcc g++

# mkdir  -p  /app/MysqL

# tar -zxvf mysql-5.6.28.tar.gz 

# cmake -DCMAKE_INSTALL_PREFIX=/app/MysqL -DSYSconfdIR=/app/mysq/etc/ -DMysqL_DATADIR=//app/mysq/MysqL_data -DMysqL_TCP_PORT=3306 -DMysqL_UNIX_ADDR=/tmp/MysqLd.sock -DMysqL_USER=MysqL -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMbedDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DENABLE_DOWNLOADS=1  -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/src/boost_1_59_0

# make   &&  make install   

2.启动脚本

# cp support-files/MysqL.server      /etc/init.d/MysqLd

# mkdir  /app/mysq/etc/

# cp support-files/my-default.cnf     /app/MysqL/etc/my.cnf

# chmod +x /etc/init.d/MysqLd 

# update-rc.d MysqLd defaults 

# chown MysqL.MysqL  /data/mysdl/MysqL_data/

# ./scripts/MysqL_install_db  -basedir=/app/mysq  -datadir=/app/mysq/MysqL_data    --defaults-file=/app/MysqL/etc/my.cnf --user=MysqL

# ./bin/MysqL_secure_installation    //执行之前启动MysqL服务

//输入用户名/密码

# /etc/init.d/MysqLd restart

# vim  /etc/profile    //使其可以直接使用MySQL命令
export PATH=$PATH:/app/MysqL/bin

source  /etc/profile

连接进入MysqL     

是否出现套接字的错误

创建一个软连接

三  安装PHP

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum -y install PHP70w*

1.解压,编译

useradd -M -s /sbin/nologin PHP-fpm

# apt-get install libxml2   libxml2-dev

# apt-get install curl  libsasl2-dev

# apt-get install libcurl4-gnutls-dev    libjpeg-dev   libpng12-dev  libfreetype6-dev  

libmcrypt-dev

//之后会安装的很多包

# tar -zxvf PHP-5.6.16.tar.gz

# cd PHP-5.6.16


# ./configure --prefix=/app/PHP --with-config-file-path=/app/PHP/etc --with-MysqL  --with-MysqLi --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir  --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers  --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash   --enable-pcntl --enable-sockets --with-ldap=/usr/lib/x86_64-linux-gnu  --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --with-pear --enable-pdo   --with-pdo-MysqL --with-gettext --enable-exif --enable-wddx --enable-calendar --enable-ftp --enable-dba --enable-sysvmsg --enable-sysvshm   --enable-debug --enable-maintainer-zts --enable-embed --with-pcre-regex --enable-gd-jis-conv


# make &&   make test  &&   make install 

出现缺少ldap 问题

find / -iname libldaP*   //查找出ldap的具体位置,以so 结尾的文件   在编译的选项后面加上路径

找不到ldap.h      软连接。

ln -s /usr/include/ldap.h /usr/lib/x86_64-linux-gnu/

configure: WARNING: unrecognized options: --with-curlwrappers         //问题

2.启动脚本

# cp  PHP.ini-production  /app/PHP/etc/PHP.ini    //不知道在哪里拷贝,使用find命令查

# cp   sapi/fpm/init.d.PHP-fpm /etc/init.d/PHP-fpm 

# chmod u+x  /etc/init.d/PHP-fpm 

# update-rc.d PHP-fpm defaults 

# cd /app/PHP/etc/

# cp PHP-fpm.conf.default PHP-fpm.conf

3.配置方法

vim PHP-fpm.conf 修改用户及组

/etc/init.d/PHP-fpm start

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐