编译安装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和Apache都是强大的Web服务器,各自在性能、可扩展性和效率上有独特的优势和不足。1)NGINX在处理静态内容和反向代理时表现出色,适合高并发场景。2)Apache在处理动态内容时表现更好,适合需要丰富模块支持的项目。选择服务器应根据项目需求和场景来决定。

NGINX适合处理高并发请求,Apache适合需要复杂配置和功能扩展的场景。1.NGINX采用事件驱动、非阻塞架构,适用于高并发环境。2.Apache采用进程或线程模型,提供丰富的模块生态系统,适合复杂配置需求。

NGINX可用于提升网站性能、安全性和可扩展性。1)作为反向代理和负载均衡器,NGINX可优化后端服务和分担流量。2)通过事件驱动和异步架构,NGINX高效处理高并发连接。3)配置文件允许灵活定义规则,如静态文件服务和负载均衡。4)优化建议包括启用Gzip压缩、使用缓存和调整worker进程。

NGINXUnit支持多种编程语言,通过模块化设计实现。1.加载语言模块:根据配置文件加载相应模块。2.应用启动:调用语言运行时执行应用代码。3.请求处理:将请求转发给应用实例。4.响应返回:将处理后的响应返回给客户端。

NGINX和Apache各有优劣,适合不同场景。1.NGINX适合高并发和低资源消耗场景。2.Apache适合需要复杂配置和丰富模块的场景。通过比较它们的核心特性、性能差异和最佳实践,可以帮助你选择最适合需求的服务器软件。

确认 Nginx 是否启动的方法:1. 使用命令行:systemctl status nginx(Linux/Unix)、netstat -ano | findstr 80(Windows);2. 检查端口 80 是否开放;3. 查看系统日志中 Nginx 启动消息;4. 使用第三方工具,如 Nagios、Zabbix、Icinga。

要关闭 Nginx 服务,请按以下步骤操作:确定安装类型:Red Hat/CentOS(systemctl status nginx)或 Debian/Ubuntu(service nginx status)停止服务:Red Hat/CentOS(systemctl stop nginx)或 Debian/Ubuntu(service nginx stop)禁用自动启动(可选):Red Hat/CentOS(systemctl disable nginx)或 Debian/Ubuntu(syst


热AI工具

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

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

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

SublimeText3汉化版
中文版,非常好用

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

Dreamweaver CS6
视觉化网页开发工具

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

禅工作室 13.0.1
功能强大的PHP集成开发环境