ubuntu 환경에 nginx, php, mysql 설치하기
# apt 업데이트
sudo apt update
# php 설치
sudo apt install -y software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt install -y php8.1-common php8.1-fpm php8.1-cli php8.1-gd php8.1-mysql php8.1-curl php8.1-intl php8.1-mbstring php8.1-bcmath php8.1-imap php8.1-xml php8.1-zip
# php composer 설치
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
rm composer-setup.php
mv composer.phar /usr/bin/composer
# nginx 설치
sudo apt install -y nginx
# nginx 설정
sudo vim /etc/nginx/sites-available/default
sudo service nginx reload
# mysql 설치
sudo apt install -y mysql-server
# mysql 설정
sudo mysql -u root -p
server {
listen 80;
root /var/www/test/public;
index index.php;
server_name _;
charset utf-8;
location = /favicon.ico {
access_log off;
log_not_found off;
}
location = /robots.txt {
access_log off;
log_not_found off;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ /\. {
deny all;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
}
}
CREATE DATABASE test;
SHOW DATABASES;
use test;
CREATE USER 'test'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';
GRANT ALL PRIVILEGES ON test.* TO 'test'@'localhost';
FLUSH PRIVILEGES;