安装了centos7的基本版
网卡设置:在/etc/sysconfig/network-scripts/底下。
添加:
BOOTPROTO=static
IPADDR=192.168.1.230
NETMASK=255.255.255.0
GATEWAY=192.168.1.254
DNS=114.114.114.114
MM_CONTROLLED=no
……
ONBOOT=yes
yum安装连不上,ping网关和dns都是通的。于是
vi /etc/resolv.conf
添加:
nameserver 114.114.114.114
service network restart
安装GCC。
yum -y install gcc
yum -y install gcc-c++
cd bzip2-1.0.6
make -f Makefile-libbz2_so //-f 标志是使bzip2 根据另一个Makefile来编译,就是Makefile-libbz2_so文件,创建一个动态的libbz.so库文件,然后把bzip2工具连接到这个库上
make && make install
tar jxvf apr-1.6.2.tar.bz2
tar jxvf apr-util-1.6.0.tar.bz2
cd apr-1.6.2
./configure --prefix=/usr \
--disable-static \
--with-installbuilddir=/usr/share/apr-1/build &&
make
make install
安装openssl-1.1.0f需要perl5
yum install expat-devel
cd apr-util-1.6.0
./configure --prefix=/usr \
--with-apr=/usr \
--with-gdbm=/usr &&
make
make install
yum -y install httpd
/sbin/chkconfig httpd on
Note: Forwarding request to 'systemctl enable httpd.service'.
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
/sbin/service httpd start
Redirecting to /bin/systemctl start httpd.service
Permission denied: httpd: could not open error log file /home/wwwroot/jb51.net/logs/error_log.
Unable to open logs
setenforce 0 ##设置SELinux 成为permissive模式
##setenforce 1 设置SELinux 成为enforcing模式
修改配置文件需要重启机器:
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled
httpd启动以后,访问不了网站
关闭防火墙:
关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
centos7安装php7,亲测可行
在centos7通过yum安装PHP7,首先在终端运行:
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
提示错误:
error: Failed dependencies:
epel-release >= 7 is needed by webtatic-release-7-3.noarch
需要先安装epel-release。
1.安装epel-release
通过命令:
yum -y install epel-release
成功安装。
2.安装PHP7
终端再次运行如下命令:
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
成功获取PHP7的yum源,然后再执行:
yum install -y php70w-mysql
这样就大功告成了。
3.验证安装
终端命令:PHP -v,显示当前PHP版本,信息如下:
[root@moliangjun /]# php -v
PHP 7.0.18 (cli) (built: Apr 15 2017 07:09:11) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
这样就在CentOS 7下通过yum安装成功PHP7.
service httpd restart
yum install php-mbstring
开启显示php错误
vi /etc/php.ini
将
display_errors = off
改为
display_errors = on
yum -y install cmake bison-devel ncurses-devel libaio libaio-devel perl-Data-Dumper net-tools
tar xvzf which-2.21.tar.gz
cd wh*
yum -y install wget
查看刚安装mysql数据库版本信息。
rpm -qa | grep mysql
yum remove mysql mysql-server
yum remove mysql-devel
1、安装MariaDB
安装命令
yum -y install mariadb mariadb-server
安装完成MariaDB,首先启动MariaDB
systemctl start mariadb
设置开机启动
systemctl enable mariadb
接下来进行MariaDB的相关简单配置
mysql_secure_installation
首先是设置密码,会提示先输入密码
Enter current password for root (enter for none):<–初次运行直接回车
设置密码
Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码
其他配置
Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车
Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车,
Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车
初始化MariaDB完成,接下来测试登录
mysql -uroot -ppassword
完成。
2、配置MariaDB的字符集
文件/etc/my.cnf
vi /etc/my.cnf
在[mysqld]标签下添加
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
文件/etc/my.cnf.d/client.cnf
vi /etc/my.cnf.d/client.cnf
在[client]中添加
default-character-set=utf8
文件/etc/my.cnf.d/mysql-clients.cnf
vi /etc/my.cnf.d/mysql-clients.cnf
在[mysql]中添加
default-character-set=utf8
全部配置完成,重启mariadb
systemctl restart mariadb
之后进入MariaDB查看字符集
mysql> show variables like "%character%";show variables like "%collation%";
显示为
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_unicode_ci |
| collation_database | utf8_unicode_ci |
| collation_server | utf8_unicode_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)
字符集配置完成。
3、添加用户,设置权限
创建用户命令
mysql>create user username@localhost identified by 'password';
直接创建用户并授权的命令
mysql>grant all on *.* to username@localhost indentified by 'password';
授予外网登陆权限
mysql>grant all privileges on *.* to username@'%' identified by 'password';
授予权限并且可以授权
mysql>grant all privileges on *.* to username@'hostname' identified by 'password' with grant option;
简单的用户和权限配置基本就这样了。
其中只授予部分权限把 其中 all privileges或者all改为select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file其中一部分。
增加gd库
yum -y install libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel
yum install gd
yum install -y php70w-mysql php70w-gd
httpd service restart
星期三, 08/02/2017 - 11:09 — 杨超