centos手动离线安装php,nginx


1、CentOS 7上安装并配置Nginx
https://www.cnblogs.com/xujiecnblogs/p/16843984.html


/usr/local/nginx/sbin/nginx                       #启动
/usr/local/nginx/sbin/nginx -s stop               #关闭
/usr/local/nginx/sbin/nginx -s reload             #重启

增加https访问
https://www.cnblogs.com/ambition26/p/14077773.html
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

2、CentOS7环境下离线安装MySQL5.7数据库
https://blog.csdn.net/millery22/article/details/123468625
mysql密码
mysql
336699@Gooyuit

root密码相同

mysql启动
/etc/init.d/mysqld restart

----不确定
service mysql start
service mysql restart
service mysql stop

创建用户
CREATE USER 'data_user'@'localhost' IDENTIFIED BY '331176_Msfq';
GRANT SELECT, INSERT,UPDATE ON mzxyt.* TO  'data_user'@'localhost';

CREATE USER 'mzxyt_user'@'localhost' IDENTIFIED BY '31235*@Adme';
GRANT SELECT, INSERT,UPDATE,DELETE ON mzxyt.* TO  'mzxyt_user'@'localhost';


MariaDB Server 10.2 和 MySQL 5.7对应 

问题:ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization packet', system err
原因是按照https://www.jianshu.com/p/45b37a73e286安装了server_audit.so插件
解决:
https://www.jianshu.com/p/2e8c2bc45f3c
查询mysql的plugin表,把server_audit的记录删除,把/usr/local/mysql/lib/plugin/server_audit.so删除


导入数据库
create database mzxyt;
set names utf8;
source *.sql


3、离线安装php7.4
https://www.cnblogs.com/xujiecnblogs/p/16843984.html

安装后,需要重启:/usr/local/php/sbin/php-fpm
如果发现9000被占用,则kill进程

删掉所有相关进程
ps aux|grep nginx
ps aux|grep php-fpm

重启
#systemctl start php74-fpm  # 开启php74-fpm
#/usr/local/nginx/sbin/nginx


安装php时出现No package 'libxml-2.0' found
安装libxml2 2.11.4

(1)安装libxml2
https://www.cnblogs.com/yunfan1024/p/13063224.html
官网下载tar.xz后缀的才可以
要下载2.9.0版本

按照文档执行到这个位置为止
cp libxml-2.0.pc /usr/local/lib/pkgconfig

(2)安装Python 2.7.15
https://blog.csdn.net/spec_king/article/details/107176043

如果出现No package ** found
找到所有已安装好的软件pkgconfig路径
#find / -name pkgconfig

编辑环境变量
#vim ~/.bash_profile 

添加到$PKG_CONFIG_PATH中
export PKG_CONFIG_PATH=/usr/local/python2.7.15/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH

使其生效
# source ~/.bash_profile

再查看
#pkg-config --list-all


(3)安装sqlite
https://www.sqlite.org/download.html

下载sqlite-autoconf-3420000.tar.gz

(4)Please reinstall the BZip2 distribution
bzip2安装
https://blog.csdn.net/u013010499/article/details/113105907


(5)libcurl
https://blog.csdn.net/lxyoucan/article/details/116083330

(6)libpng
https://blog.csdn.net/I_feige/article/details/117702589

(7)libjpeg
https://blog.csdn.net/qq_62815119/article/details/127709812

(freetype2)
https://www.cnblogs.com/dmj666/p/10641244.html
不能安装通过

(8)
使用最小化安装php,可以避免上面的问题
#可选1:最小化安装-适合nginx平台
主要安装在/usr/local/php,而不是/usr/local/php74

#./configure --prefix=/usr/local/php --with-config-file-scan-dir=/usr/local/php/etc/ --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-curl --with-openssl --with-jpeg --with-zlib --disable-fileinfo --enable-fpm --with-sodium --enable-gd --enable-xml --with-freetype


./configure --prefix=/usr/local/php --with-config-file-scan-dir=/usr/local/php/etc/ --enable-fpm

./configure --prefix=/usr/local/php74 --with-config-file-scan-dir=/usr/local/php74/etc/ --enable-inline-optimization --enable-opcache --enable-fpm --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbregex --enable-mbstring --with-iconv --with-mhash --with-openssl --enable-bcmath --enable-soap --with-xmlrpc --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zip --with-bz2 --enable-gd --with-jpeg --with-readline --with-freetype --disable-fileinfo


未安装扩展

 --with-freetype

(9)
vi /etc/profile
PATH=/usr/local/php/bin:$PATH
export PATH

:$PATH要放在后面

(10)
https://blog.csdn.net/have_a_cat/article/details/115211208
执行命令service php-fpm start时报ERROR: failed to load configuration file ‘/usr/local/php/etc/php-fpm.conf
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf


