ubuntu php 源码编译译安装php都需要哪些基础安装包

作者小波/QQ欢迎转载!
Linux:redhat 6/centos 6
继续上一篇笔记Apache的配置,然后下面记录Linux安装php的过程。
第一步:安装依赖的包libxml2,libxml2-devel
如果没有安装的话,在安装php过程中会出现如下的错误:
configure: error: xml2-config not found. Please check your libxml2 installation.
所以先用yum安装好依赖的包:
yum install libxml2
yum install libxml2-devel
第二步:下载、解压php安装包,以及php的配置:
下载地址:&http://www.php.net/downloads.php解压安装包:&&&
tar -zxvf +php包
进入解压包文件夹内执行:
./configure --prefix=/work/installed/php
--with-apxs2=/work/installed/apache/bin/apxs
其中:--with-apxs2=/work/installed/apache/bin/apxs 是安装完后Apache目录下的 这里是我的安装目录地址(视你的情况而定)
然后编译:&&& make&&&测试编译:&&& make test&&&最后安装:&&& make install
配置文件:
&&#&root@php-5.3.16/ cp php.ini-development& /work/installed/php/lib/php.ini&&& 把原来位于源代码里面的php.ini-development拷贝到/usr/local/php/lib/php.ini下,并且重命名为php.ini
在原来Apache解压包内重新执行如下命令:(本笔记紧跟上一个笔记Apache的配置)
./configure --prefix=/work/installed/apache --with-apr=/work/installed/apr --with-apr-util=/work/installed/apr-util --with- pcre=/work/installed/pcre --enable-module=shared
&./configure --prefix=/work/installed/apache --with-apr=/work/installed/apr --with-apr-util=/work/installed/apr-util --with- pcre=/work/installed/pcre --enable-module=shared&
要加上后面的参数,否则无法使用php,-enable-module=shared表示Apache可以动态的加载模块
& 编辑并配置Apache里面文件
&&编辑 /work/installed/conf/httpd.conf 文件&&& (别人有的自定义安装的目录/usr/local/apache/conf/httpd.conf&&&&&&&&& 找到:&&& AddType& application/x-compress .Z&&& AddType application/x-gzip .gz .tgz&&& 在后面添加:&&& AddType application/x-httpd-php .php
&&& AddType application/x-httpd-php-source .php5&&&
&&& 目的是使Apcche支持PHP
找到:&&& &IfModule dir_module&&&& DirectoryIndex index.html&&& &/IfModule&&&& 添加:在index.html后面添加index.php就行啦!(这个在上一个笔记配置Apache中已经写到Apache的配置)&&& &IfModule dir_module&&&& DirectoryIndex index.html index.php&&& &/IfModule&&&
重启apache: 在安装的Apache目录下重启:
/work/installed/apache/bin/apachectl restart
第三步测试php:
在发布网页的目录下建立一个文index.php的文件:
默认的是在apache的htdocs下建立一个php文件index.php,里面的内容如下:&&& &?php&&& phpinfo();&&& ?&
我的发布目录则是在/home/web/下建立 index.php文件
出现如上内容则测试成功!
阅读(...) 评论()Linux下PHP的源码安装与配置_服务器应用_Linux公社-Linux系统门户网站
你好,游客
Linux下PHP的源码安装与配置
来源:Linux社区&
作者:xiaobo-Linux
Linux: 6/ 6
继续上一篇笔记Apache的配置,然后下面记录Linux安装php的过程。
第一步:安装依赖的包libxml2,libxml2-devel
如果没有安装的话,在安装php过程中会出现如下的错误:
configure: error: xml2-config not found. Please check your libxml2 installation.
所以先用yum安装好依赖的包:
yum install libxml2
yum install libxml2-devel
第二步:下载、解压php安装包,以及php的配置:
下载地址:
解压安装包:
tar -zxvf +php包
进入解压包文件夹内执行:
./configure --prefix=/work/installed/php& --with-apxs2=/work/installed/apache/bin/apxs
其中:--with-apxs2=/work/installed/apache/bin/apxs 是安装完后Apache目录下的 这里是我的安装目录地址(视你的情况而定)
然后编译:
测试编译:
最后安装:
make install
配置文件:
# root@php-5.3.16/ cp php.ini-development& /work/installed/php/lib/php.ini
把原来位于源代码里面的php.ini-development拷贝到/usr/local/php/lib/php.ini下,并且重命名为php.ini
在原来Apache解压包内重新执行如下命令:(本笔记紧跟上一个笔记Apache的配置)
./configure --prefix=/work/installed/apache --with-apr=/work/installed/apr --with-apr-util=/work/installed/apr-util --with- pcre=/work/installed/pcre --enable-module=shared
./configure --prefix=/work/installed/apache --with-apr=/work/installed/apr --with-apr-util=/work/installed/apr-util --with- pcre=/work/installed/pcre --enable-module=shared
要加上后面的参数,否则无法使用php,-enable-module=shared表示Apache可以动态的加载模块
编辑并配置Apache里面文件
编辑 /work/installed/conf/httpd.conf 文件& & (别人有的自定义安装的目录/usr/local/apache/conf/httpd.conf
AddType& application/x-compress .Z
AddType application/x-gzip .gz .tgz
在后面添加:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .php5
目的是使Apcche支持PHP
DirectoryIndex index.html
添加:在index.html后面添加index.php就行啦!(这个在上一个笔记配置Apache中已经写到Apache的配置)
DirectoryIndex index.html index.php
重启apache: 在安装的Apache目录下重启:
/work/installed/apache/bin/apachectl restart
第三步测试php:
在发布网页的目录下建立一个文index.php的文件:
默认的是在apache的htdocs下建立一个php文件index.php,里面的内容如下:
我的发布目录则是在/home/web/下建立 index.php文件
出现如上内容则测试成功!
PHP 7 ,你值得拥有&
在 CentOS 7.x /
21 上面体验 PHP 7.0&
CentOS 6.3 安装LNMP (PHP 5.4,MyySQL5.6)
在部署LNMP的时候遇到Nginx启动失败的2个问题
安装Nginx php5-fpm MySQL(LNMP环境搭建)
《细说PHP》高清扫描PDF+光盘源码+全套教学视频
CentOS 6中配置PHP的LNMP的开发环境&
PHP 的详细介绍:PHP 的下载地址:
本文永久更新链接地址:
相关资讯 & & &
& (09/12/:05)
& (08/04/:37)
& (02/28/:46)
& (08/29/:47)
& (07/28/:22)
& (01/07/:03)
   同意评论声明
   发表
尊重网上道德,遵守中华人民共和国的各项有关法律法规
承担一切因您的行为而直接或间接导致的民事或刑事法律责任
本站管理人员有权保留或删除其管辖留言中的任意内容
本站有权在网站内转载或引用您的评论
参与本评论即表明您已经阅读并接受上述条款博客访问: 2928667
博文数量: 176
注册时间:
认证徽章:
Happy is the man who is living by his hobby.
IT168企业级官微
微信号:IT168qiye
系统架构师大会
微信号:SACC2013
分类: MySQL
1 下载安装包download tar.gz
wget http://download.csdn.net/detail/mchdba/7545037
2 安装cmake软件包
yum install cmake -y
3 create account of mysql
groupadd mysql & & & & &&
useradd -g mysql mysql & & & & &&
autoreconf --force --install
libtoolize --automake --force
automake --force --add-missing
4 &complie the sources
数据目录 &: /home/data/mysql/data
mysql软件目录 &: /usr/local/mysql
mkdir -p /home/data/mysql/data
mkdir -p /usr/local/mysql
tar -xvf mysql-5.6.12.tar.gz&
cd mysql-5.6.12
[root@squid-2 mysql-5.6.12]# time cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/home/data/mysql/data -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR==/usr/local/mysql/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
-- Check size of wint_t
-- Check size of wint_t - done
-- Could NOT find Curses &(missing: &CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:85 (MESSAGE):
& Curses library not found. &Please install appropriate package,
& & & remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
& cmake/readline.cmake:128 (FIND_CURSES)
& cmake/readline.cmake:202 (MYSQL_USE_BUNDLED_EDITLINE)
& CMakeLists.txt:325 (MYSQL_CHECK_EDITLINE)
-- Configuring incomplete, errors occurred!
real 0m41.872s
user 0m23.508s
sys 0m16.328s
6 yum install make
[root@472322 mysql-5.6.13]#&
[root@squid-2 mysql-5.6.12]# find / -name CMakeCache.txt
/root/mysql/mysql-5.6.12/CMakeCache.txt
安装ncurses-devel
yum -y install ncurses-devel
再报错如下:
-- Performing Test HAVE_PEERCRED
CMake Error at /usr/share/cmake/Modules/CMakeCXXInformation.cmake:17 (GET_FILENAME_COMPONENT):
& get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
& CMakeLists.txt:3 (PROJECT)
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Performing Test HAVE_PEERCRED - Failed
-- Library mysqlclient depends on OSLIBS -m;dl
-- Googlemock was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an http proxy: export http_proxy=:80
Warning: Bison executable not found in PATH
-- Library mysqlserver depends on OSLIBS -m;dl
-- Configuring incomplete, errors occurred!
real 0m42.841s
user 0m24.527s
sys 0m16.543s
-- Configuring incomplete, errors occurred!
real & &0m0.510s
user & &0m0.275s
sys & & 0m0.112s
[root@472322 mysql-5.6.13]#&
yum install gcc gcc-c++ -y
& & yum install -y ncurses-devel.x86_64
& & yum install -y cmake.x86_64
& & yum install -y libaio.x86_64
& & yum install -y bison.x86_64
yum install -y gcc-c++.x86_64
[解决办法]:删除原来的mysql-5.6.12目录,重新解压缩tar.gz包
8 重新执行编译
rm -rf /root/mysql-5.6.12
tar -xvf mysql-5.6.12.tar.gz&
cd /root/mysql-5.6.12
time cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/home/data/mysql/data -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR==/usr/local/mysql/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
-- Looking for asprintf - found
-- Check size of pthread_t
-- Check size of pthread_t - done
-- Using cmake version 2.6.4
-- Not building NDB
-- Performing Test HAVE_PEERCRED
-- Performing Test HAVE_PEERCRED - Success
-- Library mysqlclient depends on OSLIBS -m;dl
-- Googlemock was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an http proxy: export http_proxy=:80
-- Library mysqlserver depends on OSLIBS -m;dl
-- Configuring done
-- Generating done
-- Build files have been written to: /root/mysql/mysql-5.6.12
real 0m45.943s
user 0m26.213s
sys 0m17.661s
time make&
这一步时间比较长,需要耐心等待,看中间是否有error信息产生。
会看到很多Building信息
[ 38%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/lock/lock0iter.cc.o
[ 38%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/lock/lock0lock.cc.o
[ 38%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/lock/lock0wait.cc.o
[ 38%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/log/log0log.cc.o
[ 39%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/log/log0recv.cc.o
[ 39%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/mach/mach0data.cc.o
[ 39%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/mem/mem0mem.cc.o
[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o
Linking CXX executable my_safe_process
[100%] Built target my_safe_process
real 21m39.375s
user 18m9.239s
sys 1m34.320s
time make install
这个命令比较快
-- Installing: /usr/local/mysql/man/man8/mysqld.8
-- Installing: /usr/local/mysql/support-files/solaris/postinstall-solaris
real 0m8.439s
user 0m3.353s
sys 0m4.616s
9 init db,初始化数据库
ll /home/data/mysql/data
cd /home/data/mysql/data
先赋予文件夹mysql权限
chown -R mysql /home/data/mysql/data
chgrp -R mysql /home/data/mysql/data
chown -R mysql /usr/local/mysql/
chgrp -R mysql /usr/local/mysql/
cd /usr/local/mysql/
cp support-files/f /f
scripts/mysql_install_db &--user=mysql --basedir=/usr/local/mysql --datadir=/home/data/mysql/data --defaults-file=/usr/local/f
[root@localhost mysql]# scripts/mysql_install_db &--user=mysql --basedir=/usr/local/mysql --datadir=/home/data/mysql/data --defaults-file=/usr/local/f
Installing MySQL system tables.../usr/local/mysql/bin/mysqld: File '/home/data/mysql/binlog/mysql-bin.index' not found (Errcode: 2 - No such file or directory)
10:47:14 9686 [ERROR] Aborting
10:47:14 9686 [Note] Binlog end
10:47:14 9686 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
[root@localhost mysql]# mkdir -p /home/data/mysql/binlog/
[root@localhost mysql]#
[root@localhost mysql]# chown -R mysql /home/data/mysql/binlog/
[root@localhost mysql]# chgrp -R mysql /home/data/mysql/binlog/
建好目录,再执行数据库初始化:
[root@472322 mysql56]# scripts/mysql_install_db &--user=mysql --basedir=/usr/local/mysql --datadir=/home/data/mysql/data --defaults-file=/usr/local/f
Installing MySQL system tables... 05:06:03 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
05:06:03 19416 [Note] InnoDB: The InnoDB memory heap is disabled
05:06:03 19416 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
05:06:03 19416 [Note] InnoDB: Compressed tables use zlib 1.2.3
05:06:03 19416 [Note] InnoDB: Using CPU crc32 instructions
05:06:03 19416 [Note] InnoDB: Initializing buffer pool, size = 128.0M
05:06:03 19416 [Note] InnoDB: Completed initialization of buffer pool
05:06:03 19416 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
05:06:03 19416 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
05:06:03 19416 [Note] InnoDB: Database physically writes the file full: wait...
05:06:03 19416 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
05:06:03 19416 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
05:06:03 19416 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
05:06:03 19416 [Warning] InnoDB: New log files created, LSN=45781
05:06:03 19416 [Note] InnoDB: Doublewrite buffer not found: creating new
05:06:03 19416 [Note] InnoDB: Doublewrite buffer created
05:06:03 19416 [Note] InnoDB: 128 rollback segment(s) are active.
05:06:03 19416 [Warning] InnoDB: Creating foreign key constraint system tables.
05:06:03 19416 [Note] InnoDB: Foreign key constraint system tables created
05:06:03 19416 [Note] InnoDB: Creating tablespace and datafile system tables.
05:06:03 19416 [Note] InnoDB: Tablespace and datafile system tables created.
05:06:03 19416 [Note] InnoDB: Waiting for purge to start
05:06:03 19416 [Note] InnoDB: 5.6.13 log sequence number 0
05:06:04 19416 [Note] Binlog end
05:06:04 19416 [Note] InnoDB: FTS optimize thread exiting.
05:06:04 19416 [Note] InnoDB: Starting shutdown...
05:06:05 19416 [Note] InnoDB: S log sequence number 1625977
Filling help tables... 05:06:05 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
05:06:05 19439 [Note] InnoDB: The InnoDB memory heap is disabled
05:06:05 19439 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
05:06:05 19439 [Note] InnoDB: Compressed tables use zlib 1.2.3
05:06:05 19439 [Note] InnoDB: Using CPU crc32 instructions
05:06:05 19439 [Note] InnoDB: Initializing buffer pool, size = 128.0M
05:06:05 19439 [Note] InnoDB: Completed initialization of buffer pool
05:06:05 19439 [Note] InnoDB: Highest supported file format is Barracuda.
05:06:05 19439 [Note] InnoDB: 128 rollback segment(s) are active.
05:06:05 19439 [Note] InnoDB: Waiting for purge to start
05:06:05 19439 [Note] InnoDB: 5.6.13 log sequence number 1625977
05:06:05 19439 [Note] Binlog end
05:06:05 19439 [Note] InnoDB: FTS optimize thread exiting.
05:06:05 19439 [Note] InnoDB: Starting shutdown...
05:06:06 19439 [Note] InnoDB: S log sequence number 1625987
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
& /usr/local/mysql56/bin/mysqladmin -u root password 'new-password'
& /usr/local/mysql56/bin/mysqladmin -u root -h
password 'new-password'
Alternatively you can run:
& /usr/local/mysql56/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. &This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
& cd . ; /usr/local/mysql56/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
& cd mysql- perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbug script!
The latest information about MySQL is available on the web at
Support MySQL by buying support/licenses at
New default config file was created as /usr/local/f and
will be used by default by the server when you start it.
You may edit this file to change server settings
WARNING: Default config file /f exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
[root@472322 mysql56]#&
10 copy start command&
cp support-files/mysql.server /etc/init.d/mysqld5612
chmod 700 /etc/init.d/mysqld5612
echo "export PATH=$PATH:/usr/local/mysql/bin">>/etc/profile&
source /etc/profile
11 添加开机启动
chkconfig --add mysqld5612
12 &start service&
service mysqld5612 start
[root@squid-2 mysql]# service mysqld5612 start
Starting MySQL.......The server quit without updating PID f[失败]usr/local/mysql/mysqld.pid).
[root@squid-2 mysql]#&
查看日志报错如下:
14:56:54 31726 [Note] Server socket created on IP: '::'.
14:56:54 31726 [ERROR] Can't start server : Bind on unix socket: Permission denied
14:56:54 31726 [ERROR] Do you already have another mysqld server running on socket: /usr/local/mysql/mysql.sock ?
14:56:54 31726 [ERROR] Aborting
解决原因是:
/usr/local/mysql跟目录需要赋予mysql权限
根据日志文件显示,首先检查运行权限,再看一下/usr/local/mysql/mysql.sock,发现/usr/local/mysql目录下并没有该文件,是否是没有权限写目录?
看到/usr/local/mysql目录是root用户,所以赋予mysql操作权限。
chown -R mysql.mysql /usr/local/mysql
[root@472322 data56]# service mysqld5612 start
Starting MySQL. SUCCESS!&
[root@472322 data56]# mysql
Welcome to the MySQL monitor. &C or \g.
Your MySQL connection id is 1
Server version: 5.6.13 Source distribution
Copyright (c) , Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
Type '' or '\h' for help. Type '\c' to clear the current input statement.
+--------------------+
| Database & & & & & |
+--------------------+
| information_schema |
| mysql & & & & & & &|
| performance_schema |
| test & & & & & & & |
+--------------------+
4 rows in set (0.00 sec)
阅读(30559) | 评论(4) | 转发(1) |
相关热门文章
给主人留下些什么吧!~~
time&scripts/mysql_install_db&&--user=mysql&--basedir=/usr/local/mysql&--datadir=/home/data/mysql/data&--defaults-file=/fcp&support-files/mysql.server&/etc/init.d/mysqlchmod&700&/etc/init.d/mysqlecho&&export&PATH=$PATH:/usr/local/mysql/bin&&&/etc/profile&source&/etc/profilechkconfig&--add&mysql
time&cmake&.&-DCMAKE_INSTALL_PREFIX=/usr/local/mysql&-DMYSQL_DATADIR=/home/data/mysql/data&-DWITH_INNOBASE_STORAGE_ENGINE=1&-DMYSQL_UNIX_ADDR==/usr/local/mysql/mysql.sock&-DMYSQL_USER=mysql&-DDEFAULT_CHARSET=utf8&-DDEFAULT_COLLATION=utf8_general_citime&make&time&make&installcd&/home/data/mysql/datachown&-R&mysql&/home/data/mysql/datachgrp&-R&mysql&/home/data/mysql/datachown&-R&mysql&/usr/local/mysql/chgrp&-R&mysql&/usr
yum&install&gcc&gcc-c++&-yyum&install&-y&ncurses-devel.x86_64yum&install&-y&cmake.x86_64yum&install&-y&libaio.x86_64yum&install&-y&bison.x86_64yum&install&-y&gcc-c++.x86_64yum&install&make&-ymkdir&-p&/home/data/mysql/datamkdir&-p&/usr/local/mysql&tar&-xvf&mysql-5.6.12.tar.gz&&cd&mysql-5.6.12
命令总结:yum&install&cmake&-ygroupadd&mysqluseradd&-g&mysql&mysql&&autoreconf&--force&--installlibtoolize&--automake&--forceautomake&--force&--add-missingyum&install&-y&libtoolize
请登录后评论。2015博客升级记(五):CentOS 7.1编译安装PHP7 - 推酷
2015博客升级记(五):CentOS 7.1编译安装PHP7
这是《2015年博客升级记》系列文章的第五篇,主要记录在Linux系统中如何编译安装PHP7。
1 创建php用户和用户组,并在github下载php7源码
首先创建一个名为php且 没有登录权限 的用户和一个名为php的用户组,然后去GitHub下载php7源码包。
#######新建php用户和php组
[root@typecodes ~]# groupadd -r php && useradd -r -g php -s /bin/false -d /usr/local/php7 -M php
######从GitHub下载php7安装包
[root@typecodes ~]# wget -c --no-check-certificate -O php7-src-master.zip /php/php-src/archive/master.zip
######开始解压php7包
[root@typecodes ~]# unzip -q php7-src-master.zip && cd php-src-master
#####安装编译php7时需要的依赖包
[root@typecodes php-src-master]# yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel
2 PHP7编译参数的配置
准备工作做好后,就开始正式配置php5.7.7rc的安装明细了。注意,操作时一定要先把下面反斜杠“\”后面添加的注释文字去掉!!!
[root@typecodes php-src-master]# ./configure
--prefix=/usr/local/php7 \
[PHP7安装的根目录]
--exec-prefix=/usr/local/php7 \
--bindir=/usr/local/php7/bin \
--sbindir=/usr/local/php7/sbin \
--includedir=/usr/local/php7/include \
--libdir=/usr/local/php7/lib/php \
--mandir=/usr/local/php7/php/man \
--with-config-file-path=/usr/local/php7/etc \
[PHP7的配置目录]
--with-mysql-sock=/var/run/mysql/mysql.sock \
[PHP7的Unix socket通信文件]
--with-mcrypt=/usr/include \
--with-mhash \
--with-openssl \
--with-mysql=shared,mysqlnd \
[PHP7依赖mysql库]
--with-mysqli=shared,mysqlnd \
[PHP7依赖mysql库]
--with-pdo-mysql=shared,mysqlnd \
[PHP7依赖mysql库]
--with-gd \
--with-iconv \
--with-zlib \
--enable-zip \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
[允许php会话session]
--with-curl \
[允许curl扩展]
--with-jpeg-dir \
--with-freetype-dir \
--enable-opcache \
[使用opcache缓存]
--enable-fpm \
--enable-fastcgi \
--with-fpm-user=nginx \
[php-fpm的用户]
--with-fpm-group=nginx \
[php-fpm的用户组]
--without-gdbm \
--disable-fileinfo
执行上面的配置命令的结果如下图所示:
3 开始编译和安装PHP7
相对编译安装MySQL的大量CPU和内存消耗,PHP7的编译安装轻松多了,整个过程大约1个小时左右。
[root@typecodes php-src-master]# make clean && make && make install
看到下图就代表已经编译安装好了PHP7!
4 选做步骤:执行make test命令进行测试
这是一个非必需的操作步骤,执行 make test 命令。
有趣的一件事就是:在test期间,会和一个IP地址72.52.91.14建立tcp连接,它对应着php官网
执行完 make test 命令后,最终的结果如下:
5 查看编译成功后的PHP7安装目录
由于需要和MySQL进行通信,所以需要特别查看PHP7安装后的lib扩展库目录(/usr/local/php7/lib/php/extensions/no-debug-non-zts-/)。需要确保至少存在 mysqli.so 、 pdo_mysql.so 这两个动态库文件,如下图所示。
6 开始设置PHP7的配置文件php.ini、php-fpm.conf、www.conf和php-fpm脚本
可以用编译后的配置文件复制到PHP7的配置目录(/usr/local/php7/etc/),推荐使用
文中整理的3个PHP7配置文件和php-fpm服务控制脚本。
#######方法一:直接使用编译后未经优化处理的配置
[root@typecodes php-src-master]# cp php.ini-production /usr/local/php7/etc/php.ini
[root@typecodes php-src-master]# cp /root/php-src-master/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@typecodes php-src-master]# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
[root@typecodes php-src-master]# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
#######方法二:使用/web/php7configure.html文中的配置
[root@typecodes php-src-master]# mv ~/php.ini /usr/local/php7/etc/php.ini && mv ~/php-fpm /etc/init.d/php-fpm
[root@typecodes php-src-master]# mv ~/php-fpm.conf /usr/local/php7/etc/php-fpm.conf && mv ~/www.conf /usr/local/php7/etc/php-fpm.d/www.conf
7 添加php的环境变量
将php编译生成的bin目录添加到当前Linux系统的环境变量中
[root@typecodes ~]# echo -e '\nexport PATH=/usr/local/php7/bin:/usr/local/php7/sbin:$PATH\n' && /etc/profile && source /etc/profile
8 创建php数据库文件的存放路径以及相关安全配置
在Linux主机上创建一个目录 /mydata/php/data ,用于存放php的数据库文件。同时设置其用户和用户组为之前创建的 php ,权限为777。这样其它用户是无法进行读写的,尽量保证数据库的安全。
#######设置PHP日志目录和php-fpm的运行进程ID文件(php-fpm.sock)目录
[root@typecodes ~]# mkdir -p /var/log/php-fpm/ && mkdir -p /var/run/php-fpm && cd /var/run/ && chown -R nginx:nginx php-fpm
#######修改session的目录配置
[root@typecodes etc]# mkdir -p /var/lib/php/session
[root@typecodes etc]# chown -R nginx:nginx /var/lib/php
9 设置PHP开机启动以及测试配置文件是否正确
######配置开机自启动,增加到主机sysV服务
[root@typecodes php-src-master]# chmod +x /etc/init.d/php-fpm
[root@typecodes php-src-master]# chkconfig --add php-fpm
[root@typecodes php-src-master]# chkconfig php-fpm on
######测试PHP的配置文件是否正确合法
[root@typecodes sbin]# php-fpm -t
[03-May-:04] NOTICE: configuration file /usr/local/php7/etc/php-fpm.conf test is successful
10 启动php服务
在完成上面的操作后,就可以正式使用php服务了。启动php进程服务的命令如下:
[root@typecodes sbin]# service php-fpm start
Starting php-fpm
然后可以通过命令 ps -aux|grep php 查看是否成功(图中的php-fpm进程数和进程用户nginx都是由www.conf中pm.start_servers和user的值分别决定的):
11 查看PHP7版本信息
最后,可以通过命令 php -v 查看当前PHP版本信息,图中可以看到当前PHP7还使用了Zend OPcache缓存,是因为在php.ini文件中添加了 zend_extension=opcache.so 配置。
已发表评论数()
请填写推刊名
描述不能大于100个字符!
权限设置: 公开
仅自己可见
正文不准确
标题不准确
排版有问题
主题不准确
没有分页内容
图片无法显示
视频无法显示
与原文不一致

我要回帖

更多关于 php源码编译 的文章

 

随机推荐