centos7 Nginx1.14+php7+mysql5.7 以及 centos7 Apache2.4+PHP7+mysql 安装 Linux 配置 composer 以及Python2.7升级到3.7

时间:2022-04-06 07:36:53

1   centos7 Nginx1.14+php7.0+mysql5.7 (LNMP)安装

nginx
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install epel-release
php
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install php70w-fpm php70w-cli php70w-gdphp70w-mysql php70w-pear php70w-xml php70w-mbstring php70w-pdo php70w-json php70w-pecl-apcu php70w-pecl-apcu-devel
mysql
rpm -Uvh http://repo.mysql.com/mysql57-community-release-el7-7.noarch.rpm
yum install mysql-server mysql-devel mysql
外部登录
grep 'temporary password' /var/log/mysqld.log
mysql_secure_installation
grant all privileges on *.* to 创建的用户名 @"%" identified by "密码";
flush privileges; 
配置
/etc/php-fpm/www.config

/etc/nginx/conf.d default.conf
server {
listen 80;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
server_name test1.loc www.test1.loc;
error_log /var/log/default_error.log;

root /usr/share/nginx/html;
index index.php index.html index.htm;
location ~ \.php$ {
#fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
systemctl restart nginx.service
systemctl enablenginx.service
systemctl enable php-fpm.service
systemctl start php-fpm.service
service mysqld start 
service mysqld stop

  

说说配置lnmp遇到的坑 测试时一定要使用<?php?>这样的PHP标记 fastcgi默认是不能解析<??>这样的PHP代码标记的 更别说 <% %>这样以及其他的

为了这个问题苦恼了两天,国内外的论坛·博客翻烂了没找到解决办法

这就是代码规范的 重要性 

2  centos7 +PHP7.2+Apache2.4+mysql (lamp)简单配置

mysql
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum -y install epel-release  安装release
yum -y install mariadb-server mariadb 安装mysql
systemctl start mariadb.service 开启服务
systemctl enable mariadb.service 添加到开机启动
mysql_secure_installation   mysql重置命令
Apache
yum -y install httpd
systemctl start httpd.service
systemctl enable httpd.service
php
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y install yum-utils  yum-config-manager utility
7.0
yum-config-manager --enable remi-php70
yum -y install php php-opcache
7.1
yum-config-manager --enable remi-php71
yum -y install php php-opcache
7.2
yum-config-manager --enable remi-php72
yum -y install php php-opcache
测试
ystemctl restart httpd.service
vi /var/www/html/info.php

<?php
phpinfo();
安装PHP模块
yum -y install php-mysqlnd php-pdo
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel
systemctl restart httpd.service

3Linux操作系统下composer安装 前提 安装PHP并且启动PHP服务

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
chmod -R 777 /usr/local/bin/composer

4 centos 下Python2.7 升级到Python3.7

wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
下载压缩包
tar -zxvf Python-3.7.0.tgz
解压
cd Python-3.7.0/
进入目录
./configure
对安装软件进行配置 如果出错 先安装GCC yum install make gcc gcc-c++ ./configure
make & make install
编辑以及编译安装
顺带一提安装模块提示pip: command not found以下如何解决
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
python -v