Install PHP 7, Apache, MySQL 5.6 on CentOS / RHEL 7.1 & 6.7 + Wordpress

来源:互联网 发布:java开发实例1200 pdf 编辑:程序博客网 时间:2024/05/22 22:47

最近做了个小项目,挣了几百块钱,于是买了个域名:shawshining.com 和一个搬瓦工的服务器。搬瓦工自带CentOS6,支持一键安装ss,比较方便。买的搬瓦工的服务器只有500MB内存,导致出现一些以前在类似阿里云的学生机1g内存上根本不会出现的问题。所以有必要告诉后来人怎么填坑。事不宜迟,写个教程让大家少走点弯路。如果有问题,清查看最下面的问题解决方法。如果问题依然没有解决可以google,百度一下!

主要参考:https://tecadmin.net/install-php-7-apache-2-4-mysql-on-centos-rhel/#

 正式开始!

yum upgrade

 

CentOS / RHEL 7

# yum install epel-release# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm# rpm -Uvh http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

CentOS / RHEL 6

# yum install epel-release# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm# rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm# rpm -Uvh http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm

 

Install PHP7

# yum install php70w# yum search php70w# yum install php70w-mysql php70w-xml php70w-soap php70w-xmlrpc# yum install php70w-mbstring php70w-json php70w-gd php70w-mcrypt

CentOS/ RHEL 7

# systemctl restart httpd.service

CentOS/ RHEL 6

# service httpd restart

 

Install Apache 2.4

 

# yum --enablerepo=epel,remi install httpd

CentOS/ RHEL 7

# systemctl start httpd.serve# systemctl enable httpd.service

CentOS/ RHEL 6

# service httpd restart# chkconfig --level 3 httpd on

 

Install MySQL 5.6

 

# yum install mysql-server

CentOS/ RHEL 7

# systemctl start mysqld.service

CentOS/ RHEL 6

# service mysqld start

 

# mysql_secure_installation

CentOS/ RHEL 7

# systemctl restart mysqld.service# systemctl enable mysqld.service

CentOS/ RHEL 6

# service mysqd restart# chkconfig --level 3 mysqld on

 

Open Port in Firewall

CentOS/ RHEL 7

# firewall-cmd --permanent --zone=public --add-service=http# firewall-cmd --permanent --zone=public --add-service=https# firewall-cmd --reload

CentOS/ RHEL 6

# iptables -t filter -A INPUT -p tcp --dport 80 -j ACCEPT# iptables -t filter -A INPUT -p tcp --dport 443 -j ACCEPT# service iptables restart 

 //如果你希望能够远程连接你的数据库的话,就开启3306端口。

mysql>GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";mysql>flush privileges;

 

Wordpress安装

安装之前,先创建一个数据库,创建一个用户,并设定其密码。WordPress的安装需要用到这个数据库,并且需要你输入用户名和密码。

参考

https://cn.wordpress.org/

把文件下载好解压上传到/var/www/html目录

直接打开你的服务器ip地址,就能打开安装向导,一步步进行即可。

如果提示无法生成wp-config.php文件,可以复制它自动生成好的代码,使用ftp连接,自己上传该文件。

如果你遇到忽然页面变成了白色的话,那么恭喜你!你中招了,请查看问题解决方法。

 

问题解决方法:

我遇到的问题的根本原因全部都是因为内存只有512MB完全不够用。问题表征主要有:

1.各种服务无法启动。

2.WordPress安装时页面空白。

具体解决方法:

php:

/etc

php.ini

memory_limit = 256M

Mysql:

/etc

my.cnf

[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.socksymbolic-links=0sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLESexplicit_defaults_for_timestamp = TRUEkey_buffer=16Ktable_open_cache=4query_cache_limit=256Kquery_cache_size=4Mmax_allowed_packet=1Msort_buffer_size=64Kread_buffer_size=256Kthread_stack=64Kinnodb_buffer_pool_size = 56Minnodb_flush_neighbors=0innodb_flush_log_at_trx_commit=2character-set-server=utf8collation-server=utf8_general_ci

 

阅读全文
0 0
原创粉丝点击