centos7 PHP mysql安装_CentOs7安装php7、mysql5.7、httpd2.4

本文详细介绍了如何在CentOS7系统中安装Apache HTTP Server、MySQL 5.7和PHP。首先,通过编译安装配置Apache,接着安装MySQL并设置密码,最后安装PHP及其相关扩展,确保所有服务能够正常运行。
摘要由CSDN通过智能技术生成

一、安装HTTP(Apache)

1.安装APR 和 APR-Util

所用代码cd apr

./configure --prefix=/usr/local/ap

make && make install

cd apr-util

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config

make && make install

cd pcre

./configure --prefix=/usr/local/pcre --with-apr=/usr/local/apr/bin/apr-1-config

make && make install

cd httpd

./configure --prefix=/usr/local/httpd --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

make && make install

2.配置http开机自启动

所用代码cp /usr/local/httpd/bin/apachectl /etc/rc.d/init.d/httpd

vim /etc/rc.d/init.d/httpd

//注册到linux服务列表

/**

添加如下代码

chkconfig: 35 61 61

description: Apache

**/

chkconfig --add httpd

//启动 关闭 重启

./apachectl start

./apachectl stop

./apachectl restart

二、安装MySQL 5.7.x

所用代码//创建用户组

groupadd mysql

//创建用户并添加用户到用户组

useradd -r -g mysql mysql

//修改mysql目录所有者

chown -R mysql:mysql ./

//在mysql目录下创建data空目录

mkdir data

//安装mysql

mysql/bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data

//如果报错用下面的代码

mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data --initialize

//安装完成后编辑 /etc/my.cnf

[mysqld]

datadir=/usr/local/mysql/data

basedir=/usr/local/mysql

socket=/tmp/mysql.sock

user=mysql

port=3306

character-set-server=utf8

# 取消密码验证

skip-grant-tables

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

# skip-grant-tables

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

//开启服务

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

//开机自启

chkconfig mysql on

//启动服务

service mysql start

//登录数据库

mysql/bin/mysql -u root -p

//修改密码

update user set authentication_string=password('你的密码') where user='root';

//刷新权限

flush privileges;

//退出将/etc/my.cnf中的skip-grant-tables删除

//登录再次设置密码

ALTER USER 'root'@'localhost' IDENTIFIED BY '修改后的密码';

//退出系统再次进入就可以正常使用数据库了

三、安装phpyum -y install libcurl-devel

yum -y install libXpm-devel

yum -y install libxml2-devel

yum -y install php-mbstring

安装libmcrypt./configure

make && make install

安装libvpx./configure --prefix=/usr/local/libvpx --enable-shared --enable-vp9

make && make install

安装tiff./configure --prefix=/usr/local/tiff --enable-shared

make && make install

安装libpng./configure --prefix=/usr/local/libpng --enable-shared

make && make install

安装freetype./configure --prefix=/usr/local/freetype --enable-shared

make && make install

安装jpeg./configure --prefix=/usr/local/jpeg --enable-shared

make && make install

安装libgd./configure --prefix=/usr/local/libgd --enable-shared --with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/freetype --with-xpm=/usr/ --with-tiff=/usr/local/tiff --with-webp=/usr/local/libwebp/

make && make install

安装php./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-gd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/ --with-zlib-dir=/usr/local/zlib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --enable-ctype

make && make install

可能会出现关于zip扩展的错误信息,如果出现则把其中关于zip的扩展去掉

参考博客:https://www.cnblogs.com/zoulongbin/p/6379272.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值