php5.6+apache2.2+mysql5.6源码包安装

本人亲自在centos7安装测试,自己总结小经验。

首先安装相关依赖,这里采用yum安装


yum install gcc gcc-c++ glibc glibc-devel gd gd-devel zlib zlib-devel libtool-ltdl-devel flex autoconf automake 



yum  install  vim zip unzip


一、apache安装
下载四个核心包
1、安装apr
./configure --prefix=/usr/local/apr  
make  
make install
一般错误:
cannot remove `libtoolT': No such file or directory
$RM “$cfgfile”注释掉


2、安装apr-iconv
./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr  
make  
make install
3、安装apr-util
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr --with-apr-iconv=/usr/local/apr-iconv/bin/apr-iconv  
make  
make install  
4、安装pcre
./configure --prefix=/usr/local/pcre


make
make install
5、安装apache


./configure --prefix=/usr/local/apache --enable-so-rewrite=SHARED --with-mpm=prefork --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-apr-iconv=/usr/local/apr-iconv --with-pcre=/usr/local/pcre
make
make install


启动apache 进去bin/中启动


6、修改配置文件

有时候安装完成后,访问不了,可能配置问题



ServerName localhost:80


7、关闭防火墙

主机不能访问虚拟机,

systemctl stop firewalld.service#停止firewall


二、安装mysql

有时候安装mysql,老是提示失败,因为centos7中默认安装mariadb,需要提前卸载,再进行安装。

1、清除mariadb

查找

rpm -qa | grep mariadb -i

卸载

rpm -e --nodeps 。。。。
2、groupadd mysql
   useradd useradd -r -g mysql mysql
3、安装依赖
yum install libaio net-tools numactl -y

4、安装

需按顺序安装

client dev service

命令 

rpm -ivh 。。。

5、 启动 service mysql start
6、查看初始密码
cat /root/.mysql_secret
7修改密码
set password for 'root'@'localhost' =password('root');
update user set password=password('root') where user='root';
update user set host='%' where user='root' and host='localhost';
flush privileges;
8、加入系统服务
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
三、安装php
1、安装相关依赖
yum install libxml2


yum install libxml2-devel -y
yum install bzip2* -y
yum install libcurl* -y
安装第三方yum源
wget http://www.atomicorp.com/installers/atomic
sh ./atomic
yum  install  php-mcrypt  libmcrypt  libmcrypt-devel 


./configure --prefix=/usr/local/php \
--with-libxml-dir=/usr/include/libxml2 --with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-config-file-path=/usr/local/apache/conf \
--with-gd --enable-gd-native-ttf \
--with-zlib --with-mcrypt  --enable-shmop \
--enable-soap --enable-sockets --enable-wddx --enable-zip --with-xmlrpc \
--enable-fpm --enable-mbstring --with-zlib-dir --with-bz2 --with-curl --enable-exif \
--enable-ftp --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib \
--with-freetype-dir=/usr/lib/ 
make
make install




2、配置php
cp php.ini-development /usr/local/php/etc/php.ini
3、启动fpm
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
 chmod +x /etc/init.d/php-fpm
service php-fpm start






3、配置apache
修改DirectoryIndex index.html 为DirectoryIndex index.html index.php
并添加AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .php5


ln -s /var/lib/mysql/mysql.sock mysql.sock


mysql.default_socket =/mnt/mydata/mysql.sock
mysqli.default_socket =/mnt/mydata/mysql.sock
pdo_mysql.default_socket=/mnt/mydata/mysql.sock


4、安装相关模块
进入php安装包
执行/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
生成的so文件,在php。ini中添加extension=bcmath.so

你可能感兴趣的:(PHP环境配置)