LNMP(二)

二、编译安装PHP
1.官网找到对应版本源码包
进入存放安装包目录 cd /usr/local/src
wget http://cn2.php.net/distributions/php-7.3.0.tar.bz2
解压:tar jxvf php-7.3.0.tar.bz2
编译:
编译参数:./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/mysql --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

补充:vi里面在一般模式下,按dd可以删除行(剪切),支持数字dd 5dd(剪切5行),光标挪动要粘贴的位置,按P,操作错误之后,想要撤销,可以按u,反撤销按ctrl r,一般模式按gg可以把光标定位到首行,按G可以定位到末行,按yy复制,5yy复制5行,显示行号,:set nu,定位到指定的行,直接数字G,如10G

编译安装一个软件包步骤: ./configure ; 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-mysql=/usr/local/mysql --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
grep -i 忽略大小写
报错一:error: libxml2 not found
解决:yum install -y libxml2-devel.x86_64
报错二:error: Cannot find OpenSSL’s <evp.h>
解决:yum install -y openssl-devel.x86_64
报错三:error: cURL version 7.15.5 or later is required
解决:yum install -y libcurl-devel.x86_64
报错四:error: jpeglib.h not found.
解决:yum install -y libjpeg-turbo-devel.x86_64
报错五:error: png.h not found.
解决:yum install -y libpng-devel.x86_64
报错六:error: freetype-config not found
解决:yum install -y freetype-devel
警告:configure: WARNING: unrecognized options: --with-mysql, --with-mcrypt, --enable-gd-native-ttf
echo $?查看是否有错误,如果没有错误,执行make && make install
编译报错:更换mysql 5.7二进制包
解压:tar zxvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
修改编译参数:./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.7 --with-mysqli=/usr/local/mysql5.7/bin/mysql_config --with-pdo-mysql=/usr/local/mysql5.7 --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
安装完成过后执行:ls /usr/local/php-fpm/
cd /usr/local/php-rpm/
cd etc/
拷贝配置文件:cp php-fpm.conf.default php-fpm.conf
diff用来查看两个文件的差异的,如diff 1.txt 2.txt
拷贝配置文件:cp php.ini-development /usr/local/php-fpm/etc/php.ini
配置启动脚本:拷贝配置文件:cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
加入到服务列表:chkconfig --add php-fpm
开机启动:chkconfig php-fpm on
设置755权限:chmod 755 /etc/init.d/php-fpm
启动服务:service php-fpm start
报错:WARNING: Nothing matches the include pattern ‘/usr/local/php-fpm/etc/php-fpm.d/*.conf’ from /usr/local/php-fpm/etc/php-fpm.conf at line 143
cd /usr/local/php-fpm/etc/php-fpm.d/ 定义配置文件
cp www.conf.defaultwww.conf
错误:ERROR: [pool www] cannot get uid for user 'php-fpm
增加用户:useradd php-fpm
启动服务:service php-fpm start
检查服务是否启动:ps aux |grep php-fpm

三、编译安装nginx
官网:nginx.org
下载:wget http://nginx.org/download/nginx-1.14.2.tar.gz
解压:tar zxvf nginx-1.14.2.tar.gz
cd nginx-1.142
编译参数:/configure --prefix=/usr/local/nginx --with-http_ssl_module
echo $?查看是否有错误 没有错误执行make && make install
启动:/usr/local/nignx/sbin/nginx
可以用ps aux |grep nginx查看进程是否启动
查看配置文件: cd /usr/local/nginx/conf/
vi nginx.conf
查看监听端口:netstat -ltnp |grep nginx

三、yum安装nginx
官方文档:
http://nginx.org/en/linux_packages.html
编辑yum仓库:
vi /etc/yum.repos.d/nginx.repo
粘贴:

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/ r e l e a s e v e r / releasever/ releasever/basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
yum list |grep nginx
pkill nginx 杀死一个进程
ps aux |grep nginx 再次查看进程
rm -rf /usr/local/nginx/ 删除掉原来安装的nginx
yum install -y nginx
ls /etc/nginx/nginx.conf 配置文件
ls /etc/nginx/conf.d 子配置文件
nginx -V 查看版本号以及编译参数
启动nginx:systemctl start nginx
查看配置文件有没有语法错误,可以使用nginx -t

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值