Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to compile and install PHP and Nginx in Ubuntu environment

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to compile and install PHP and Nginx in the Ubuntu environment. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

This paper gives an example of how to compile and install PHP and Nginx in Ubuntu environment. Share with you for your reference, the details are as follows:

Compile and install nginx

Switch directories to the working folder:

Cd / usr/local/src

Download the pcre source code and install

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

Download the zlib source code and 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

Download the nginx source code and 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

Boot and start nginx

Add / ect/init.d/nginx and write to the script

#! / 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 9 September 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 transfersesacexit 0chmod + x / etc/init.d/nginxchkconfig-- add nginxchkconfig-- level nginx onservice nginx start

Source code compilation and installation of php5.6

Download the php source code

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

Install dependent components

Xml extension

Apt-get install libxml2-dev

Png extension

Apt-get install libpng12-dev

Freetype extension

Apt-get-y install libfreetype6-dev

Openssl extension

Apt-get install opensslapt-get install libcurl3-openssl-dev

Jpeg extension

Apt-get install libjpeg-dev

Compile statement

Generate configuration file

/ 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

Once the dependent components are installed, there should be no error. If an error occurs, install the missing component, and then regenerate the configuration file.

Compile & install

Make & & make install

View php server configuration

When we migrate the server, the above code to generate the configuration file needs to be the same as the original php server, which we can look at using php-config-- configure-options.

The location of php-config is in php/bin/php-config

No sign of php.ini?

After compiling and installing php directly, there is no php.ini, we can copy from the extracted directory to / opt/php/lib, and then the configuration takes effect.

/ opt/php/lib is the path configured in. / configure

This is the end of this article on "how to compile and install PHP and Nginx in Ubuntu environment". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 244

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report