This article describes 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 Change directory to the working folder: cd /usr/local/src Download the pcre source code and install it 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 Download zlib source code and install 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 Download nginx source code and install 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 Start nginx at boot Add /ect/init.d/nginx and write 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 to 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 Compile and install php5.6 from source code Download PHP source code 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 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 openssl apt-get install libcurl3-openssl-dev jpeg extension apt-get install libjpeg-dev Compile Statement Generate configuration files ./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 After installing the dependent components, there should be no errors. If errors occur, please install the missing components and regenerate the configuration file. Compile & Install make && make install View PHP server configuration When we migrate the server, the code for generating the configuration file needs to be consistent with the original PHP server. We can use php-config --configure-options to view it. The location of php-config is php/bin/php-config No php.ini found? After compiling and installing PHP directly, there is no php.ini. We can copy it from the decompressed directory to /opt/php/lib, and then configure it to take effect. /opt/php/lib is the path configured in ./configure I hope this article will help you configure your Ubuntu environment. You may also be interested in:
|
<<: MySQL 8.0.12 installation and configuration graphic tutorial
>>: Vue+thinkphp5.1+axios to realize file upload
Visual Studio Code is a powerful text editor prod...
Part of the code: Copy code The code is as follow...
There are many versions of the Java language. In ...
The results are different in Windows and Linux en...
ChunkFive Free Typefamily Cuprum JAH I Free font Y...
The problem that MYSQL5.7.17 cannot connect under...
First look at the code and effect↓ <style> ...
The syntax for an outer join is as follows: SELEC...
Shopify Plus is the enterprise version of the e-c...
Copy code The code is as follows: <HTML> &l...
Introduction MySQL 5.7 aims to be the most secure...
This article mainly introduces how to evenly dist...
Azure Container Registry is a managed, dedicated ...
Simply use CSS to achieve all the effects of corn...
1. The difference between forward proxy and rever...