Ubuntu环境怎么编译安装PHP和Nginx
时间:2023-05-14 00:22
编译安装nginx 切换目录到工作文件夹: 下载pcre源代码并安装 下载zlib源代码并安装 下载nginx源代码并安装 开机启动nginx 添加/ect/init.d/nginx,并写入脚本 源码编译安装php5.6 下载php源代码 安装依赖的组件 xml扩展 png扩展 freetype扩展 openssl扩展 jpeg扩展 编译语句 生成配置文件 安装了依赖的组件以后,应该就不会报错,如果报错请安装缺少的组件,然后重新生成配置文件。 编译&安装 查看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的详细内容,更多请关注Gxl网其它相关文章!cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.20.tar.gztar -zxvf pcre2-10.20.tar.gzmv ./pcre2-10.20.tar.gz ./pcre cd pcre./configure --prefix=/usr/local/pcremake && make install
wget http://tenet.dl.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gztar -zxvf zlib-1.2.8.tar.gzmv ./zlib-1.2.8.tar.gz ./zlibcd zlib./configure --prefix=/usr/local/zlibmake && make install
wget http://nginx.org/download/nginx-1.8.1.tar.gztar -zxvf nginx-1.8.1.tar.gzcd nginx-1.8.1./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre --with-zlib=/usr/local/zlibmake && make install
#! /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 nginxset -epath=$path:/usr/local/nginx/sbin/desc="nginx daemon"name=nginxdaemon=/usr/local/nginx/sbin/$nameconfigfile=/usr/local/nginx/conf/nginx.confpidfile=/var/run/nginx.pidscriptname=/etc/init.d/$name# gracefully exit if the package has been removed.test -x $daemon || exit 0d_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" instart)echo -n "starting $desc: $name"d_startecho ".";;stop)echo -n "stopping $desc: $name"d_stopecho ".";;reload)echo -n "reloading $desc configuration..."d_reloadecho "reloaded.";;restart)echo -n "restarting $desc: $name"d_stopsleep 1d_startecho ".";;*)echo "usage: $scriptname {start|stop|restart|force-reload}" >&2exit 3;;esacexit 0
chmod +x /etc/init.d/nginxchkconfig --add nginxchkconfig --level 2345 nginx onservice nginx start
cd /usr/local/srcwget http://cn2.php.net/get/php-5.6.24.tar.gz/from/this/mirrormv mirror php-5.6.24.tar.gztar -zxvf php-5.6.24.tar.gzcd php-5.6.24
apt-get install libxml2-dev
apt-get install libpng12-dev
apt-get -y install libfreetype6-dev
apt-get install opensslapt-get install libcurl3-openssl-dev
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