설치하기 전에 저장소의 패키지 목록을 업데이트 하고 기존에 설치되어 있는 패키지를 업그레이드 합니다.
$ sudo apt update && sudo apt upgrade
1. Apache2 설치
Apache2 설치
$ sudo apt-get install apache2
설치된 Apache2 버전 확인
& apache2 -v
Apache2 구동
$ sudo service apache2 restart // 재시작
$ sudo service apache2 start // 시작
$ sudo service apache2 stop // 멈춤
$ sudo service apache2 start 명령어를 실행한 후
웹 브라우저를 통해 localhost 를 주소에 입력할 시 아래의 화면이 보이면 정상적으로 설치된 것입니다.
2. Mysql 설치
Mysql 서버 설치
$ sudo apt install mysql-server
MySql 기본 설정
$ sudo mysql_secure_installation
// 명령어 실행 후 차례로 나오는 입력값 입력하시면 됩니다.
Press y|Y for Yes, any other key for No: y
//비밀번호 입력방식을 설정합니다.
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
//패스워드를 입력합니다.
New password:
//설정한 비밀번호를 사용할 것인지 여부
Do you wish to continue with the password provided?
(Press y|Y for Yes, any other key for No) : y
//데이터베이스 접근 제한
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
//원격 접속 불가
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 와 같은 에러가 발생할 시
& sudo service mysql restart
위의 명령어 실행후 다시 실행해 줍니다.
3. PHP 설치
PHP 설치
$ sudo apt install php php-mysql
PHP 설치 확인
$ sudo nano /var/www/html/info.php
위의 명령어를 실행한 후
아래 내용을 입력한 후 Ctrl + O를 누른 후 엔터를 눌러 저장하고 Ctrl + X를 눌러 종료합니다.