Apache, php, MySQL 설치
1.sudo dnf update -y
2. sudo dnf install -y httpd wget php-fpm php-mysqli php-json php php-devel mariadb105-server
3. sudo systemctl start httpd
4. sudo systemctl enable httpd
Apache2 httpd server file의 기본 경로는 /var/www/html으로 기본 값이 설정되어있다. 그리고 해당 경로를 조작하기 위해서는 ec2-user 계정에 권한을 부여해줘야 한다. 왜냐하면 해당 경로는 소유자 root 그룹 root로 구성이 되어있기 때문이다.
ec2-user 권한 부여
1.sudo usermod -a -G apache ec2-user
2. sudo chown -R ec2-user:apache /var/www
3. sudo chmod 2775 /var/www && find /var/www -type d -exec sudo chmod 2775 {} \ ;
4. find /var/www -type f -exec sudo chmod 0664 {} \ ;
소유하고 있는 사용자와 그룹을 변경한 것을 확인할 수 있다.
php & apache2 테스트
1.echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php
2. http://EC2IP/phpinfo.php 접속하면 phpinfo 정보가 담긴 사이트가 출력된다.
MariaDB 실행
1.sudo systemctl start mariadb
2.sudo mysql_secure_installation
root 계정에 대한 비밀번호가 설정이 되어있지 않다면 Enter를 누르면 된다.
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
- Y
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y
- Y
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment
Remove test database and access to it? [Y/n] y
- Y
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
- Y
3.sudo systemctl enable mariadb
4.sudo mysql -u root -p
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Tutorials.WebServerDB.CreateWebServer.html
https://docs.aws.amazon.com/linux/al2023/ug/ec2-lamp-amazon-linux-2023.html
'Linux' 카테고리의 다른 글
Sudo redirection does not work (0) | 2024.06.09 |
---|---|
Vim settings (0) | 2024.06.09 |
SSH 비밀번호로 접속하기 (0) | 2024.06.08 |
AWS EC2 Node, express 및 pm2 설치 (1) | 2024.06.08 |
[AWS] AL 2023 EBS 추가하기 (0) | 2024.06.08 |