编译安装nginx
切换目录到工作文件夹:
cd /usr/local/src
下载pcre源代码并安装
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.20.tar.gz tar -zxvf pcre2-10.20.tar.gz mv ./pcre2-10.20.tar.gz ./pcre cd pcre ./configure --prefix=/usr/local/pcre make && make install
下载zlib源代码并安装
wget http://tenet.dl.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz tar -zxvf zlib-1.2.8.tar.gz mv ./zlib-1.2.8.tar.gz ./zlib cd zlib ./configure --prefix=/usr/local/zlib make && make install
下载nginx源代码并安装
wget http://nginx.org/download/nginx-1.8.1.tar.gz tar -zxvf nginx-1.8.1.tar.gz cd nginx-1.8.1 ./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre --with-zlib=/usr/local/zlib make && make install
开机启动nginx
添加/ect/init.d/nginx,并写入脚本
#! /bin/bash # description: startup script for webserver on centos. cp it in /etc/init.d and # chkconfig --add nginx && chkconfig nginx on # then you can use server command control nginx # # chkconfig: 2345 08 99 # description: starts, stops nginx set -e path=$path:/usr/local/nginx/sbin/ desc="nginx daemon" name=nginx daemon=/usr/local/nginx/sbin/$name configfile=/usr/local/nginx/conf/nginx.conf pidfile=/var/run/nginx.pid scriptname=/etc/init.d/$name # gracefully exit if the package has been removed. test -x $daemon || exit 0 d_start() { $daemon -c $configfile || echo -n " already running" } d_stop() { kill -quit `cat $pidfile` || echo -n " not running" } d_reload() { kill -hup `cat $pidfile` || echo -n " can't reload" } case "$1" in start) echo -n "starting $desc: $name" d_start echo "." ;; stop) echo -n "stopping $desc: $name" d_stop echo "." ;; reload) echo -n "reloading $desc configuration..." d_reload echo "reloaded." ;; restart) echo -n "restarting $desc: $name" d_stop sleep 1 d_start echo "." ;; *) echo "usage: $scriptname {start|stop|restart|force-reload}" >&2 exit 3 ;; esac exit 0
chmod +x /etc/init.d/nginx chkconfig --add nginx chkconfig --level 2345 nginx on service nginx start
源码编译安装php5.6
下载php源代码
cd /usr/local/src wget http://cn2.php.net/get/php-5.6.24.tar.gz/from/this/mirror mv mirror php-5.6.24.tar.gz tar -zxvf php-5.6.24.tar.gz cd php-5.6.24
安装依赖的组件
xml扩展
apt-get install libxml2-dev
png扩展
apt-get install libpng12-dev
freetype扩展
apt-get -y install libfreetype6-dev
openssl扩展
apt-get install openssl apt-get install libcurl3-openssl-dev
jpeg扩展
apt-get install libjpeg-dev
编译语句
生成配置文件
./configure --prefix=/opt/php --with-config-file-path=/opt/php/lib --enable-mbstring --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl-dir=/usr --with-openssl --with-pdo-mysql=mysqlnd --with-pear --enable-sockets --with-freetype-dir=/usr --enable-gd-native-ttf --with-zlib --with-libxml-dir=/usr --with-xmlrpc --enable-zip --enable-fpm --enable-fpm --enable-xml --enable-sockets --with-gd --with-zlib --with-iconv --enable-zip --with-freetype-dir=/usr/lib/ --enable-soap --enable-pcntl --enable-cli
安装了依赖的组件以后,应该就不会报错,如果报错请安装缺少的组件,然后重新生成配置文件。
编译&安装
make && make install
查看php服务器配置
当我们迁移服务器的时候,上述生成配置文件的代码需要与原php服务器的一直,我们可以使用php-config --configure-options查看。
php-config的位置在 php/bin/php-config
没有发现php.ini?
直接编译安装php之后,是没有php.ini的,我们可以从解压缩后的目录copy到/opt/php/lib,然后进行配置生效。
/opt/php/lib是在./configure中配置的路径
以上是Ubuntu环境怎么编译安装PHP和Nginx的详细内容。更多信息请关注PHP中文网其他相关文章!

NGINX受欢迎的原因是其在速度、效率和控制方面的优势。1)速度:采用异步、非阻塞处理,支持高并发连接,静态文件服务能力强。2)效率:内存使用低,负载均衡功能强大。3)控制:通过灵活的配置文件管理行为,模块化设计便于扩展。

NGINX和Apache在社区、支持和资源方面的差异如下:1.NGINX的社区虽然规模较小,但活跃度和专业性高,官方支持通过NGINXPlus提供高级功能和专业服务。2.Apache拥有庞大且活跃的社区,官方支持主要通过丰富的文档和社区资源提供。

NGINXUnit是一个开源的应用服务器,支持多种编程语言和框架,如Python、PHP、Java、Go等。1.它支持动态配置,可以在不重启服务器的情况下调整应用配置。2.NGINXUnit支持多语言应用,简化了多语言环境的管理。3.通过配置文件,可以轻松部署和管理应用,如运行Python和PHP应用。4.它还支持高级配置,如路由和负载均衡,帮助管理和扩展应用。

NGINX可通过以下方式提升网站性能和可靠性:1.作为Web服务器处理静态内容;2.作为反向代理服务器转发请求;3.作为负载均衡器分配请求;4.作为缓存服务器减轻后端压力。通过配置优化如启用Gzip压缩和调整连接池,NGINX能显着提高网站性能。

nginxserveswebcontentandactsasareverseproxy,loadBalancer和more.1)效率高效的servesstaticContentLikeHtmlandImages.2)itfunctionsasareverseproxybalancer,and andginxenhanceperforfforfforfforfforfforffrenfcaching.4)

NGINXUnit通过动态配置和多语言支持简化应用部署。1)动态配置无需重启服务器即可修改。2)支持多种编程语言,如Python、PHP、Java。3)采用异步非阻塞I/O模型,提升高并发处理性能。

NGINX起初解决C10K问题,现已发展为处理负载均衡、反向代理和API网关的全能选手。1)它以事件驱动和非阻塞架构闻名,适合高并发。2)NGINX可作为HTTP和反向代理服务器,支持IMAP/POP3。3)其工作原理基于事件驱动和异步I/O模型,提升了性能。4)基本用法包括配置虚拟主机和负载均衡,高级用法涉及复杂负载均衡和缓存策略。5)常见错误包括配置语法错误和权限问题,调试技巧包括使用nginx-t命令和stub_status模块。6)性能优化建议包括调整worker参数、使用gzip压缩和

Nginx常见错误的诊断与解决方法包括:1.查看日志文件,2.调整配置文件,3.优化性能。通过分析日志、调整超时设置和优化缓存及负载均衡,可以有效解决404、502、504等错误,提高网站稳定性和性能。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

SublimeText3 英文版
推荐:为Win版本,支持代码提示!

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境

安全考试浏览器
Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器