基于lnmp的网站源码分享 lnmp平台

大家好,关于基于lnmp的网站源码分享很多朋友都还不太明白,今天小编就来为大家分享关于lnmp平台的知识,希望对各位有所帮助!

一、编译Mysql

版本5.7.11

1、目录

源码目录\n\nmkdir-p/opt/source\n\nmysql安装目录\n\nmkdir-p/usr/local/mysql\n\nMySQL数据目录\n\nmkdir-p/webserver/data/mysql\n\n创建不能登陆的mysql用户\n\nuseradd-s/sbin/nologinmysql

2下载mysql源码

下载带boost库版本的源码

cd/opt/source\n\nwgethttps://downloads.mysql.com/archives/get/p/23/file/mysql-boost-5.7.11.tar.gz

3、安装编译环境

yumgroupinstall&39;\n\nyuminstallcmake

4安装依赖库文件

yuminstallncurses-devel

5编译mysql

5.1生成makefile

cmake.-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/webserver/data/mysql-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DMYSQL_TCP_PORT=3306-DMYSQL_USER=mysql-DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DWITH_MEMORY_STORAGE_ENGINE=1-DWITH_BOOST=/opt/source/mysql-5.7.11/boost

5.2编译mysql

make-j4\n\nmakeinstall

5.3初始化mysql数据

首先创建mysql用户

cd/usr/local/mysql/bin\n\n./mysqld–initialize-insecure–user=mysql–basedir=/usr/local/mysql–datadir=/webserver/data/mysql

执行完后会提示一个root的密码

5.4配置mysql环境

1、生成my.cnf文件

cp/usr/local/mysql/support-files/my-default.cnf/etc/my.cnf

修改配置如下:

http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html\n\n39;satemplatewhichwillbecopiedtothe\n\n***upgradetoanewerversionofMySQL.\n\n[client]\n\nport=3306\n\nsocket=/var/lib/mysql/mysql.sock\n\n[mysqld]\n\ndatadir=/webserver/data/mysql\n\nsocket=/var/lib/mysql/mysql.sock\n\ninit-connect=&39;\n\ncharacter-set-server=utf8mb4\n\nskip-name-resolve\n\nserver-id=1\n\nback_log=300\n\nmax_connections=2000\n\nmax_connect_errors=6000\n\nopen_files_limit=1024\n\ntable_open_cache=128\n\nmax_allowed_packet=500M\n\nbinlog_cache_size=1M\n\nmax_heap_table_size=8M\n\ntmp_table_size=16M\n\nread_buffer_size=2M\n\nread_rnd_buffer_size=8M\n\nsort_buffer_size=8M\n\njoin_buffer_size=8M\n\nkey_buffer_size=4M\n\nthread_cache_size=8\n\nquery_cache_type=1\n\nquery_cache_size=8M\n\nquery_cache_limit=2M\n\nft_min_word_len=4\n\nlog_bin=mysql-bin\n\nbinlog_format=mixed\n\nexpire_logs_days=7\n\nperformance_schema=0\n\nRemoveleadingcacheinMySQL.Startat70%oftotalRAMfordedicatedserver,else10%.\n\nRemoveleadingchangestothebinarylogbetweenbackups.\n\nThesearecommonlyset,removethebasedir=…..\n\nport=…..\n\nsocket=…..\n\ntosetoptionsmainlyusefulforreportingservers.\n\nAdjustsizesasneeded,experimenttofindtheoptimalvalues.\n\nsort_buffer_size=2M\n\nmysqladmin-uroot-hlocalhost-ppasswordpassword.lehoon.com\n\nEnterpassword:输入旧密码默认为空\n\nmysqladmin:[Warning]Usingapasswordonthecommandlineinterfacecanbeinsecure.\n\nWarning:Sincepasswordwillbesenttoserverinplaintext,usesslconnectiontoensurepasswordsafety.

修改root的密码为password.lehoon.com

5.7创建用户

–创建数据库\n\ncreatedatabaseyigoutongdefaultcharactersetutf8collateutf8_general_ci;\n\n–创建用户\n\ncreateuser&39;@&39;identifiedby&39;;\n\n–授权\n\ngrantselect,insert,update,delete,createonyigoutong.*toyigoutong;\n\n–所有权限\n\ngrantallonyigoutong.*toyigoutong;\n\n–刷新立即生效\n\nflushprivileges;

5.8导入数据库

mysql-ushop-pshop<shop_20200318.sql\n\n输入密码,执行完数据就导入数据库

二、编译php7.1.33

2.1下载源码

cd/opt/source\n\nwgethttps://www.php.net/distributions/php-7.1.33.tar.gz\n\n解压源码\n\ntarzxvfphp-7.1.33.tar.gz

2.2修改ld路径

vi/etc/ld.so.conf.d/local.conf

添加

/usr/local/lib

/usr/local/lib64

保存,后执行命令ldconfig-v

2.3安装依赖库文件

yuminstalllibxml2libxml2-devel\n\nyum-yinstallopenssl-devel\n\nyuminstallcurl-devel\n\nyuminstalllibpng-y\n\nyuminstalllibpng-devel-y\n\nyum-yinstalllibjpeg-devel\n\nyum-yinstallfreetype-devel

2.3.1安装mcrypt库

wgetftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz\n\ntar-zxvflibmcrypt-2.5.7.tar.gz\n\ncdlibmcrypt-2.5.7\n\n./configure\n\nmake\n\nmakeinstall

2.4编译php

