centos安装nginx php mysql redis mongodb 并配置kohana环境
以下是在CentOS系统上安装Nginx、PHP、MySQL、Redis、MongoDB以及配置Kohana环境的步骤:
- 安装Nginx:
sudo yum install epel-release -y
sudo yum install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
- 安装MySQL:
sudo yum install mariadb-server mariadb -y
sudo systemctl start mariadb
sudo systemctl enable mariadb
mysql_secure_installation
- 安装PHP及扩展(确保已安装所需PHP扩展,如mysqli, pdo\_mysql, mbstring, json, curl等):
sudo yum install epel-release -y
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
sudo yum-config-manager --enable remi-php74
sudo yum install php php-cli php-fpm php-mysqlnd php-pdo php-pear php-mbstring php-json php-redis php-mongodb php-xml php-pecl-redis php-pecl-mongo
- 安装Redis:
sudo yum install epel-release -y
sudo yum install redis -y
sudo systemctl start redis
sudo systemctl enable redis
- 安装MongoDB:
sudo tee /etc/yum.repos.d/mongodb-org-4.4.repo <<EOF
[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/\$releasever/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
EOF
sudo yum install mongodb-org -y
sudo systemctl start mongod
sudo systemctl enable mongod
- 配置Nginx与PHP处理:
# 创建Nginx配置文件
sudo tee /etc/nginx/conf.d/kohana.conf <<EOF
server {
listen 80;
server_name example.com;
root /var/www/kohana;
index index.php index.html index.htm;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location / {
try_files \$uri \$uri/ /index.php?\$args;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
}
EOF
# 重启Nginx
sudo systemctl restart nginx
- 配置Kohana框架(确保已安装Kohana框架):
# 创建Kohana项目目录
sudo mkdir -p /var/www/kohana
# 设置正确的权限
sudo chown -R nginx:nginx /var/www
# 下载Kohana项目(仅作为示例,需要替换为实际项目URL)
sudo wget http://example.com/kohana-project.tar.gz -O /var/www/kohana/kohana-project.tar.gz
sudo tar -zxvf /var/www/kohana/kohana-project.tar.gz -C /var/www/kohana --
评论已关闭