搭建一个小程序开发环境
后端采用 centos7.5 + php7 + memcached + mysql5.7
前端采用 wepy + iview-weapp
PHP7 安装
安装yum源 centos 7
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
或
yum install epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
安装php7.0
sudo yum -y install php70w php70w-cli php70w-common php70-devel php70w-mysql php70w-memcached php70w-fpm php70w-pdo
启动php
systemctl start php-fpm // 启动php
systemctl reload php-fpm 重新加载配置
memcached
安装
yum install memcached
yum install php-memcached // 安装php扩展
启动
memcached -d -l 127.0.0.1 -p 11211 -m 150 -u root
mysql
安装
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
yum localinstall mysql57-community-release-el7-8.noarch.rpm
yum install mysql-community-server
启动
systemctl start mysqld
修改root本地的默认登陆密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql
grep 'temporary password' /var/log/mysqld.log
nginx
安装
yum install nginx
配置nginx php loader
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include /etc/nginx/fastcgi_params;
}
mongodb
安装
创建/etc/yum.repos.d/mongodb-org-4.0.repo文件,编辑内容如下:
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
安装命令
yum install -y mongodb-org
启动
sudo service mongod start