nginx+php7+mysql8+redis安装

安装nginx

yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel gd-develcd /opt
yum -y install gd-devel
sudo wget http://nginx.org/download/nginx-1.12.2.tar.gz
sudo tar -zxvf nginx-1.12.2.tar.gzcd nginx-1.12.2
./configure
sudo make && sudo make install

方法一:
 启动 /usr/local/nginx/sbin/nginx
重启:/usr/local/nginx/sbin/nginx -s reload
 停止: /usr/local/nginx/sbin/nginx -s stop
方法二:
 cd /usr/local/nginx/
启动:sbin/nginx
重启:sbin/nginx -s reload
停止: sbin/nginx -s stop

用ps -aux | grep nginx查看状态

安装PHP7

cd /usr/local/src 
wget http://cn2.php.net/get/php-7.1.23.tar.gz/from/this/mirror
 tar -zxvf  mirror
 cd  php-7.1.23

安装php时的报错

checking libxml2 install dir... no
checking for xml2-config path... 
configure: error: xml2-config not found. Please check your libxml2 installation.

检查是否安装了libxm包

[root@123456]# rpm -qa |grep  libxml2
libxml2-2.6.26-2.1.12
libxml2-python-2.6.26-2.1.12

重新安装libxml2和libxml2-devel包
yum install libxml2
yum install libxml2-devel -y

注意: 我们编译的PHP 要有如下功能:
连接mysql, gd, ttf, 以fpm(fascgi)方式运行

./configure  --prefix=/usr/local/php \
--with-mysqli=mysqlnd \
--enable-mysqlnd \
--with-gd \

--enable-bcmath \
--enable-session \
--enable-gd-native-ttf \
--enable-gd-jis-conv  \
--enable-fpm

make && make install


编译完毕后: 
先 cd /usr/local/php 
1: copy配置文件
cp  /usr/local/src/php-7.1.23/php.ini-development   ./lib/php.ini  (也就是/usr/local/php/lib/php.ini)	
继续:
 cp etc/php-fpm.conf.default  etc/php-fpm.conf  (也即是cd /usr/local/php/etc/)


php-fpm重启:killall php-fpm && /usr/local/php/sbin/php-fpm

关闭 php
killall php-fpm 

启动php 
 ./sbin/php-fpm  (cd /usr/local/php)
启动报错的话:
 WARNING: Nothing matches the include pattern '/usr/local/php/etc/php-fpm.d/*.conf' from /usr/local/php/etc/php-fpm.conf at line 125.
解决方法
 cd /usr/local/php/etc/php-fpm.d/
sudo cp www.conf.default www.conf

查看php
 ps aux|grep php

安装mysql8.0

添加 MySQL8.0到YUM源
rpm -Uvh  http://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm
安装MySQL8.0
yum -y install mysql-community-server
权限设置:
chown mysql:mysql -R /var/lib/mysql
初始化 MySQL:
mysqld --initialize
启动 MySQL:
systemctl start mysqld
查看 MySQL 运行状态:
systemctl status mysqld

注意: 当启动mysql报错,通过查看MySQL运行状态
[root@123456 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sun 2019-04-14 18:50:07 CST; 1min 45s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.htmlProcess: 3201 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)
  Process: 3182 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 3201 (code=exited, status=1/FAILURE)
   Status: "SERVER_BOOTING"
    Error: 2 (No such file or directory)Apr 14 18:50:07 iZwz9dw8wes0yi8n5blmtiZ systemd[1]: Starting MySQL Server...
Apr 14 18:50:07 iZwz9dw8wes0yi8n5blmtiZ systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE
Apr 14 18:50:07 iZwz9dw8wes0yi8n5blmtiZ systemd[1]: Failed to start MySQL Server.
Apr 14 18:50:07 iZwz9dw8wes0yi8n5blmtiZ systemd[1]: Unit mysqld.service entered failed state.
Apr 14 18:50:07 iZwz9dw8wes0yi8n5blmtiZ systemd[1]: mysqld.service failed.
解决方法:
看不出问题,查看mysql的日志终于找到问题vim /var/log/mysqld.log

[root@123456~]# cat  /var/log/mysqld.log
2019-04-14T10:49:44.610667Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.15) initializing of server in progress as process 3105
2019-04-14T10:49:47.963314Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: jc:.jew!J2use mysql;
	mysql>update user set host = '%' where user ='root';
	mysql>flush privileges;
	mysql>select host, user from user; 

MySQL8.0,发现Navicat连接不上,总是报错1251;
原因是MySQL8.0版本的加密方式和MySQL5.0的不一样,连接会报错。
解决方法:
一,登录mysql
mysql -u root -p
二
use mysql; 
三 更改加密方式:
ALTER USER 'root'@'%' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
四 更改密码
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '新密码'; 
五 刷新
 flush privileges;

安装redis

cd  /usr/local/src
wget http://download.redis.io/releases/redis-4.0.2.tar.gz
tar -zxvf redis-4.0.2.tar.gz
cd redis-4.0.2
make MALLOC=libc
cd src && make PREFIX=/usr/local/redis install
mkdir -p /etc/redis
cp /usr/local/src/redis-4.0.2/redis.conf /etc/redis
cp /usr/local/src/redis-4.0.2/redis.conf /etc/redis/6379.conf
cp /usr/local/src/redis-4.0.2/redis.conf /etc/redis/6380.conf
cp /usr/local/src/redis-4.0.2/utils/redis_init_script /etc/init.d/redis-6379
cp /usr/local/src/redis-4.0.2/utils/redis_init_script /etc/init.d/redis-6380
修改 /etc/init.d/redis-6379, /etc/init.d/redis-6380
vim /etc/init.d/redis-6379
vim /etc/init.d/redis-6380
改动以下内容: 
REDISPORT=6379    # 6380
EXEC=/usr/local/redis/bin/redis-server
CLIEXEC=/usr/local/bin/redis/redis-cli
修改 /etc/redis/6379.conf, /etc/redis/6380.conf
vim /etc/redis/6379.conf
vim /etc/redis/6380.conf
改动以下内容:
daemonize yes
port 6379  # 6380
启动和停止服务
/etc/init.d/redis-6379 start
/etc/init.d/redis-6380 start

/etc/init.d/redis-6379 stop 
/etc/init.d/redis-6380 stop

为PHP安装redis扩展
redis编译报错Cannot find config.m4 解决方法

yum install -y automake
cd /usr/local/src
wget https://github.com/phpredis/phpredis/archive/develop.zip
yum install -y unzip zip
unzip develop.zip
cd  phpredis-develop
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install


编辑 /etc/php.ini
vim /usr/local/php/lib/php.ini

extension=redis.so

你可能感兴趣的:(PHP,redis,mysql)