linux-安装环境
安装PHP
本文将介绍如何在 CentOS 7 服务器上使用 yum 命令安装 PHP7.2
安装 PHP7.2
systemctl list-dependencies
安装 EPEL 软件包:
yum install epel-release -y
安装 remi 源:
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
安装 yum 扩展包:
yum install yum-utils -y
启用 remi 仓库:
yum-config-manager --enable remi-php72 -y
yum update -y
安装 PHP7.2
yum install php72 -y
yum list | grep redis
安装 php-fpm 和一些其他模块
yum install -y php72-php-fpm \
php72-php-gd \
php72-php-json \
php72-php-mbstring \
php72-php-mysqlnd \
php72-php-xml \
php72-php-xmlrpc \
php72-php-opcache \
php72-php-pecl-redis
输入 php72 -v 查看安装结果
php-fpm 服务
设置开机自启
systemctl enable php72-php-fpm && systemctl enable nginx
systemctl stop php72-php-fpm && systemctl stop nginx
systemctl start php72-php-fpm && systemctl start nginx
systemctl status php72-php-fpm && systemctl status nginx
常用 php-fpm 命令
systemctl start php72-php-fpm
systemctl stop php72-php-fpm
systemctl status php72-php-fpm
通过 egrep 查询 nginx 服务器的用户和用户组:
$ egrep '^(user|group)' /etc/nginx/nginx.conf
结果示例:
user nginx;
编辑 /etc/opt/remi/php72/php-fpm.d/www.conf,修改执行 php-fpm 的权限:
vi /etc/opt/remi/php72/php-fpm.d/www.conf
设置用户和用户组为 nginx:
user = nginx
group = nginx
保存并关闭文件,重启 php-fpm 服务:
systemctl stop php72-php-fpm && systemctl start php72-php-fpm && systemctl status php72-php-fpm
路径整理
/etc/opt/remi/php72
/etc/nginx/nginx.conf
/usr/share/nginx/html
php安装pgsql pdp_pgsql扩展
yum search *pgsql* -y
yum install centos-release-scl-rh -y
yum install php72-php-pgsql -y
或者
yum install rh-php72-php-pgsql -y
获取pgsql.so 扩展所在地址
find / -name *pgsql.so
php安装redis扩展
php -v
yum list | grep php72-php-pecl-re* -y
yum install php72-php-pecl-redis -y
find / -name *redis.so
extension=/opt/remi/php72/root/usr/lib64/php/modules/redis.so
修改php.ini
extension=/opt/remi/php72/root/usr/lib64/php/modules/pgsql.so
extension=/opt/remi/php72/root/usr/lib64/php/modules/pdo_pgsql.so
extension=/opt/remi/php72/root/usr/lib64/php/modules/redis.so
short_open_tag = On
安装nginx
CentOS7 安装 Nginx
nginx centos7
YUM 安装
1.下载nginx包
yum install -y wget
wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2.建立nginx的yum仓库
rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
3.下载并安装nignx
yum install nginx -y
4.启动nginx服务
systemctl start nginx && systemctl enable nginx
5.如果在浏览器中输入部署nginx环境的IP不能访问,可能是端口没有开启
firewall-cmd --zone=public --add-port=80/tcp --permanent
重启防火墙
systemctl stop firewalld
systemctl start firewalld
命令含义:
--zone
--add-port=80/tcp
--permanent
编译安装nginx
源码编译安装
下载 Nginx 安装包
检查是否已经YUM安装
如果已安装,使用 yum remove nginx 命令删除。
➜ ~ yum list installed | grep nginx
nginx.x86_64 1:1.12.2-2.el7 @epel
nginx-all-modules.noarch 1:1.12.2-2.el7 @epel
nginx-filesystem.noarch 1:1.12.2-2.el7 @epel
nginx-mod-http-geoip.x86_64 1:1.12.2-2.el7 @epel
nginx-mod-http-image-filter.x86_64 1:1.12.2-2.el7 @epel
nginx-mod-http-perl.x86_64 1:1.12.2-2.el7 @epel
nginx-mod-http-xslt-filter.x86_64 1:1.12.2-2.el7 @epel
nginx-mod-mail.x86_64 1:1.12.2-2.el7 @epel
nginx-mod-stream.x86_64 1:1.12.2-2.el7 @epel
安装 Nginx
➜ tar -xvf nginx-1.14.2.tar.gz
➜ cd nginx-1.14.2
➜ ./configure
➜ make && make install
./configure 执行后提示的 nginx 配置信息:
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
运行 Nginx
/usr/local/nginx 中包含四个主要的目录:
conf:配置文件
html:默认的 nginx 访问路径
logs:各种日志信息
sbin:二进制启动脚本
/usr/local/nginx/sbin/nginx
ps -ef | grep nginx
nginx( 1.18 配置ssl )
server {
listen 80;
listen 443 ssl;
server_name visit.taijisemi.com
ssl on;
ssl_certificate /etc/nginx/USSL_TBDgfz1p3/USSL_TBDgfz1p3/Nginx/public.pem;
ssl_certificate_key /etc/nginx/USSL_TBDgfz1p3/USSL_TBDgfz1p3/Nginx/private.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
if ($server_port = 80) {
rewrite ^(.*)$ https://$host$1 permanent;
}
location / {
root /usr/share/nginx/taiji;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/taiji;
}
location ~ \.php$ {
root /usr/share/nginx/taiji;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
include fastcgi_params;
}
}
安装postgres 9.6
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm -y
yum install postgresql96 -y
yum install postgresql96-server -y
安装postgres 9.6
https://www.postgresql.org/download/linux/redhat/
安装postgresql之后
#初始化一个数据库
/usr/pgsql-9.6/bin/postgresql96-setup initdb
#启用服务
systemctl enable postgresql-9.6
#开启服务
systemctl start postgresql-9.6
#查看服务状态
systemctl status postgresql-9.6
postgres 后期配置
pg_hba.conf文件 (或许存在多个 find / -name 寻找一下)
local all all ident
host all all 127.0.0.1/32 ident
host all all ::1/128 ident
host all all 0.0.0.0/0 md5
postgresql.conf文件
listen_addresses = '*'
文档支持
https://segmentfault.com/u/donne/articles