当前位置:Gxlcms > 数据库问题 > LNMP 源码安装 超详细笔记记录 PHP7 MariaDB 10.1.12

LNMP 源码安装 超详细笔记记录 PHP7 MariaDB 10.1.12

时间:2021-07-01 10:21:17 帮助过:2人阅读

 

LNMP 源码安装 超详细笔记记录   php 7.04 版本 mariaDB  10.1.12 版本    首先安装nginx       一般编译nginx时,都要先安装pcre、zlib等外部支持程序,然后编译安装nginx时指定这些外部支持程序的位置,这样nginx在每次启动的时候,就会去动态加载这些东西了。     下面介绍的是另一种方式,即将这些程序编译到nginx里面去,这样nginx启动时就不会采用动态加载的方式去load。从古谱中可获知,这种方式会比动态加载有更高的效率。       首先 安装 yum install openssl-devel pcre-devel zlib-devel    OpenSSL 库 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。     支持https协议     openssl-fips是符合FIPS标准的Openssl。     联邦信息处理标准(Federal Information Processing Standards,FIPS)是一套描述文件处理、加密算法和其他信息技术标准(在非军用政府机构和与这些机构合作的政府承包商和供应商中应用的标准)的标准。     下载openssl      wget http://www.openssl.org/source/openssl-1.0.1s.tar.gz     解压  tar -zxvf openssl-1.0.1s.tar.gz   PCRE 库 PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括 perl 兼容的正则表达式库。     支持 rewrite     下载 PCRE       wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.20.tar.gz     解压 tar -zxvf pcre2-10.20.tar.gz   zlib库 zlib是提供数据压缩用的函式库 对HTTP包的内容作gzip压缩     支持gzip      下载zlib     wget http://zlib.net/zlib-1.2.8.tar.gz     解压 tar -zxvf zlib-1.2.8.tar.gz   安装 nginx     useradd nginx -M -s /sbin/nologin #给nginx服务器创建后台进程管理用户     下载nginx     wget nginx.org/download/nginx-1.9.12.tar.gz     解压 tar -zxvf nginx-1.9.12.tar.gz     编译到 /usr/local/nginx 下         ./configure --prefix=/usr/local/nginx \     --conf-path=/usr/local/nginx/conf/nginx.conf \     --user=nginx \     --group=nginx \     --with-pcre=/usr/local/src/pcre-8.37 \     --with-zlib=/usr/local/src/zlib-1.2.8 \     --with-openssl=/usr/local/src/openssl-1.0.1s \     --with-threads \     --with-http_stub_status_module \     --with-http_ssl_module \     --with-http_gzip_static_module       //--with-pcre=/usr/local/pcre 源码路径不是安装路径     //--with-zlib=/usr/local/zlib 源码路径不是安装路径     //--with-openssl=/usr/local/openssl 源码路径不是安装路径     // --user=nginx –group=nginx 设置允许nginx允许的用户和组为nginx      // --prefix=/usr/local/nginx/  设置nginx安装路径      // --with-http_stub_status_module 安装允许状态模块      // --with-http_ssl_module 安装ssl模块      // --with-http_gzip_static_module 支持 在线实时压缩输出数据流       启动服务     /usr/local/nginx/sbin/nginx       查看服务是否启动     netstat -tunlp | grep :80   安装mariaDB     添加用户添加组     groupadd -r mysql     useradd -g mysql -r -M -s /sbin/nologin mysql       下载 wget https://downloads.mariadb.org/interstitial/mariadb-10.1.12/source/mariadb-10.1.12.tar.gz/from/http%3A//ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/     这个下载后 名字变为了index.html 重命名下     mv index.html mariadb-10.1.12.tar.gz       解压     tar -zxvf mariadb-10.1.12.tar.gz       编译        cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \     -DINSTALL_DATADIR=/usr/local/mysql/data \     -DDEFAULT_CHARSET=utf8mb4 \     -DDEFAULT_COLLATION=utf8mb4_general_ci \     -DEXTRA_CHARSETS=all \     -DENABLED_LOCAL_INFILE=1       如果出现这样的错误      gmake: *** No targets specified and no makefile found.  Stop     原因没有装 ncurses 库     yum install ncuses ncuses-devel       其他的缺少什么依赖库 就yum install        cd /usr/local/mysql     chown mysql.root * -R       /scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data     cp support-files/my-large.cnf /etc/my.cnf       vi /etc/my.cnf 添加       datadir=/usr/local/mysql/data     cp support-files/mysql.server /etc/init.d/mysqld       添加开机启动     chkconfig --add mysqld      chkconfig mysqld on       开启Mysql     service mysqld start        查看服务是否启动     netstat -tunlp | grep :3306       进入mysql     mysql      会报错,因为 /usr/bin 下找不到mysql     添加软连接       ln -s /usr/local/mysql/bin/mysql /usr/bin     其他错误类似         登录mysql 删除匿名登录用户       use mysql     delete from user where user <> ‘root‘ or host <> ‘localhost‘;       设置密码     set password for ‘root‘@‘localhost‘ = password(‘qing123‘);       资料     http://www.tuicool.com/articles/ARZ77jE      https://mariadb.com/kb/zh-cn/generic-build-instructions/ 通用编译说明页   安装php   首先安装依赖库   libxml  Libxml 函数和常量与 SimpleXML、XSLT 以及 DOM 函数一起使用 这些函数需要 libxml 包 libmcrypt Mcrypt扩展库可以实现加密解密功能 支持一些加密函数 mhash mcrypt zlib  openssl   freetype libjpeg  libpng  libgd 图像处理函数 需要freetype、jpeg、png 支持    curl 支持 curl函数 libiconv 支持 iconv 函数     下面这些后期再装 memcached  redis xhprof 性能测试工具 threads 多进程 swoole 多线程 laravel     开始 为安装php 做准备   安装 libxml2 下载 libxml2 wget ftp://xmlsoft.org/libxml2/libxml2-git-snapshot.tar.gz tar -zxvf libxml2-git-snapshot.tar.gz 安装 到/usr/local/libxml 下   yum install libxml2-devel   ./configure --prefix=/usr/local/libxml   make && make instlal   如果出现了这些错误 libxml.c:3915: 错误:‘libxmlMethods’未声明(在此函数内第一次使用) yum install python-devel 可解决 接着 make clean 清空下之前的编译 再重新编译并 make instlal 其他的库 遇到编译失败均需要 make clean 清空下之前的编译     安装 libmcrypt 下载 wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz  解压 tar -zxvf libmcrypt-2.5.7.tar.gz    yum install libmcrypt-devel  ./configure    make && make install    安装 mhash     wget https://sourceforge.net/projects/mhash/files/latest/download?source=files  mv download\?source\=files mhash-0.9.9.9.tar.gz    tar -zxvf mhash-0.9.9.9.tar.gz    ./configure   make && make instlal    安装 mcrypt wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/mcrypt-2.6.4.tar.gz   tar -zxvf mcrypt-2.6.4.tar.gz   设置下环境变量 否则找不到 libmcrypt mhash export LD_LIBRARY_PATH=/usr/local/lib: LD_LIBRARY_PATH ./configure --prefix=/usr/local/mcrypt   make && make install     安装zlib  ./configure --prefix=/usr/local/zlib make && make install     安装 openssl ./config --prefix=/usr/local/openssl make && make install   安装 freetype   yum install freetype-devel 下载 wget http://download.savannah.gnu.org/releases/freetype/freetype-2.6.3.tar.gz   ./configure --prefix=/usr/local/freetype make && make install    安装libpng  wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/libpng-1.6.21.tar.gz 解压 安装 ./configure --prefix=/usr/local/libpng   make && make install   安装libjpeg  wget http://www.ijg.org/files/jpegsrc.v9b.tar.gz 解压 安装 ./configure --prefix=/usr/local/libjpeg   安装libgd库   下载 这个很慢,建议FQ 然后上传到服务器上面去 wget https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.1.tar.gz    解压 安装 ./configure --prefix=/usr/local/libgd \ --with-zlib=/usr/local/zlib/ \ --with-freetype=/usr/local/freetype/ \ --with-png=/usr/local/libpng/ \ --with-jpeg=/usr/local/jpeg/   安装curl   wget https://curl.haxx.se/download/curl-7.47.1.tar.gz   解压 安装 ./configure --prefix=/usr/local/curl make && make install   安装 libiconv wget http://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz 解压 安装 ./configure --prefix=/usr/local/libiconv make && make install   wget http://xorg.freedesktop.org/archive/individual/lib/libXpm-3.5.10.tar.gz   解压 安装    ./configure --prefix=/usr/local/libXpm make && make install    安装 php    yum install libXpm libXpm-devel 不然make时报错  rpm -ql libXpm 下看看 libXpm 装在哪 下面 --with-xpm-dir=/path     ./configure --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php/etc \ --with-mcrypt=/usr/local/mcrypt \ --with-mysqli=/usr/local/mysql/bin/mysql_config \ --with-pdo-mysql=/usr/local/mysql \ --with-iconv-dir=/usr/local/libiconv \ --with-zlib-dir=/usr/local/zlib \ --with-libxml-dir=/usr/local/libxml \ --with-jpeg-dir=/usr/local/jpeg \ --with-png-dir=/usr/local/libpng \ --with-freetype-dir=/usr/local/freetype \ --with-gd=/usr/local/libgd \ --with-curl=/usr/local/curl \ --with-xpm-dir=/usr/local/libXpm \ --enable-xml \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-inline-optimization \ --enable-mbregex \ --enable-fpm \ --enable-mbstring \ --enable-ftp \ --enable-gd-native-ttf \ --with-openssl \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-zip \ --enable-soap \ --without-pear \ --with-gettext \ --enable-session \ --enable-opcache   make && make install   cp php.ini-production /usr/local/php/etc/php.ini cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm   cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf   开启opcache vim /usr/local/php/etc/php.ini zend_extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/opcache.so     开启 php-fpm   service php-fpm start   查看下php 版本信息  /usr/local/php/bin/php -v   整个nginx 和 php   vim /usr/local/nginx/conf/nginx.conf 这里 location / {             root   html;             index  index.html index.htm; } 修改为 location / {             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;    }   重启nginx 服务   /usr/local/nginx/sbin/nginx -s reload   编辑个php文件,然后用phpinfo();测试下   接下来在网站访问 其他类型文件时会出现错误   查询error.log日志 FastCGI sent in stderr: "Access to the script ‘/usr/local/nginx/html/index.html‘ has been denied (see security.limit_extensions)" while reading 。。   需要修改 php-fpm 的配置文件   我的是 在/usr/local/php/etc/php-fpm.conf 里面包含了www.conf配置   找到security.limit_extensions把他修改为: security.limit_extensions=.php .html .js .css .jpg .jpeg .gif .png .htm#(常用的文件扩展名)   重启 php-fpm 服务    现在你可以嗨了

LNMP 源码安装 超详细笔记记录 PHP7 MariaDB 10.1.12

标签:

人气教程排行