Ubuntu环境怎么编译安装PHP和Nginx
编译安装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中文网其他相关文章!

热AI工具

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

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

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

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

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

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

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

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

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

如何在 Windows 中配置 Nginx?安装 Nginx 并创建虚拟主机配置。修改主配置文件并包含虚拟主机配置。启动或重新加载 Nginx。测试配置并查看网站。选择性启用 SSL 并配置 SSL 证书。选择性设置防火墙允许 80 和 443 端口流量。

在 Linux 中,使用以下命令检查 Nginx 是否已启动:systemctl status nginx根据命令输出进行判断:如果显示 "Active: active (running)",则 Nginx 已启动。如果显示 "Active: inactive (dead)",则 Nginx 已停止。

在 Linux 中启动 Nginx 的步骤:检查 Nginx 是否已安装。使用 systemctl start nginx 启动 Nginx 服务。使用 systemctl enable nginx 启用在系统启动时自动启动 Nginx。使用 systemctl status nginx 验证启动是否成功。在 Web 浏览器中访问 http://localhost 查看默认欢迎页面。

PHP在数据库操作和服务器端逻辑处理中使用MySQLi和PDO扩展进行数据库交互,并通过会话管理等功能处理服务器端逻辑。1)使用MySQLi或PDO连接数据库,执行SQL查询。2)通过会话管理等功能处理HTTP请求和用户状态。3)使用事务确保数据库操作的原子性。4)防止SQL注入,使用异常处理和关闭连接来调试。5)通过索引和缓存优化性能,编写可读性高的代码并进行错误处理。

启动 Nginx 服务器需要按照不同操作系统采取不同的步骤:Linux/Unix 系统:安装 Nginx 软件包(例如使用 apt-get 或 yum)。使用 systemctl 启动 Nginx 服务(例如 sudo systemctl start nginx)。Windows 系统:下载并安装 Windows 二进制文件。使用 nginx.exe 可执行文件启动 Nginx(例如 nginx.exe -c conf\nginx.conf)。无论使用哪种操作系统,您都可以通过访问服务器 IP

问题的答案:304 Not Modified 错误表示浏览器已缓存客户端请求的最新资源版本。解决方案:1. 清除浏览器缓存;2. 禁用浏览器缓存;3. 配置 Nginx 允许客户端缓存;4. 检查文件权限;5. 检查文件哈希;6. 禁用 CDN 或反向代理缓存;7. 重启 Nginx。

服务器无权访问所请求的资源,导致 nginx 403 错误。解决方法包括:检查文件权限。检查 .htaccess 配置。检查 nginx 配置。配置 SELinux 权限。检查防火墙规则。排除其他原因,如浏览器问题、服务器故障或其他可能的错误。
