新服务器环境部署(nginx 1.14.2+ php7.2.8+mysql.8.0.14+redis4.0.11)

 

  • 服务器环境部署(nginx 1.14.2+ php7.2.8+mysql.8.0.14+redis4.0.11

 

安装包在/data/MySofts或/MySofts目录下

安装注意事项:./confgure后面的参数与参数间不要有多余空格,不然可能会报错误。

word文档的单行多字符时,单空格有时看起来像多个空格,可以先复制到记事本查看)

 

1. 安装相关依赖软件包

 

yum -y install gcc make libpng libpng-devel libjpeg-devel curl-devel bzip2 bzip2-devel openssl-devel libxml2-devel pcre-devel freetype-devel gmp-devel openldap openldap-devel readline-devel perl

 

yum -y install redhat-rpm-config.noarch libxml2 libxml2-dev libxslt-devel gd-devel perl perl-devel perl-ExtUtils-Embed GeoIP GeoIP-devel GeoIP-data

 

yum  install  libtool-ltdl-devel  libtool libtool-ltdl

 

yum -y install openssl openssl-devel.i686

 

2. 安装php7.2.8

tar  -xf php.7.2.8.tar.gz

cd  php.7.2.8

./configure '--prefix=/usr/local/php' '--with-config-file-path=/usr/local/php/etc' '--with-bz2' '--with-curl' '--enable-ftp' '--enable-sockets' '--disable-ipv6' '--with-gd' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-freetype-dir=/usr/local' '--with-iconv-dir=/usr/local' '--enable-mbstring' '--enable-calendar' '--with-gettext' '--with-ldap' '--with-libxml-dir=/usr/local' '--with-zlib' '--with-pdo-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--enable-dom' '--enable-xml' '--enable-fpm' '--with-libdir=lib64' '--enable-bcmath' '--with-openssl' --with-zlib-dir --enable-calendar --enable-exif '--with-gmp' '--with-mhash' '--with-openssl' --enable-pcntl --with-pcre-jit --with-pcre-dir --with-readline

make && make installl

cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

cp /MySoft/etc_init/php-fpmd /etc/inint.d/

useradd wwww –s /sbin/nologin

chkconfig php-fpmd --add

service php-fpmd start

(相关配置文件可以用现在已有的配置文件,保持环境的一致)

(主要扩展是:redisswooleeventsocketpcntl,socketpcntl上面已经装好)

 

下面主要安装redis、swoole、event扩展功能

A –---安装redis扩展

tar –xf redis-4.2.0.tgz

cd redis-4.2.0

phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make && make install

vim /usr/local/php/etc/php.ini

...

extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/redis.so

...

 

B –---安装swoole扩展

tar -xf swoole-4.2.9.tgz

cd swoole-4.2.9/

phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make && make install

vim /etc/php.ini

....

extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/swoole.so

....

 

B –---安装event扩展

tar -zxvf libevent-2.1.8-stable.tar.gz

cd libevent-2.1.8

./configure --prefix=/usr/local/libevent

 make && make install

 

tar -zxvf event-2.3.0.tar.tgz

cd  event-2.3.0.tar

phpize

./configure --with-php-config=/usr/local/php7/bin/php-config --with-event-libevent-dir=/usr/local/libevent/

make && make install

vim /usr/local/php/etc/php.ini

...

extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/event.so

...

 

3. 安装nginx 1.14.2

tar  -xf nginx 1.14.2.tar.gz

cd  nginx 1.14.2

useradd nginx –s /sbin/login

 

./configure --prefix=/usr/local/nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'

make && make installl

cp  /usr/local/nginx/conf/nginx.conf.default /usr/local/nginx/conf/nginx.conf

cp /MySoft/etc_init/nginxd /etc/inint.d/

chkconfig nginxd --add

service nginxd start

(相关配置文件可以用现在已有的配置文件,保持环境的一致)

 

4. 安装redis4.0.11

tar –xf redis4.0.11.tar.gz

mv  redis4.0.11  /usr/local/redis

cd  /usr/local/redis

make

cd /usr/local/redis/utils

mkdir /data/redis/6388 -p

./install_server.sh

Welcome to the redis service installer

This script will help you easily set up a running redis server

 

Please select the redis port for this instance: [6379] 6388     

Please select the redis config file name [/etc/redis/6388.conf]

Selected default - /etc/redis/6388.conf

Please select the redis log file name [/var/log/redis_6388.log] /data/redis/6388

Please select the data directory for this instance [/var/lib/redis/6388] /usr/local/redis/src/redis-server

.....

(红色部分要输入,其它都回车即可)

修改配置,设置密码

Vim /etc/redis/6388.conf     

....

requirepass Fitcom2015jiankangyun1234

....

设置开机自启和启动服务

chkconfig redis_6388 --add

service redis_6388 start

 

5. 安装mysql8.0.14

yum -y remove mariadb-libs.x86_64          //安装前请先删除或禁止其它已安装mysql相关版本

yum install -y libaio

groupadd mysql

useradd  -g mysql –s /sbin/login mysql

tar mysql-8.0.14-el7-x86_64.tar.gz

mv mysql-8.0.14-el7-x86_64 /usr/local/mysql     //mysql8主程序目录,默认目录位置/usr/local/mysql

mkdir /data/mysql8/data                     //mysql8 数据存放目录

chown -R mysql:mysql mysql8/data

