脑子一热,把一台私人小服务器从centos6升级到8,安装php7.4尝尝鲜,没有想到费了一番事。记录如下。
1. yum 安装nginx1.14,安装php74
sudo yum install nginx dnf -y install dnf-utils yum search php74* yum install php74-php
安装完成后php访问不到。后来发现以前版本php,在nginx里默认配置是:
fastcgi_pass 127.0.0.1:9000;
到php目录下查看配置:
listen = /var/opt/remi/php74/run/php-fpm/www.sock
修改nginx配置为:fastcgi_pass /var/opt/remi/php74/run/php-fpm/www.sock;
启动还是报错,看了下nginx error log,提示为www.sock没有权限,于是给了www.sock +rw权限,成功执行!
配置nginx,同时可以访问443和80端口
# # The default server # server { listen 80; listen 443 ssl; server_name blog.pianhuangw.com; root /data/web/blog.pianhuangw.com; index index.php; ssl_certificate /etc/nginx/cert/blog.pianhuangw.com.pem; ssl_certificate_key /etc/nginx/cert/blog.pianhuangw.com.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location ~ .php$ { root /data/web/blog.pianhuangw.com; fastcgi_pass unix:/var/opt/remi/php74/run/php-fpm/www.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }
2. php74 mysql扩展
yum install php74-php-mysqlnd.x86_64
3. mysql56安装
这个是用rpm包装的
rpm -ivh MySQL-server-5.6.19-1.el6.x86_64.rpm rpm -ivh MySQL-devel-5.6.36-1.el6.x86_64.rpm rpm -ivh MySQL-client-5.6.36-1.el6.x86_64.rpm
mysql 默认生成的密码在/root/.mysql_secret,查看密码后登录:
mysql -uroot -p # 修改root默认密码 SET PASSWORD=PASSWORD('123456');
4. java1.8安装
这个也是rpm包,就比较简单了
rpm -ivh jdk-8u192-linux-x64.rpm
配置环境变量
vim /etc/profile
JAVA_HOME=/usr/java/jdk1.8.0_192-amd64 JRE_HOME=$JAVA_HOME/jre PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib export JAVA_HOME JRE_HOME PATH CLASSPATH
source /etc/profile生效
可以echo $JAVA_HOME看下路径,java -version,javac验证下。
5. docker安装
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo #这一步是因为centos8下会提示containerd.io>1.2.2版本 yum install https://download.docker.com/linux/fedora/30/x86_64/stable/Packages/containerd.io-1.2.6-3.3.fc30.x86_64.rpm yum install -y docker-ce
docker version验证安装成功。
6. consul安装
./consul agent -server -ui -bootstrap-expect 1 -client 0.0.0.0 -config-dir /data/app/consul/config.json -data-dir /data/app/consul/data1/
consul.json配置如下:
{ "datacenter": "zyproject-dc", "node_name": "zyproject-reg1", "data_dir": "/data/app/consul/data1", "ports": { "http": 8000, "dns": 8601, "grpc": 8401, "serf_lan": 8311, "server": 8310 } }
再启一个client模拟集群
./consul agent -data-dir=/data/app/consul/data2 -advertise=127.0.0.1 -client=0.0.0.0 -join=127.0.0.1:8311 -datacenter='zyproject-dc'