20190110-php、nginx编译安装

本文详细介绍了在Linux环境下从源码编译安装PHP及Nginx的过程,包括必要的依赖包安装、编译参数说明、配置文件编辑、启动脚本创建及常见错误排查。适用于希望深入了解服务器软件部署流程的技术人员。

补充知识

vi里面在一般模式,dd可以截切;p复制;u撤销;ctrl+u反撤销;显示行号:":set nu";定位到某一行:“:100”;
diff 查看两个文件的差异的,如 diff 1.txt 2.txt
grep -i 忽略大小写
编译安装步骤:1. ./configure;
2. make
3. make install
编译参数:HTTPs://php.net/install

alias 别名

  • eq:alias viens33=“vim /etc/sysconfig/network-scripts/ifcfg-ens33”
  • 取消:unalias viens33
  • 配置文件 :~/.bashrc //针对用户
    /etc/bashrc //全局
    在文件末尾添加alias oo='cd /mnt/hgfs/D/work/project/ASID/5.code/trunk/ASID/ASID/wms/'并保存退出
    执行source /etc/bashrc 使配置生效

php编译安装过程

www.php.net
下载:wget http://cn2.php.net/distributions/php-7.3.0.tar.bz2
解压:tar -jxvf

yum install -y bzip2 openssl-devel libxml2-devel gcc  libcurl-devel libjpeg-turbo-devel libpng-devel freetype-devel
useradd -M -s /sbin/nologin php-fpm 

cd php-7.3.0
编译参数

./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm  --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl

make
make install 
./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm  --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-mysql-sock=/data/mysql/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl
编译参数解释

–prefix 制定安装路径
–with-config-file-path 配置文件路径
–enable-fpm 开启fpm
–with-fpm-user 指定用户
–with-fpm-group 指定组
–with-mysql 老版本用关联mysql的方式
–with-mysqli 新版本用来关联mysql
–with-pdo-mysql 同上
–with-mysql-sock
–with-libxml-dir
–with-gd
–with-jpeg-dir
–with-png-dir
–with-freetype-dir
–with-iconv-dir
–with-zlib-dir
–with-mcrypt
–enable-soap
–enable-gd-native-ttf
–enable-ftp
–enable-mbstring
–enable-exif
–with-pear
–with-curl
–with-openssl

配置文件:
cd /usr/local/php-fpm/
cp ./etc/php-fpm.conf.default php-fpm.conf
cd /usr/local/src/php-7.3.0
cp php.ini-development (测试) /usr/local/php-fpm/etc/php.ini
cd /usr/local/php-fpm/etc/php-fpm.d/
cp www.conf.default www.conf

php.ini.production 生产环境用的ini

启动脚本:
cd /usr/local/src/php-7.3.0
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
chkconfig --level 3 php-fpm on 
chmod 755 /etc/init.d/php-fpm 
cp ./php-fpm/etc/php.fpm.d/www.conf.default ./www.conf
报错解析

RROR: [pool www] cannot get uid for user ‘php-fpm’
解决:useradd php-fpm
在这里插入图片描述

错误8
configure: error: wrong mysql library version or lib not found
解决:下载一个低版本的MySQL/Mariadb
wget http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
tar jxvf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.6.39-linux-glibc2.12-x86_64 /usr/local/mysql5.6
改编译参数
./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql5.6 --with-mysqli=/usr/local/mysql5.6/bin/mysql_config --with-pdo-mysql=/usr/local/mysql5.6 --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl

编译安装nginx

官方文档:http://nginx.org/en/docs/install.html
www.nginx.org
stable稳定版
nginx-1.14.2
下载:wget http://nginx.org/download/nginx-1.14.2.tar.gz
解压:tar -zxvf nginx-1.14.2.tar.gz
编译安装:
./configure
./configure --prefix=/usr/local/nginx --with-http_ssl_module

make && make install

启动:/usr/local/nginx/sbin/nginx
检察配置文件正确性:/usr/local/nginx/sbin/nginx -t
重新加载:/usr/local/nginx/sbin/nginx -s reload

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值