时间:2021-05-19
本文实例讲述了Centos7.4环境安装lamp-php7.0的方法。分享给大家供大家参考,具体如下:
一. 环境准备
桥接模式
能访问外网
#pingping得通则能到外网
关闭防火墙
#systemctl disable firewalld //禁用防火墙#systemctl stop firewalld //关闭防火墙关闭seLinux
#vim /etc/selinux/config改为:
SELINUX=disabled配置yum源
# cd /etc/yum.repos.d/# mkdir repo_bak //创建备份源文件夹# mv *.repo repo_bak/ //将源文件都放到备份文件夹# wget http://mirrors.aliyun.com/repo/Centos-7.repo //配置阿里源# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo //配置网易源# ls //列出/etc/yum.repos.d/目录下的文件Centos-7.repo CentOS-Base-163.repo repo.bak# yum clean all //清除系统所有yum缓存# yum makecache //生成yum缓存# yum list | grep epel-release //查看epel源列表# yum install -y epel-release //安装epel源# ls //epel源安装成功,比原来多了一个epel.repo和epel-testing.repo文件Centos-7.repo CentOS-Base-163.repo epel.repo epel-testing.repo repo.bak# wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo //下载阿里源的epel源# lsCentOS7-Base-163.repo Centos-7.repo epel-7.repo epel.repo epel-testing.repo repo_bak# yum clean all //再次清除系统yum缓存# yum makecache //重新生成新的yum缓存# yum repolist enabled //查看系统可用的yum源# yum repolist all //查看所有yum源删除旧版本
# yum -y remove php二. Apache
1. 安装Apache
# yum install httpd2. 配置Apache
# vim /etc/httpd/conf/httpd.conf//搜索# AddType application/x-gzip .gz .tgz//然后在后面添加# AddType application/x-httpd-php .php//搜索# IfModule dir_module//在DirectoryIndex下面添加 index.php//修改#ServerName :80# ServerName localhost:80修改默认Web站点目录
找到: DocumentRoot "/var/www/html"
修改为: DocumentRoot "/var/www"
找到:<Directory "/var/www/html">
修改为:<Directory "/var/www">
3. 启动Apache服务
# systemctl start httpd4. 查看httpd状态
systemctl status httpd三. PHP 7.0.7
1. 下载好对应版本的centos的PHP源码包
php-7.0.7.tar.gz2. 解压源码包
# tar zxvf php-7.0.7.tar.gz3. 进入解压包编译安装php所需要的依赖包
# yum install -y gcc gcc-c++ make automake autoconf gd file bison patch mlocate flex diffutils zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers openldap-devellibxslt-devel kernel-devel libtool-libs readline-devel gettext-devel libcap-devel php-mcrypt libmcrypt libmcrypt-devel recode-devel gmp-devel icu libxslt libxslt-devel php-devel# yum -y install libxslt-devel*# yum -y install perl*# yum -y install httpd-devel# find / -name apxs //得到的路径是:/usr/bin/apxs 编译参数的时候用到,是配置Apache支持PHP的关键参数4. 编译参数
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-zlib-dir \
--with-freetype-dir \
--enable-mbstring \
--with-libxml-dir=/usr \
--enable-xmlreader \
--enable-xmlwriter \
--enable-soap \
--enable-calendar \
--with-curl \
--with-zlib \
--with-gd \
--with-pdo-sqlite \
--with-pdo-mysql \
--with-mysqli \
--with-mysql-sock \
--enable-mysqlnd \
--disable-rpath \
--enable-inline-optimization \
--with-bz2 \
--with-zlib \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-pcntl \
--enable-mbregex \
--enable-exif \
--enable-bcmath \
--with-mhash \
--enable-zip \
--with-pcre-regex \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-openssl \
--enable-ftp \
--with-kerberos \
--with-gettext \
--with-xmlrpc \
--with-xsl \
--enable-fpm \
--with-fpm-user=php-fpm \
--with-fpm-group=php-fpm \
--with-fpm-systemd \
--with-apsx2 \
--disable-fileinfo
6. 编译并安装
# make && make install7. 安装完查看PHP版本
# /usr/local/php/bin/php -v8. 编辑 /etc/profil 添加环境变量
# vim /etc/profil添加进去
PATH=$PATH:/usr/local/php/binexport PATH9. 更新环境变量
# source /etc/profile10. 查看环境变量
# echo $PATH11. 查看PHP版本
# php -v12. 配置PHP配置文件php-fpm
# cp php.ini-production /etc/php.ini# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf# cp /usr/local/php/etc/php-fpm.d//get/mysql57-community-release-el7-11.noarch.rpm2. yum安装MySQL
# yum install mysql-community-server3. 启动MySQL
# systemctl start mysqld# systemctl enable mysqld //开机自启4. 在更改root默认密码前,可以根据需要,关闭密码策略。 如果没有关闭密码策略,则新密码要求是大小写字母+数字+字符的组合。
# vim /etc/my.cnf[mysqld]validate_password = off//重启,使修改后的密码策略生效# systemctl restart mysqld5. 修改MySQL的root默认密码
//查看默认密码# grep 'temporary password' /var/log/mysqld.log//默认密码是: )U4FB:Kw!evF# 2018-12-18 A temporary password is generated for root@localhost: )U4FB:Kw!evF运行安全设置向导,并修改默认密码
mysql_secure_installation//输入root默认密码Enter password for user root: ***//设置新密码New password:***Re-enter new password: ***//是否更改root密码Change the password for root ? ((Press y|Y for Yes, any other key for No) ://直接回车,表示No//是否删除匿名用户Remove anonymous users? (Press y|Y for Yes, any other key for No) : y//禁止root远程登录Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y//删除test数据库Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y//重新加载权限表Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y//也可以使用mysql直接更改root密码mysql -uroot -pALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';exit;//为安全root仅限本地登录,根据需要可以新建一个有管理员权限的远程用户mysql -uroot -pGRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' IDENTIFIED BY '登录密码' WITH GRANT OPTION;FLUSH PRIVILEGES;exit;安装完成
希望本文所述对大家CentOS服务器配置有所帮助。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
PHP7.0正式版也出来了,今天编译安装了一下,写下安装步骤,我是在centos6.6环境中编译的,下面是详细的安装步骤环境依赖yuminstallgccgcc
系统环境:centos7.4一,查看是否安装有数据库:yumlistinstalled|grepmysqld/mariadb二,安装centos7系统带有mys
操作系统:阿里云esc实例centos7.4软件:docker-ceversion18.09.3,docker-composeversion1.23.2一.创建
初级第一次在linux下安装mysql-5.7.19版本教程,如果已经会安装了,那么请看下一篇linux下安装多个mysql-5.7.19环境:centos6.
本文实例讲述了CentOS6/7环境下通过yum安装php7的方法。分享给大家供大家参考,具体如下:安装php7已经是现在linux服务器必备的一款工具了,只要