亲测装服流程可用,如果中间遇到错误信息可重新来跑一遍流程

如果需要高性能的MySQL配置请看下一篇文章

1安装php服务器

清除掉历史版本


yum -y remove php*

配置php7.2源

\# 安装EPEL yum存储库

yum install epel-release -y

\# 安装Remi存储库

rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

\# 安装 PHP 7.2

yum install --enablerepo=remi-php72 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof calendar curl dom ftp gd gettext mcrypt mysql json msgpack zip php72-php-pecl-apcu php-fpm php72-php-pecl-apcu-devel php-memcached httpd

vim /etc/php-fpm.d/www.conf #根据服务器配置自我调整

pm.min\_spare\_servers = 50

pm.max\_spare\_servers = 100

pm.max\_requests = 5000

pm.max\_children = 2000

pm.start\_servers = 50

rlimit\_files = 30240

vim /etc/php-fpm.conf#根据服务器配置自我调整

rlimit\_files = 30240

vim /etc/php.ini 时区配置

date.timezone = Europe/London

内存配置 // 根据服务器内存大小来变动 1/2

memory\_limit = 2048M

post最大值配置

post\_max\_size = 30M

\#启动php

service php-fpm start

安装mysql5.7(若使用云数据库可省略此步骤)

下载yum仓库文件

wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

2. 安装yum pepo文件

yum localinstall mysql80-community-release-el7-1.noarch.rpm

3. 选择具体版本

// 查看 YUM 仓库关于 MySQL 的所有仓库列表

\# yum repolist all | grep mysql

// 只查看启用的

\# yum repolist enabled | grep mysql

4. 关闭80,开启57

// 安装 YUM 管理工具包,此包提供了 yum-config-manager 命令工具

\# yum install yum-utils

// 禁用 8.0

\# yum-config-manager --disable mysql80-community

// 启用 5.7

\# yum-config-manager --enable mysql57-community

5. 再次确认启动MySQL

yum repolist enabled | grep mysql

6. 开始安装MySQL

yum install -y mysql-community-server

7. 管理MySQL服务

// 启动

\# systemctl start mysqld.service

// 查看状态

\# systemctl status mysqld.service

// 开机自启动

\# systemctl enable mysqld

// 查看监听端口,默认 3306

\# ss -natl |grep 3306

8. 初始化MySQL

grep 'temporary password' /var/log/mysqld.log

9. 默认的密码是随机生成的,需要重新设置密码

1).// 停止 mysql 服务

systemctl stop mysqld

2).// 启动免授权服务端

vim /etc/my.cnf

skip-grant-tables=1

3).重启mysql

systemctl restart mysqld

\# 在服务端本地执行 mysql, 通过本地连接数据库,回车进入mysql

mysql -u root -p

\# 修改用户的密码

update mysql.user set authentication\_string=PASSWORD('pMr80yb6r68sHXBIA') where user='root' and host='localhost'; (pMr80yb6r68sHXBIA 为密码 随意设置 记得保存记录下来)

// 再次重启服务

systemctl restart mysqld

10. 查看密码表中的内容,在 MySQL 会话终端中输入如下命令

mysql> select * from mysql.user\G

关闭事务自动提交

vim /etc/my.cnf

init\_connect='SET autocommit=0' //在mysqld里面加上这些内容

重启mysql

systemctl restart mysqld

创建用户

mysql -u root -p

grant all privileges on *.* to 'gm97'@'%' identified by 'Mr80yb6r68sHXBIA' with grant option;(如果报错 先执行 flush privileges; 再执行此命令)

导入数据库脚本 (如有脚本可导入,没有直接忽略)

mysql -ugm97 -pMr80yb6r68sHXBIA -h127.0.0.1 -P3306 suc\_sheep\_share<suc\_sheep\_share.sql

mysql -ugm97 -pMr80yb6r68sHXBIA -h127.0.0.1 -P3306 app\_version<app\_version.sql

mysql -ugm97 -pMr80yb6r68sHXBIA -h127.0.0.1 -P3306 suc\_sheep\_admin<suc\_sheep\_admin.sql

mysql -ugm97 -pMr80yb6r68sHXBIA -h127.0.0.1 -P3306 suc\_sheep\_raid<suc\_sheep\_raid.sql

2配置httpd服务器

vim /etc/httpd/conf/httpd.conf

1添加监听端口

Listen 81 GMT(默认存在)

Listen 5082 游戏服(需要添加的)

2 修改默认 ServerName

ServerName localhost:80

3 5082 游戏服 81 GMT

DocumentRoot /data/app/web/api-public

ServerName localhost:5082

SetOutputFilter DEFLATE

Options FollowSymLinks

AllowOverride All

Require all granted

AcceptPathInfo On

DirectoryIndex index.php index.html index.htm default.php default.html default.htm

DocumentRoot /var/www

ServerName localhost:81

SetOutputFilter DEFLATE

Options FollowSymLinks

AllowOverride All

Require all granted

AcceptPathInfo On

DirectoryIndex index.php index.html index.htm default.php default.html default.htm

4添加解析PHP(默认存在)

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

5优化服务器httpd 配置httpd.conf末尾追加 根据服务器配置适当调整

StartServers 50

MinSpareServers 50

MaxSpareServers 120

MaxClients 5000

ServerLimit 5000

MaxRequestsPerChild 10000

启动httpd

service httpd start

\## 安装memcached

yum install memcached

启动memcached

/usr/bin/memcached -p 11211 -m 1024M -u root -d -c 4096 -d

根目录添加logs目录 /logs 项目中有日志写入也可移动至项目目录

——————————————————

服务器到这里已经搭建完成 接下来就要放代码了

放到文件夹这个位置:/var/www

可以以压缩文件去上传代码

安装压缩软件

yum install lrzsz

解压文件

unzip app.zip -d /data/app/web/

修改文件的权限否则文件不能被访问

chmod -R 777 data

接下来重启httpd

service httpd restart

\_\_\_\_\_\_\_\_\_\_\_\_\_\_

到这里就是整个安装流程,下面的可以参考下

如果安装有memcache每次更新数据库要清空缓存

ps -ef|grep mem 查看进程id

杀死进程

kill-9 进程id

后重启缓存

/usr/bin/memcached -p 11211 -m 1024M -u root -d -c 4096 -d

标签: Linux, 服务器, yum, php, httpd, mysql, mysqld, Lamp

相关文章推荐

添加新评论,含*的栏目为必填