1、步骤一:tar 命令 tar -zxvf 源码包(.tar.gz结尾的压缩包)的路径,(.bzip2结尾的用jxvf)
2、步骤二:进入到解压目录,cd命令
3、步骤三:配置, ./configure --prefix=指定安装目录
4、步骤四:编译,make
5、步骤五:安装,make install
准备工作:
先使用winscp连接服务器,将包置于/php/tools目录下。
安装开始:
一、安装mysql,先通过yum安装mysql所需依赖
yum -y install gcc gcc-c++ cmake ncurses-devel
二、进入到mysql源码包目录下
cd /php/tools/mysql
三、解压
tar -zxvf mysql-5.6.35.tar.gz
四、进入解压目录
cd mysql-5.6.35
五、配置
cmake -dcmake_install_prefix=/php/server/mysql -dmysql_datadir=/php/server/data -ddefault_charset=utf8 -ddefault_collation=utf8_general_ci
六、编译安装
make && make install
相关推荐:《php入门教程》
七、配置mysql
1、复制安装目录中的mysql配置文件,到/etc/my.cnf。
\cp -r /php/tools/mysql/mysql-5.6.35/support-files/my-default.cnf /etc/my.cnf
2、修改mysql配置文件(声明mysql数据存放目录)
vi /etc/my.cnf
在[mysqld]下设置这一行:datadir = /php/server/data
3、创建mysql用户组并创建用户加入用户组
groupadd mysqluseradd -g mysql -s /sbin/nologin mysql
4、初始化数据库(执行下述命令会在data目录下生成mysql/test等默认数据库)
/php/server/mysql/scripts/mysql_install_db \--basedir=/php/server/mysql \--datadir=/php/server/data \--user=mysql
报错:
安装autoconf解决,再执行上面命令一次
yum -y install autoconf
5、启动mysql服务(注:&表示后台启动)
/php/server/mysql/bin/mysqld_safe --user=mysql &
6、验证mysql服务是否启动成功(相当于win查看进程)
ps -a | grep mysql
7、初始化数据库,设置root帐户的密码(默认密码空)
/php/server/mysql/bin/mysql -uroot -p#回车输入密码,然后执行下述sql语句
删除测试数据库 && 删除本机匿名连接的空密码帐号
drop database test; delete from mysql.user where user='';
修改密码
update mysql.user set password=password('admin888') where user='root';flush privileges;
忘记密码,强制修改密码
1、打开mysql配置文件
vi /etc/my.cnf
2、在[mysqld]下一行添加 skip-grant-tables
3、重启mysql服务
4、重新登陆mysql(因为上面的操作,这时密码为空)
5、修改密码
6、删除mysql配置文件:my.cnf 中刚添加的: skip-grant-tables
7、再重启 msyql服务即可
安装apache
1、安装zlib
shell> cd /php/tools/apache #进入tools目录shell> tar zxvf zlib-1.2.5.tar.gz #解压zlib安装包shell> cd zlib-1.2.5 #进入解压目录shell> ./configure #这个配置编译命令不要加目录参数shell> make && make install
2、安装apache
shell> cd /php/tools/apache #进入tools目录shell> tar -jxvf httpd-2.2.19.tar.bz2 #解压apache安装包shell> cd httpd-2.2.19 #进入解压目录shell> #配置./configure --prefix=/php/server/apache --enable-modules=all --enable-mods-shared=all --enable-soshell> make && make install
若解压报错如下,则需安装bzip2
tar (child): lbzip2: cannot exec: no such file or directorytar (child): error is not recoverable: exiting nowtar: child returned status 2tar: error is not recoverable: exiting now
安装命令
yum -y install bzip2
测试
修改配置文件
vi /php/server/apache/conf/httpd.conf
启动服务
/php/server/apache/bin/apachectl start/stop/restart
查看
ps -a | grep httpd
安装php
shell> cd /php/tools/phpshell> tar -jxvf php-7.2.6.tar.bz2shell> cd php-7.2.6shell> #配置./configure --prefix=/php/server/php --with-apxs2=/php/server/apache/bin/apxs --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-zlib --enable-mbstring=all --enable-mbregex --enable-sharedshell>make && make install
配置若报libxml2错
yum -y install libxml2 libxml2-devel
配置apache支持php
1、复制php.ini配置文件到指定目录
shell> \cp -r /php/tools/php/php-7.2.6/php.ini-development /php/server/php/lib/php.ini
2、修改apache配置文件(检测遇到.php结尾的文件交给php模块处理)
shell> vi /php/server/apache/conf/httpd.conf
在httpd.conf(apache主配置文件)中增加:addtype application/x-httpd-php .php
3、重启apache
/php/server/apache/bin/apachectl stop/php/server/apache/bin/apachectl start
4、查看效果
shell> echo '<?php phpinfo();' > /php/server/apache/htdocs/test.php
管理
1、mysql
【mysql配置文件】
/etc/my.cnf
【开启mysql服务】
/php/server/mysql/bin/mysqld_safe --user=mysql &
【关闭mysql服务】
ps -a | grep mysql # 查看mysql进程killall 服务名 #结束进程 关闭mysql服务
【登陆mysql数据库】
/php/server/mysql/bin/mysql -uroot -p
2、apache
/php/server/apache/bin/apachectl start/php/server/apache/bin/apachectl stop/php/server/apache/bin/apachectl restart
配置文件: /php/server/apache/conf/httpd.conf
优化:将apache、mysql加为系统服务
1、添加apache的服务脚本
\cp -r /php/server/apache/bin/apachectl /etc/rc.d/init.d/httpdln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/s61httpd
2、编辑httpd脚本,在第二行添加如下注释信息
vi /etc/rc.d/init.d/httpd
comments to support chkconfig on redhat linux
chkconfig: 2345 90 90
description:http server
!注意用#注释
3、修改脚本使其支持chkconfig
chkconfig --add httpdchkconfig --level 2345 httpd on
4、重启服务
service httpd restart
centos下将mysql添加到服务
1、将mysql.server这个文件copy到/etc/init.d/目录下,并更名为mysql
\cp -r /php/tools/mysql/mysql-5.6.35/support-files/mysql.server /etc/init.d/mysql
2、给mysql这个文件赋予“执行”权限 && 加入到开机自动运行
chmod 755 /etc/init.d/mysql chkconfig --add mysql
3、重启服务
service mysql restart
以上就是php源码包安装步骤是什么的详细内容。