Ubuntu 14.04 64bit 编译安装Nginx1.7+PHP5.4+MySQL5.6

我的操作系统是Ubuntu14.04,其它linux系统的操作流程类似。主要安装的软件是Nginx1.7+PHP5.4+MySQL5.6

1. 创建必要目录

sudo mkdir ~/setup
sudo mkdir /opt/software
sudo chmod 777 /opt/software

2. 下载必要软件

cd ~/Downloads

wget
tar zxvf ~/Downloads/php-5.4.29.tar.gz -C ~/setup/

wget
tar zxvf ~/Downloads/nginx-1.7.1.tar.gz -C ~/setup/

wget
tar zxvf ~/Downloads/mysql-5.6.19-linux-glibc2.5-x86_64.tar.gz -C ~/setup/

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.gz
tar zxvf ~/Downloads/pcre-8.33.tar.gz -C ~/setup/

wget
tar zxvf ~/Downloads/jpegsrc.v9.tar.gz -C ~/setup/

wget ~/Downloads
tar zxvf ~/Downloads/libpng-1.6.2.tar.gz -C ~/setup/

wget
tar zxvf ~/Downloads/freetype-2.4.12.tar.gz -C ~/setup/

wget
tar zxvf ~/Downloads/mhash-0.9.9.9.tar.gz -C ~/setup/

wget
tar zxvf ~/Downloads/libmcrypt-2.5.8.tar.gz -C ~/setup/

wget
tar zxvf ~/Downloads/mcrypt-2.6.8.tar.gz -C ~/setup/

wget ftp://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz
tar zxvf ~/Downloads/termcap-1.3.1.tar.gz -C ~/setup/

wget
tar zxvf ~/Downloads/autoconf-latest.tar.gz -C ~/setup/

wget
tar zxvf ~/Downloads/m4-latest.tar.gz -C ~/setup/

wget
tar zxvf ~/Downloads/memcache-2.2.7.tgz -C ~/setup/

以上软件我已经打包好放到百度网盘,相关链接:

3. 安装nginx

sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install libssl-dev openssl libcurl4-openssl-dev
sudo apt-get install build-essential

sudo /usr/sbin/groupadd www
sudo /usr/sbin/useradd -g www www

cd ~/setup/pcre-8.33/
./configure --prefix=/opt/software/pcre
sudo make && sudo make install

cd ../nginx-1.7.1/
./configure --user=www --group=www --prefix=/opt/software/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=~/setup/pcre-8.33 --with-http_realip_module
sudo make && sudo make install

4. 安装MySQL 

cd ~/setup
sudo mv mysql-5.6.19-linux-glibc2.5-x86_64 /opt/software/mysql
sudo mkdir -p /opt/software/mysql/data

sudo apt-get install libaio-dev

sudo /usr/sbin/groupadd mysql
sudo /usr/sbin/useradd -g mysql mysql

/opt/software/mysql/scripts/mysql_install_db --basedir=/opt/software/mysql --datadir=/opt/software/mysql/data --user=mysql
sed -i "s#/usr/local/mysql#/opt/software/mysql#g" /opt/software/mysql/bin/mysqld_safe

#启动mysql进程
/opt/software/mysql/bin/mysqld --basedir=/opt/software/mysql --datadir=/opt/software/mysql/data > /dev/null 2>&1
#设置root的密码为123456
/opt/software/mysql/bin/mysqladmin -u root password '123456'

5. 安装PHP依赖库 

cd ~/setup
sudo mkdir -p /opt/software/libs/

cd jpeg-9/
./configure --prefix=/opt/software/libs --enable-shared --enable-static --prefix=/opt/software/libs
sudo make && sudo make install

cd ../libpng-1.6.2/
./configure --prefix=/opt/software/libs
sudo make && sudo make install

cd ../freetype-2.4.12/
./configure --prefix=/opt/software/libs
sudo make && sudo make install

cd ../libmcrypt-2.5.8/
./configure --prefix=/opt/software/libs
sudo make && sudo make install

#注意这里不是返回上级目录,而是在当前目录
cd libltdl/
./configure --prefix=/opt/software/libs --enable-ltdl-install
sudo make && sudo make install

cd ../../mhash-0.9.9.9/
./configure --prefix=/opt/software/libs
sudo make && sudo make install

6. 设置类库加载路径

sudo vim /etc/ld.so.conf.d/opt-software-libs.conf
输入
/opt/software/libs/lib
然后
sudo ldconfig

cd ../mcrypt-2.6.8/
export LDFLAGS="-L/opt/software/libs/lib -L/usr/lib"
export CFLAGS="-I/opt/software/libs/include -I/usr/include"
touch malloc.h
./configure --prefix=/opt/software/libs --with-libmcrypt-prefix=/opt/software/libs
sudo make && sudo make install

cd ../termcap-1.3.1/
./configure --prefix=/opt/software/libs
sudo make && sudo make install

7. 安装PHP

sudo apt-get install libxml2-dev
export LIBS="-lm -ltermcap -lresolv"
export DYLD_LIBRARY_PATH="/opt/software/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
export LD_LIBRARY_PATH="/opt/software/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"

cd ../php-5.4.29/
./configure --prefix=/opt/software/php --with-config-file-path=/opt/software/php/etc --with-mysql=/opt/software/mysql --with-mysqli=/opt/software/mysql/bin/mysql_config --with-iconv-dir --with-freetype-dir=/opt/software/libs --with-jpeg-dir=/opt/software/libs --with-png-dir=/opt/software/libs --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt=/opt/software/libs --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap

sudo ln -s /opt/software/mysql/lib/libmysqlclient.so.18 /usr/lib/

wget
sudo mv go-pear.phar /opt/software/php/bin

sudo make && sudo make install

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/225d8495e22a3e6000925cf808f80dfd.html