yum install httpd
systemctl start httpd.service #启动apache
systemctl stop httpd.service #停止apache
systemctl restart httpd.service #重启apache
systemctl enable httpd.service #设置apache开机启动
安装完成后重启服务
systemctl restart httpd.service
查看进程
netstat -tulp
1.安装Apache
yum -y install httpd httpd-manual mod_ssl mod_perl mod_auth_mysql
设置开机启动apache
systemctl enable httpd.service
启动apache
systemctl start httpd.service
Apache 安装成功,虚拟主机等配置下面再说。
2.安装Mysql
安装之前先删除以前版本,以免安装不成功。
查看mysql的rpm包
rpm -qa | gerp mysql
查到之后就删除
yum remove 文件名(可以一次多个名字,以空格分隔)
例如:
yum remove -y mysql mysql mysql-server mysql-libs compat-mysql51
查看多余文件没删干净
find / -name mysql
删除多余文件
rm -rf 文件名
例如:
rm -rf /etc/my.cnf
开始安装
rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
yum install -y mysql-server
设置开机启动Mysql
systemctl enable mysqld.service
开启服务
systemctl start mysqld.service
查看Mysql5.7默认密码
grep 'temporary password' /var/log/mysqld.log
登陆Mysql,输入用户名root,复制粘贴密码
mysql -uroot -p
修改密码(mysql5.7的密码设置规则:大写字母、小写字母、数字、特殊字符加起来)
SET PASSWORD = PASSWORD('Abc123!');
查看数据库
show databases;
Mysql配置安装成功。
mysql -u root -p #登录mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
提示:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements。这里就是说我的mysql密码强度太低,不允许我这样的操作。
解决:
mysql -u root -p #登录mysql>set global validate_password_policy=0; #密码强度设为最低等级mysql>set global validate_password_length=4; #密码允许最小长度为4mysql>flush privileges; #更新授权表,生效
[root@nmserver-7 ~]# mysql_secure_installation
接着y y n y y
更改密码:
update mysql.user set authentication_string=password('Abc629') where user='root' and Host = 'localhost';
安装PHP7.2
系统更新yum源,我的是centos7,所以我运行下面的代码!
CentOS/RHEL 7.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
然后就可以直接yum安装php7.0了,可以安装的拓展如下:
yum install php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel
就这一条命令,就可以安装了下面的拓展了!
php-api, php-bz2, php-calendar, php-ctype, php-curl, php-date, php-exif, php-fileinfo, php-filter, php-ftp, php-gettext, php-gmp, php-hash, php-iconv, php-json, php-libxml, php-openssl, php-pcre, php-pecl-Fileinfo, php-pecl-phar, php-pecl-zip, php-reflection, php-session, php-shmop, php-simplexml, php-sockets, php-spl, php-tokenizer, php-zend-abi, php-zip, php-zlib
查看一下php版本:
php -v
看一下php拓展:
php -m
使用国内yum源:http://blog.csdn.net/zhezhebie/article/details/73484695
安装redis和memcached,直接yum安装即可:
yum install -y memcached redis
memcached说明: http://blog.csdn.net/zhezhebie/article/details/73471519
redis说明: http://blog.csdn.net/zhezhebie/article/details/73470134
关于php和apache的配置
http.conf
* 配置AddType
* AddType application/x-httpd-php .php
* AddType application/x-httpd-php .txt
DirectoryIndex index.php index.htm index.html
ServerName localhost:80
LoadModule php7_module modules/libphp7.so
一般来说PHP安装完后会在apache中生成php7_module这个模块
如果没有这个模块就不能编译php