一、编译Mysql
版本5.7.11
源码目录mkdir -p /opt/sourcemysql安装目录 mkdir -p /usr/local/mysqlMySQL数据目录 mkdir -p /webserver/data/mysql创建不能登陆的mysql用户useradd -s /sbin/nologin mysql
下载带boost库版本的源码
cd /opt/sourcewget https://downloads.mysql.com/archives/get/p/23/file/mysql-boost-5.7.11.tar.gz
yum groupinstall 'Development Tools'yum install cmake
yum install ncurses-devel
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 -j4make install
5.3 初始化mysql数据
首先创建mysql用户
cd /usr/local/mysql/bin./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
修改配置如下:
# For advice on how to change settings please see# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the# *** default location during install, and will be replaced if you# *** upgrade to a newer version of MySQL.[client]port=3306socket=/var/lib/mysql/mysql.sock[mysqld]datadir=/webserver/data/mysqlsocket=/var/lib/mysql/mysql.sockinit-connect = 'SET NAMES utf8mb4'character-set-server = utf8mb4skip-name-resolveserver-id=1back_log = 300max_connections = 2000max_connect_errors = 6000open_files_limit = 1024table_open_cache = 128max_allowed_packet = 500Mbinlog_cache_size = 1Mmax_heap_table_size = 8Mtmp_table_size = 16Mread_buffer_size = 2Mread_rnd_buffer_size = 8Msort_buffer_size = 8Mjoin_buffer_size = 8Mkey_buffer_size = 4Mthread_cache_size = 8query_cache_type = 1query_cache_size = 8Mquery_cache_limit = 2Mft_min_word_len = 4log_bin = mysql-binbinlog_format = mixedexpire_logs_days = 7performance_schema = 0#lower_case_table_names = 1skip-external-lockingdefault_storage_engine = InnoDBinnodb_file_per_table = 1innodb_open_files = 500innodb_buffer_pool_size = 64Minnodb_write_io_threads = 4innodb_read_io_threads = 4innodb_thread_concurrency = 0innodb_purge_threads = 1innodb_flush_log_at_trx_commit = 2innodb_log_buffer_size = 2Minnodb_log_file_size = 32Minnodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 90innodb_lock_wait_timeout = 120bulk_insert_buffer_size = 8Mmyisam_sort_buffer_size = 8Mmyisam_max_sort_file_size = 10Gmyisam_repair_threads = 1interactive_timeout = 28800wait_timeout = 28800# Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.# innodb_buffer_pool_size = 128M# Remove leading # to turn on a very important data integrity option: logging# changes to the binary log between backups.# log_bin# These are commonly set, remove the # and set as required.# basedir = .....# datadir = .....# port = .....# server_id = .....# socket = .....# Remove leading # to set options mainly useful for reporting servers.# The server defaults are faster for transactions and fast SELECTs.# Adjust sizes as needed, experiment to find the optimal values.# join_buffer_size = 128M# sort_buffer_size = 2M# read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pidslow_query_log = 1long_query_time = 1[mysqldump]quickmax_allowed_packet = 500M[myisamchk]key_buffer_size = 20Msort_buffer_size = 20Mread_buffer = 2Mwrite_buffer = 2M[mysql]no-auto-rehash[mysqlhotcopy]interactive-timeout
2、创建启动脚本
cp -R /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqld
5.5 启动mysql
mkdir -p /var/run/mysqldchown -R mysql:mysql /var/run/mysqld//etc/init.d/mysqld start
如果出错,可以看日志文件
cat /var/log/mysqld.log
5.6 修改mysql密码
[root@tomato ~]# mysqladmin -uroot -hlocalhost -p password password.lehoon.comEnter password: 输入旧密码默认为空mysqladmin: [Warning] Using a password on the command line interface can be insecure.Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
修改root的密码为password.lehoon.com
5.7 创建用户
--创建数据库create database yigoutong default character set utf8 collate utf8_general_ci;--创建用户create user 'yigoutong'@'localhost' identified by 'yigoutong@lehoon.com';--授权grant select, insert, update,delete,create on yigoutong.* to yigoutong;--所有权限grant all on yigoutong.* to yigoutong;--刷新立即生效flush privileges;
5.8 导入数据库
mysql -ushop -p shop < shop_20200318.sql输入密码,执行完数据就导入数据库
二、编译php7.1.33
cd /opt/sourcewget https://www.php.net/distributions/php-7.1.33.tar.gz解压源码tar zxvf php-7.1.33.tar.gz
vi /etc/ld.so.conf.d/local.conf
添加
/usr/local/lib
/usr/local/lib64
保存,后执行命令ldconfig -v
yum install libxml2 libxml2-develyum -y install openssl-develyum install curl-develyum install libpng -yyum install libpng-devel -yyum -y install libjpeg-develyum -y install freetype-devel
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gztar -zxvf libmcrypt-2.5.7.tar.gzcd libmcrypt-2.5.7./configuremake make install
cd /opt/source/php-7.1.33./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完成后,执行make -j4make install
cp -R /opt/source/php-7.1.33/sapi/fpm/php-fpm.service /usr/lib/systemd/system/systemctl enable php-fpm.service
主要包括:
/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-fpmchown -R nginx:nginx /var/run/php-fpm
2.7.1 yaf扩展
打开 址
https://pecl.php.net/package/yaf 选择合适的版本下载
cd /opt/sourcewget https://pecl.php.net/get/yaf-3.2.5.tgztar zxvf yaf-3.2.5.tgzcd yaf-3.2.5phpizeconfigure --with-php-config=/usr/local/php7.1.33/bin/php-config makemake install
2.7.2 redis扩展
打开 址
https://pecl.php.net/package/redis,下载最新版本
cd /opt/sourcewget https://pecl.php.net/get/redis-5.2.2.tgztar zxvf redis-5.2.2.tgzcd redis-5.2.2phpizeconfigure --with-php-config=/usr/local/php7.1.33/bin/php-configmakemake install
2.7.3 fileinfo扩展
cd /opt/source/php-7.1.33/ext/fileinfophpizeconfigure --with-php-config=/usr/local/php7.1.33/bin/php-configmakemake install
2.7.4 pdo_mysql扩展
cd /opt/source/php-7.1.33/ext/pdo_mysqlphpizeconfigure --with-php-config=/usr/local/php7.1.33/bin/php-configmakemake install
2.7.5 修改php.ini
vi /usr/local/php-7.1.33/etc/php.iniextension=yaf.soextension=redis.soextension=fileinfo.soextension=pdo_mysql.sozend_extension=opcache.so
2.8 启动php-fpm服务
systemctl start php-fpm.service
三、编译nginx
下载nginx最新源码
wget http://nginx.org/download/nginx-1.19.0.tar.gztar zxvf nginx-1.19.0.tar.gzcd nginx-1.19.0./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_modulemake make install
四、编译redis
打开 址
https://github.com/antirez/redis/releases,选择版本下载,需要注意的是6.0版本以上需要gcc 5以上才能编译,所以根据本地gcc版本选择合适的redis版本。
cd /opt/sourcewget https://github.com/antirez/redis/archive/5.0.8.tar.gz -O redis-5.0.8.tar.gztar zxvf redis-5.0.8.tar.gz cd redis-5.0.8makemkdir -p /usr/local/rediscd srccp -R redis-cli /usr/local/redis/cp -R redis-server /usr/local/redis/cp -R redis-check-aof /usr/local/redis/cp -R redis-check-rdb /usr/local/redis/cp -R redis-benchmark /usr/local/redis/cp -R redis-sentinel /usr/local/redis/
创建一个不能登陆的用户redisuseradd -s /sbin/nologin redis
#绑定本地地址bind 127.0.0.1#保护模式protected-mode yes#后台进程模式daemonize yes#添加密码requirepass 963147825#重命名一些高危命令rename-command CONFIG ""rename-command FLUSHALL ""rename-command EVAL ""
#!/bin/bashsudo -u redis /usr/local/redis/redis-server /webserver/redis/redis.conf
通过redis用户运行redis程序
声明:本站部分文章内容及图片转载于互联 、内容不代表本站观点,如有内容涉及侵权,请您立即联系本站处理,非常感谢!