cd/opt/source/php-7.1.33\n\n./configure–prefix=/usr/local/php7.1.33–exec-prefix=/usr/local/php7.1.33–bindir=/usr/local/php7.1.33/bin–sbindir=/usr/local/php7.1.33/sbin–includedir=/usr/local/php7.1.33/include–libdir=/usr/local/php7.1.33/lib/php–mandir=/usr/local/php7.1.33/php/man–with-config-file-path=/usr/local/php7.1.33/etc–with-mysql-sock=/var/lib/mysql/mysql.sock–with-mcrypt=/usr/include–with-mhash–with-openssl–with-mysqli=shared,mysqlnd–with-pdo-mysql=shared,mysqlnd–with-gd–with-iconv–with-zlib–enable-zip–enable-inline-optimization–disable-debug–disable-rpath–enable-shared–enable-xml–enable-bcmath–enable-shmop–enable-sysvsem–enable-mbregex–enable-mbstring–enable-ftp–enable-gd-native-ttf–enable-pcntl–enable-sockets–with-xmlrpc–enable-soap–without-pear–disable-phar–with-gettext–enable-session–with-curl–with-jpeg-dir–with-freetype-dir–enable-opcache–enable-fpm–with-fpm-user=nginx–with-fpm-group=nginx–without-gdbm–disable-fileinfo\n\n完成后,执行\n\nmake-j4\n\nmakeinstall

2.5安装服务

cp-R/opt/source/php-7.1.33/sapi/fpm/php-fpm.service/usr/lib/systemd/system/\n\nsystemctlenablephp-fpm.service

2.6编辑php-fpm配置文件

主要包括:

/usr/local/php-7.1.33/etc/php.ini

/usr/local/php-7.1.33/etc/php-fpm.conf

/usr/local/php-7.1.33/etc/php-fpm.d/www.conf

同时创建sock文件目录

mkdir-p/var/run/php-fpm\n\nchown-Rnginx:nginx/var/run/php-fpm

2.7编译扩展

2.7.1yaf扩展

打开网址https://pecl.php.net/package/yaf选择合适的版本下载

cd/opt/source\n\nwgethttps://pecl.php.net/get/yaf-3.2.5.tgz\n\ntarzxvfyaf-3.2.5.tgz\n\ncdyaf-3.2.5\n\nphpize\n\nconfigure–with-php-config=/usr/local/php7.1.33/bin/php-config\n\nmake\n\nmakeinstall

2.7.2redis扩展

打开网址https://pecl.php.net/package/redis,下载最新版本

cd/opt/source\n\nwgethttps://pecl.php.net/get/redis-5.2.2.tgz\n\ntarzxvfredis-5.2.2.tgz\n\ncdredis-5.2.2\n\nphpize\n\nconfigure–with-php-config=/usr/local/php7.1.33/bin/php-config\n\nmake\n\nmakeinstall

2.7.3fileinfo扩展

cd/opt/source/php-7.1.33/ext/fileinfo\n\nphpize\n\nconfigure–with-php-config=/usr/local/php7.1.33/bin/php-config\n\nmake\n\nmakeinstall

2.7.4pdo_mysql扩展

cd/opt/source/php-7.1.33/ext/pdo_mysql\n\nphpize\n\nconfigure–with-php-config=/usr/local/php7.1.33/bin/php-config\n\nmake\n\nmakeinstall

2.7.5修改php.ini

vi/usr/local/php-7.1.33/etc/php.ini\n\nextension=yaf.so\n\nextension=redis.so\n\nextension=fileinfo.so\n\nextension=pdo_mysql.so\n\nzend_extension=opcache.so

2.8启动php-fpm服务

systemctlstartphp-fpm.service

三、编译nginx

下载nginx最新源码

wgethttp://nginx.org/download/nginx-1.19.0.tar.gz\n\ntarzxvfnginx-1.19.0.tar.gz\n\ncdnginx-1.19.0\n\n./configure–prefix=/usr/local/nginx–with-file-aio–user=nginx–group=nginx–with-http_stub_status_module–with-http_ssl_module–with-http_gzip_static_module\n\nmake\n\nmakeinstall

四、编译redis

4.1下载源码

打开网址https://github.com/antirez/redis/releases,选择版本下载,需要注意的是6.0版本以上需要gcc5以上才能编译,所以根据本地gcc版本选择合适的redis版本。

cd/opt/source\n\nwgethttps://github.com/antirez/redis/archive/5.0.8.tar.gz-Oredis-5.0.8.tar.gz\n\ntarzxvfredis-5.0.8.tar.gz\n\ncdredis-5.0.8\n\nmake\n\nmkdir-p/usr/local/redis\n\ncdsrc\n\ncp-Rredis-cli/usr/local/redis/\n\ncp-Rredis-server/usr/local/redis/\n\ncp-Rredis-check-aof/usr/local/redis/\n\ncp-Rredis-check-rdb/usr/local/redis/\n\ncp-Rredis-benchmark/usr/local/redis/\n\ncp-Rredis-sentinel/usr/local/redis/

4.2创建用户

创建一个不能登陆的用户redis\n\nuseradd-s/sbin/nologinredis

4.3修改配置

保护模式\n\nprotected-modeyes\n\n添加密码\n\nrequirepass963147825\n\n34;&34;&34;&!/bin/bash\n\nsudo-uredis/usr/local/redis/redis-server/webserver/redis/redis.conf

通过redis用户运行redis程序

好了,本文到此结束,如果可以帮助到大家,还望关注本站哦!

Published by

风君子

独自遨游何稽首 揭天掀地慰生平