chmod -R 777 /data/mysql8/log

  1. 创建mysql8配置文件

vim /etc/my.cnf

[mysqld]

pid-file        = /data/mysql8/mysqld.pid

socket          = /data/mysql8/mysqld.sock

basedir         = /usr/local/mysql

datadir         = /data/mysql8/data

 

# 日志相关

slow_query_log=ON

log_error ="/data/mysql8/log/error.log"

slow_query_log_file="/data/mysql8/log/blg-slow.log"

long_query_time=2

log_queries_not_using_indexes = 1

log_throttle_queries_not_using_indexes = 10

expire_logs_days = 90

min_examined_row_limit = 100

log_output=TABLE,FILE

general_log=1

 

# binlog设置

master_info_repository = TABLE

relay_log_info_repository = TABLE

log_bin = bin.log

server-id=69

 

# innodb 优化设置

default_storage_engine = InnoDB

innodb_file_per_table = 1

innodb_open_files = 500

innodb_buffer_pool_size = 1024M

innodb_write_io_threads = 4

innodb_read_io_threads = 4

innodb_thread_concurrency = 0

innodb_purge_threads = 1

innodb_flush_log_at_trx_commit = 2

innodb_log_buffer_size = 2M

innodb_log_file_size = 32M

innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 90

innodb_lock_wait_timeout = 120

innodb_buffer_pool_load_at_startup = 1

innodb_buffer_pool_dump_at_shutdown = 1

innodb_lru_scan_depth = 2000

innodb_io_capacity = 4000

innodb_io_capacity_max = 8000

 

# 默认参数设置

default-time-zone = '+8:00'

secure-file-priv= NULL

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

character-set-server = utf8mb4

collation-server = utf8mb4_unicode_ci

default_authentication_plugin=mysql_native_password

sql_mode='NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES'

# # Custom config should go here

#!includedir /etc/mysql/conf.d/

 

#----------------其它优化 (说明从上到下)

# 支持符号链接,就是可以通过软连接的方式,管理其他目录的数据库,最好不要开启,当一个磁盘或分区空间不够时,可以开启该参数将数据存储到其他的磁盘或分区

symbolic-links=0

# 设置autocommit=0,则用户将一直处于某个事务中,直到执行一条commit提交或rollback语句才会结束当前事务重新开始一个新的事务(调试模式时使用)

#autocommit=0

# MySQL读入缓冲区的大小

read_buffer_size = 16M

# MySQL的随机读缓冲区大小、MySQL的顺序读缓冲区大小

read_rnd_buffer_size = 8M

sort_buffer_size = 8M

# 连接超时时间、保持时间、最大传输数据包大小

wait_timeout=2880000

interactive_timeout=2880000

max_allowed_packet=100M

# 连接缓存池大小、临时表大小、临时存放位置

join_buffer_size = 128M

tmp_table_size = 64M

tmpdir = /tmp

 

cd  /data/mysql8_basedir

  1. 密码始化

有密码初始化

/data/mysql8/basedir/bin/mysqld --defaults-file=/etc/my.cnf --user=mysql --initialize  //执行这条命令

(无密码初始化)

( /data/mysql8/basedir/bin/mysqld --defaults-file=/etc/my.cnf --user=mysql --initialize-insecur)

  1. 查看密码

cat /data/mysql8/log/err.log

2019-02-01T09:07:41.027606Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.14) initializing of server in progress as process 3816

2019-02-01T09:07:45.430058Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: GpvPoB_=/22u

2019-02-01T09:07:47.381976Z 0 [System] [MY-013170] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.14) initializing of server has completed

  1. 启动程序

/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &

 

  1. 登陆修root@loclhost密码和添加root@%账号

root@gxc150 mysql]# /usr/local/mysql/bin/mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

......

mysql> alter user 'root'@'localhost' identified with mysql_native_password by '123456';

Query OK, 0 rows affected (0.01 sec)

 

mysql> create user 'root'@'%' identified by '123456';

Query OK, 0 rows affected (0.00 sec)

 

mysql> grant all privileges on *.* to 'root'@'%' with grant option;

Query OK, 0 rows affected (0.01 sec)

 

mysql> grant all privileges on *.* to 'root'@'%' with grant option;

Query OK, 0 rows affected (0.02 sec)

 

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

....

  1.  配置环境变量

vi /etc/profile         //在最后添加:

....

PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH

source /etc/profile    //生效配置

  1. 关闭数据库

mysqladmin -uroot -p shutdown    //密码输入刚修改的123456

  1. 启动数据库

mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &

  1. 设置开机启动及快捷启动方式

cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql.server

vim /etc/rc.d/init.d/mysql.server   //修改下面两项

...

basedir=/user/local/mysql

datadir=/data/mysql8/data

...

chmod +x /etc/rc.d/init.d/mysql.server

chkconfig --add mysql.server

service mysql.server start

--------------------------------mysql8报错

[ERROR] [MY-011011] [Server] Failed to find valid data directory.

解决方法:
1、手动删掉自己创建的data文件夹
2、# /usr/lcal/mysql/bin/mysqld -remove MySQL
3、# /usr/lcal/mysql/bin/mysqld --initialize-insecure
   (程序会在动MySQL文件夹下创建data文件夹以及对应的文件)
4、# /usr/lcal/mysql/bin/mysqld --install


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

璐程风

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值