styxmx 发表于 2017-12-25 14:00:36

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@"%">
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
  

  
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  
页: [1]
查看完整版本: Install PHP 7, Apache, MySQL 5.6 on CentOS / RHEL 7.1 & 6.7 + Wordpress