https://blog.csdn.net/robin_cai/article/details/118147982
No pool defined. at least one pool section must be specified in config file
进入安装目录:/usr/local/php/etc/php-fpm.d
拷贝www.conf.default为www.conf即可。


(11)
chmod -R 777 /www/mzxyt/runtime/

(12)
Oniguruma 
未安装

(13)
libzip https://www.jianshu.com/p/d87787c33e19

cmake
问题:Cannot find a C++ compiler that supports both C++11 and the specified C++ flags.
解决:

(14)
安装pdo_mysql

https://developer.aliyun.com/article/149981

在php安装源文件目录/www/soft/php-7.4.3/ext/pdo,/www/soft/php-7.4.3/ext/pdo_mysql
命令:
#/usr/local/php/bin/phpize
#./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
#make && make install

得到路径:
extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/pdo_mysql.so

问题:Cannot find autoconf. Please check your autoconf installation and the$PHP_AUTOCONF environment variable. Then, rerun this script.

安装perl, m4, autoconf,automake
https://www.codenong.com/cs106479200/


m4安装完之后,需要把/usr/local加入/etc/profile的环境变量


1)ls command not found
这是因为在改环境变量的时候没有配置正确的原因,需要在命令行写:

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

此时再试一下ls,可以正常执行,但是下次连接的时候可能失效,所以要将这句话写到/etc/profile文件中

然后让这个配置生效
source /etc/profile


perl的安装
./Configure -des -Dprefix=/usr/local/perl
不能使用./configure

----------问题1
完美解决Can‘t locate Data/Dumper.pm in @INC
https://blog.csdn.net/qq_20532695/article/details/113821054
解决Can’t locate ExtUtils/MakeMaker.pm in @INC
https://blog.csdn.net/celeste7777/article/details/77117371
下载地址:https://src.fedoraproject.org/lookaside/pkgs/perl-ExtUtils-MakeMaker/ExtUtils-MakeMaker-6.62.tar.gz/2ae291030c52999b5672b2a502eab195/

安装autoconf
https://blog.csdn.net/m0_45406092/article/details/119248400


----
http://rpmfind.net/linux/rpm2html/search.php?query=perl-Data-Dumper(x86-64)
使用rpm包安装依赖可解决问题1

linux automake-1.16 编译错误 Try `--no-discard-stderr' if option outputs to stderr
https://blog.csdn.net/whatday/article/details/102473565

----rpm包下载
http://mirror.centos.org/centos/7/os/x86_64/Packages/
perl rpm包下载
https://zhuanlan.zhihu.com/p/352932647

----问题
Can't locate Thread/Queue.pm in @INC


(15)
https://blog.csdn.net/qq_16885135/article/details/119811883
php启动
systemctl start php74-fpm  # 开启php74-fpm
systemctl stop php74-fpm  # 关闭php74-fpm
systemctl reload php74-fpm  # 平滑重启php74-fpm
systemctl restart php74-fpm  # 重启php74-fpm

systemctl enable php74-fpm  # 将php74-fpm设为开机自启动
systemctl disable php74-fpm  # 关闭php74-fpm的开机自启动

(16)
访问后台
fastadmin 安装后访问后台提示模块不存在

配置Nginx
location / {
     if (!-e $request_filename) {
          rewrite ^(.+?\.php)(/.+)$ /$1?s=$2 last;
          rewrite ^(.*)$ /index.php?s=$1 last;
          break;
     }
         
}


(17)
安装freetype
/bin/ld: /usr/local/lib/libbz2.a(bzlib.o): relocation R_X86_64_32S against `BZ2_crc32Table' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libbz2.a: error adding symbols: Bad value

解决:
https://stackoverflow.com/questions/63326781/usr-local-lib-libbz2-a-could-not-read-symbols-bad-value

修改bzip2 的makefile中CC=gcc改为CC=gcc -fPIC
重新
make clean
make
make install


./configure --with-jpeg-dir=/user/local/libjpeg --with-png-dir=/user/local/libpng --with-freetype-dir=/user/local/freetype --with-zlib-dir=/user/local/zlib
make && make install

(18)
Nginx配置

location / {
            #if (!-e $request_filename){
                #rewrite ^(.+?\.php)(/.+)$ /$1?s=$2 last;
                #rewrite  ^((?!oqfxCOZFdY.php).)*$  /index.php?s=$1  last;   
                #break;
            #}
             try_files $uri $uri/ /index.php$uri?$query_string;
        }


location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include fastcgi_params;
        }


改完fastadmin的js,在正式环境需要打包,js文件会有缓存重新关闭远程https再打开。

你可能感兴趣的:(centos,php,nginx)