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

最近做了个小项目,挣了几百块钱,于是买了个域名: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/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
explicit_defaults_for_timestamp = TRUE
key_buffer=16K
table_open_cache=4
query_cache_limit=256K
query_cache_size=4M
max_allowed_packet=1M
sort_buffer_size=64K
read_buffer_size=256K
thread_stack=64K
innodb_buffer_pool_size = 56M
innodb_flush_neighbors=0
innodb_flush_log_at_trx_commit=2
character-set-server=utf8
collation-server=utf8_general_ci
时间: 2024-08-11 03:24:28

Install PHP 7, Apache, MySQL 5.6 on CentOS / RHEL 7.1 & 6.7 + Wordpress的相关文章

How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu

About LAMP LAMP stack is a group of open source software used to get web servers up and running. The acronym stands for Linux, Apache, MySQL, and PHP. Since the virtual private server is already running Ubuntu, the linux part is taken care of. Here i

aliyun install php apache mysql nginx

yum install httpd -y yum install mysql mysql-server -y yum install php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml php-pecl-apc php-cli php-pear php-pdo -y --skip-broken yum in

apache/mysql/php编译安装及支持xcache和fastcgi方式运行

一.编译安装apache     1.安装环境:yum install gcc gcc-c++ openssl-devel libtool -y     2.安装apr.apr-util及pcre         tar jxf apr-1.5.1.tar.bz2         cd apr-1.5.1         ./configure --prefix=/usr/local/apr         make && make install              tar jxf

How to Install Apache Solr 4.5 on CentOS 6.4

By Shay Anderson on October 2013 Knowledge Base  /  Linux  /  How to Install Apache Solr 4.5 on CentOS 6.4 In this tutorial I explain how to install Apache Solr 4.5 on CentOS 6.4. In all the examples below I am using the root user, if you are not you

Ubuntu下(Linux+Apache+MYSQL+PHP, LAMP)环境搭建

最近开始玩PHP,于是试着搭建一下开发环境并做个记录,以备日后再使用起来方便可查. 第一步 确保软件包是最新的 <span style="font-size: 18px;">sudo apt-get update</span> 第二步 安装Apache2 <span style="font-size: 18px;">sudo apt-get install apache2</span> 安装之后测试:在浏览器中打开 h

Centos 7.0 编译安装LAMP(Linxu+apache+mysql+php)之源码安装Mysql (二)

mysql 简介: MySQL是一个关系型数据库管理系统,关系数据库将数据保存在不同的表中,这样就增加了速度并提高了灵活性.目前其属于 Oracle 旗下产品.MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MySQL是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件.MySQL所使用的 SQL 语言是用于访问数据库的最常用标准化语言. 安装环境: 系统: centos 7.0 最小化安装 软件

Lamp(linux+apache+mysql+php)环境搭建

Lamp(linux+apache+mysql+php)环境搭建 1.安装apache2:sudo apt-get installapache2 安装完毕后.执行例如以下命令重新启动apache:sudo/etc/init.d/apache2 restart,在浏览器中输入http://localhost或者http://127.0.0.1,会看到"It works!"说明apache成功安装. 2.安装php:sudoapt-get install libapache2-mod-ph

linux apache + mysql +php no-yum

学习PHP脚本编程语言之前,必须先搭建并熟悉开发环境,开发环境有很多种,例如LAMP.WAMP.MAMP等.这里我介绍一下LAMP环境的搭建,即Linux.Apache.MySQL.PHP环境. 一.首先安装操作系统 操作系统:centos6.3 IP地址:192.168.146.129 网关: DNS: 操作系统安装步骤,此处不在给出截图. 备注:服务器系统采用最小化安装,安装一下GCC编译工具和一个桌面即可.如下图所示: <a href="http://www.php100.com/u

CentOS环境下yum安装LAMP(Linux+Apache+Mysql+php)

CentOS下使用yum命令 安装LAMP详细过程.我们使用的软件是CentOS的最新版本CentOS 6.3,其他版本的也基本类似. 第一步:更新系统内核(如果不想更新可以跳过本步). 首先更新系统内核到最新,因为最新版的CentOS 6.3的php版本为 5.3,早起版本的CentOS的php版本也比较低. 执行命令: yum -y update 注意:如果执行失败报错,可以执行修复命令: rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY* 第二步: 安装Ap