1.关闭selinux,防火墙
setenforce 0 //临时关闭
设置开机不启动
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled SELINUX=enforcing
sed -i 's/'SELINUX=enforcing'/'SELINUX=disabled'/' /etc/selinux/config
关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
2.下载mysql源
mkdir software
cd software
wget http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
yum -y install mysql mysql-server mysql-devel
service mysqld start
查看初始密码(注:关于set global validate_password_policy=0; set global validate_password_length=1;参数参见附录mysql密码策略.docx)
grep 'password' /var/log/mysqld.log |head -n 1
passwordmysql=`grep 'password' /var/log/mysqld.log |head -n 1|awk {'print $11'}`
mysql -uroot -p$passwordmysql --database mysql -e "set global validate_password_policy=0; set global validate_password_length=1; SET PASSWORD = PASSWORD('123456');" --connect-expired-password
mysql -uroot -p123456 -e "grant all privileges on *.* to 'mydb'@'%' identified by '123456';"
mysql -umydb -p123456 -e "CREATE DATABASE mydb DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;"
导入数据库
mysql -umydb -p123456 --database mydb < mydb.sql
------------------------------------------------------关于mysql初始密码----------------------------------------------
如果不知道mysql的初始密码可通过如下方式修改初始密码
在/etc/my.cnf配置文件的[mysqld]段加入
skip-grant-tables=1
重启mysql
service mysqld restart
通过如下命令设置初始密码
mysql --database mysql -e "UPDATE user SET authentication_string=PASSWORD("123456") WHERE user='root';"
配置密码后第一次登录仍然需要修改初始密码才能进行操作
mysql -uroot -p123456 --database mysql -e "set global validate_password_policy=0; set global validate_password_length=1; SET PASSWORD = PASSWORD('123456');" --connect-expired-password
----------------------------------------------------------------------------------------------------------------------------
3.安装php
yum -y install php
yum -y install php-mysql
yum -y install gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap
4.安装httpd
yum -y install httpd
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
将项目放在/var/www/html/
修改项目权限
chown -R apache:apache myitem
vim /etc/httpd/conf/httpd.conf
在末尾加上如下段落
DocumentRoot "/var/www/html/myitem"
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
可用如下命令直接插入
sed -i '$a
\n ServerAdmin [email protected]\n DocumentRoot "/var/www/html/myitem"\n \n Options Indexes FollowSymLinks\n AllowOverride All\n Require all granted\n \n' /etc/httpd/conf/httpd.conf
重启apache
servcie httpd restart