모든 설정은
개인서버기준이므로..
sudo passwd root
위 명령어로 루트로 로그인하도록한다
패스워드 설정해주면된다
앞으로
sudo 슈퍼유저두~ 는 빼도록한다
귀찮으면 그냥 붉은글씨만 복사해서 실행해주면된다
아파치 서버의 패키지 정보를 확인
root@linux:/#
apt info apache2
root@linux:/#
apt list --installed apache2
설치
root@linux:/#
apt install apache2 -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
apache2-bin apache2-data apache2-utils libapr1 libaprutil1
libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1
libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0
0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,819 kB of archives.
After this operation, 7,945 kB of additional disk space will be used.
Do you want to continue? [Y/n] N
Abort.
root@linux:/# apt install apache2 -Y
E: Command line option 'Y' [from -Y] is not understood in combination with the other options.
root@linux:/# apt install apache2 -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
apache2-bin apache2-data apache2-utils libapr1 libaprutil1
libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1
libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0
0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,819 kB of archives.
After this operation, 7,945 kB of additional disk space will be used.
Get:1 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libapr1 amd64 1.6.5-1ubuntu1 [91.4 kB]
Get:2 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libaprutil1 amd64 1.6.1-4ubuntu2 [84.7 kB]
Get:3 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libaprutil1-dbd-sqlite3 amd64 1.6.1-4ubuntu2 [10.5 kB]
Get:4 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libaprutil1-ldap amd64 1.6.1-4ubuntu2 [8,736 B]
Get:5 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 liblua5.2-0 amd64 5.2.4-1.1build3 [106 kB]
Get:6 http://kr.archive.ubuntu.com/ubuntu focal-updates/main amd64 apache2-bin amd64 2.4.41-4ubuntu3.9 [1,180 kB]
Get:7 http://kr.archive.ubuntu.com/ubuntu focal-updates/main amd64 apache2-data all 2.4.41-4ubuntu3.9 [159 kB]
Get:8 http://kr.archive.ubuntu.com/ubuntu focal-updates/main amd64 apache2-utils amd64 2.4.41-4ubuntu3.9 [84.3 kB]
Get:9 http://kr.archive.ubuntu.com/ubuntu focal-updates/main amd64 apache2 amd64 2.4.41-4ubuntu3.9 [95.5 kB]
Fetched 1,819 kB in 3s (606 kB/s)
Selecting previously unselected package libapr1:amd64.
(Reading database ... 184171 files and directories currently installed.)
Preparing to unpack .../0-libapr1_1.6.5-1ubuntu1_amd64.deb ...
Unpacking libapr1:amd64 (1.6.5-1ubuntu1) ...
Selecting previously unselected package libaprutil1:amd64.
Preparing to unpack .../1-libaprutil1_1.6.1-4ubuntu2_amd64.deb ...
Unpacking libaprutil1:amd64 (1.6.1-4ubuntu2) ...
Selecting previously unselected package libaprutil1-dbd-sqlite3:amd64.
Preparing to unpack .../2-libaprutil1-dbd-sqlite3_1.6.1-4ubuntu2_amd64.deb ...
Unpacking libaprutil1-dbd-sqlite3:amd64 (1.6.1-4ubuntu2) ...
Selecting previously unselected package libaprutil1-ldap:amd64.
Preparing to unpack .../3-libaprutil1-ldap_1.6.1-4ubuntu2_amd64.deb ...
Unpacking libaprutil1-ldap:amd64 (1.6.1-4ubuntu2) ...
Selecting previously unselected package liblua5.2-0:amd64.
Preparing to unpack .../4-liblua5.2-0_5.2.4-1.1build3_amd64.deb ...
Unpacking liblua5.2-0:amd64 (5.2.4-1.1build3) ...
Selecting previously unselected package apache2-bin.
Preparing to unpack .../5-apache2-bin_2.4.41-4ubuntu3.9_amd64.deb ...
Unpacking apache2-bin (2.4.41-4ubuntu3.9) ...
Selecting previously unselected package apache2-data.
Preparing to unpack .../6-apache2-data_2.4.41-4ubuntu3.9_all.deb ...
Unpacking apache2-data (2.4.41-4ubuntu3.9) ...
Selecting previously unselected package apache2-utils.
Preparing to unpack .../7-apache2-utils_2.4.41-4ubuntu3.9_amd64.deb ...
Unpacking apache2-utils (2.4.41-4ubuntu3.9) ...
Selecting previously unselected package apache2.
Preparing to unpack .../8-apache2_2.4.41-4ubuntu3.9_amd64.deb ...
Unpacking apache2 (2.4.41-4ubuntu3.9) ...
Setting up libapr1:amd64 (1.6.5-1ubuntu1) ...
Setting up liblua5.2-0:amd64 (5.2.4-1.1build3) ...
Setting up apache2-data (2.4.41-4ubuntu3.9) ...
Setting up libaprutil1:amd64 (1.6.1-4ubuntu2) ...
Setting up libaprutil1-ldap:amd64 (1.6.1-4ubuntu2) ...
Setting up libaprutil1-dbd-sqlite3:amd64 (1.6.1-4ubuntu2) ...
Setting up apache2-utils (2.4.41-4ubuntu3.9) ...
Setting up apache2-bin (2.4.41-4ubuntu3.9) ...
Setting up apache2 (2.4.41-4ubuntu3.9) ...
Enabling module mpm_event.
Enabling module authz_core.
Enabling module authz_host.
Enabling module authn_core.
Enabling module auth_basic.
Enabling module access_compat.
Enabling module authn_file.
Enabling module authz_user.
Enabling module alias.
Enabling module dir.
Enabling module autoindex.
Enabling module env.
Enabling module mime.
Enabling module negotiation.
Enabling module setenvif.
Enabling module filter.
Enabling module deflate.
Enabling module status.
Enabling module reqtimeout.
Enabling conf charset.
Enabling conf localized-error-pages.
Enabling conf other-vhosts-access-log.
Enabling conf security.
Enabling conf serve-cgi-bin.
Enabling site 000-default.
Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /lib/systemd/system/apache2.service.
Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service → /lib/systemd/system/apache-htcacheclean.service.
Processing triggers for ufw (0.36-6ubuntu1) ...
Processing triggers for systemd (245.4-4ubuntu3.15) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
현재 구동 유무 확인
root@linux:/#
systemctl is-active apache2
시스템 부팅 시 자동으로 구동이 될 수 있도록 설정되어 있는지 확인
root@linux:/#
systemctl is-enabled apache2.service
시스템 부팅 시 자동 구동으로 활성화되도록 설정
root@linux:/#
systemctl enabled apache2.service
아파치 상태 확인
root@linux:/#
systemctl status apache2
아래는 그냥 따라해준다 혹은 이런기능이구나 하고 한번씩해보면좋다.
root@linux:/#
systemctl stop apache2.service
root@linux:/#
systemctl start apache2.service
root@linux:/#
systemctl restart apache2.service
root@linux:/#
systemctl reload apache2.service
root@linux:/#
apache2 -v
이제 DB를 설치해보자 mysql 8대신에...MariaDB를 설치해줄 심산이다.
root@linux:/#
apt install mariadb-server -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
galera-3 gawk libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl
libdbd-mysql-perl libdbi-perl libfcgi-perl libhtml-template-perl libsigsegv2
libsnappy1v5 libterm-readkey-perl mariadb-client-10.3 mariadb-client-core-10.3
mariadb-common mariadb-server-10.3 mariadb-server-core-10.3 socat
Suggested packages:
gawk-doc libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl
libipc-sharedcache-perl mailx mariadb-test tinyca
The following NEW packages will be installed:
galera-3 gawk libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl
libdbd-mysql-perl libdbi-perl libfcgi-perl libhtml-template-perl libsigsegv2
libsnappy1v5 libterm-readkey-perl mariadb-client-10.3 mariadb-client-core-10.3
mariadb-common mariadb-server mariadb-server-10.3 mariadb-server-core-10.3
socat
0 upgraded, 19 newly installed, 0 to remove and 0 not upgraded.
Need to get 20.1 MB of archives.
After this operation, 167 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libsigsegv2 amd64 2.12-2 [13.9 kB]
Get:2 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 gawk amd64 1:5.0.1+dfsg-1 [418 kB]
Get:3 http://kr.archive.ubuntu.com/ubuntu focal-updates/universe amd64 mariadb-common all 1:10.3.32-0ubuntu0.20.04.1 [15.9 kB]
Get:4 http://kr.archive.ubuntu.com/ubuntu focal/universe amd64 galera-3 amd64 25.3.29-1 [898 kB]
Get:5 http://kr.archive.ubuntu.com/ubuntu focal-updates/main amd64 libdbi-perl amd64 1.643-1ubuntu0.1 [730 kB]
Get:6 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libconfig-inifiles-perl all 3.000002-1 [40.6 kB]
Get:7 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libsnappy1v5 amd64 1.1.8-1build1 [16.7 kB]
Get:8 http://kr.archive.ubuntu.com/ubuntu focal-updates/universe amd64 mariadb-client-core-10.3 amd64 1:10.3.32-0ubuntu0.20.04.1 [5,868 kB]
Get:9 http://kr.archive.ubuntu.com/ubuntu focal-updates/universe amd64 mariadb-client-10.3 amd64 1:10.3.32-0ubuntu0.20.04.1 [1,129 kB]
Get:10 http://kr.archive.ubuntu.com/ubuntu focal-updates/universe amd64 mariadb-server-core-10.3 amd64 1:10.3.32-0ubuntu0.20.04.1 [6,017 kB]
Get:11 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 socat amd64 1.7.3.3-2 [323 kB]
Get:12 http://kr.archive.ubuntu.com/ubuntu focal-updates/universe amd64 mariadb-server-10.3 amd64 1:10.3.32-0ubuntu0.20.04.1 [4,198 kB]
Get:13 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libcgi-pm-perl all 4.46-1 [186 kB]
Get:14 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libfcgi-perl amd64 0.79-1 [33.1 kB]
Get:15 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libcgi-fast-perl all 1:2.15-1 [10.5 kB]
Get:16 http://kr.archive.ubuntu.com/ubuntu focal/universe amd64 libdbd-mysql-perl amd64 4.050-3 [82.8 kB]
Get:17 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libhtml-template-perl all 2.97-1 [59.0 kB]
Get:18 http://kr.archive.ubuntu.com/ubuntu focal/main amd64 libterm-readkey-perl amd64 2.38-1build1 [24.6 kB]
Get:19 http://kr.archive.ubuntu.com/ubuntu focal-updates/universe amd64 mariadb-server all 1:10.3.32-0ubuntu0.20.04.1 [12.7 kB]
Fetched 20.1 MB in 4s (4,798 kB/s)
Preconfiguring packages ...
Selecting previously unselected package libsigsegv2:amd64.
(Reading database ... 184879 files and directories currently installed.)
Preparing to unpack .../libsigsegv2_2.12-2_amd64.deb ...
Unpacking libsigsegv2:amd64 (2.12-2) ...
Setting up libsigsegv2:amd64 (2.12-2) ...
Selecting previously unselected package gawk.
(Reading database ... 184886 files and directories currently installed.)
Preparing to unpack .../0-gawk_1%3a5.0.1+dfsg-1_amd64.deb ...
Unpacking gawk (1:5.0.1+dfsg-1) ...
Selecting previously unselected package mariadb-common.
Preparing to unpack .../1-mariadb-common_1%3a10.3.32-0ubuntu0.20.04.1_all.deb ...
Unpacking mariadb-common (1:10.3.32-0ubuntu0.20.04.1) ...
Selecting previously unselected package galera-3.
Preparing to unpack .../2-galera-3_25.3.29-1_amd64.deb ...
Unpacking galera-3 (25.3.29-1) ...
Selecting previously unselected package libdbi-perl:amd64.
Preparing to unpack .../3-libdbi-perl_1.643-1ubuntu0.1_amd64.deb ...
Unpacking libdbi-perl:amd64 (1.643-1ubuntu0.1) ...
Selecting previously unselected package libconfig-inifiles-perl.
Preparing to unpack .../4-libconfig-inifiles-perl_3.000002-1_all.deb ...
Unpacking libconfig-inifiles-perl (3.000002-1) ...
Selecting previously unselected package libsnappy1v5:amd64.
Preparing to unpack .../5-libsnappy1v5_1.1.8-1build1_amd64.deb ...
Unpacking libsnappy1v5:amd64 (1.1.8-1build1) ...
Selecting previously unselected package mariadb-client-core-10.3.
Preparing to unpack .../6-mariadb-client-core-10.3_1%3a10.3.32-0ubuntu0.20.04.1_amd64.deb ...
Unpacking mariadb-client-core-10.3 (1:10.3.32-0ubuntu0.20.04.1) ...
Selecting previously unselected package mariadb-client-10.3.
Preparing to unpack .../7-mariadb-client-10.3_1%3a10.3.32-0ubuntu0.20.04.1_amd64.deb ...
Unpacking mariadb-client-10.3 (1:10.3.32-0ubuntu0.20.04.1) ...
Selecting previously unselected package mariadb-server-core-10.3.
Preparing to unpack .../8-mariadb-server-core-10.3_1%3a10.3.32-0ubuntu0.20.04.1_amd64.deb ...
Unpacking mariadb-server-core-10.3 (1:10.3.32-0ubuntu0.20.04.1) ...
Selecting previously unselected package socat.
Preparing to unpack .../9-socat_1.7.3.3-2_amd64.deb ...
Unpacking socat (1.7.3.3-2) ...
Setting up mariadb-common (1:10.3.32-0ubuntu0.20.04.1) ...
update-alternatives: using /etc/mysql/mariadb.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mariadb-server-10.3.
(Reading database ... 185410 files and directories currently installed.)
Preparing to unpack .../0-mariadb-server-10.3_1%3a10.3.32-0ubuntu0.20.04.1_amd64.deb ...
Unpacking mariadb-server-10.3 (1:10.3.32-0ubuntu0.20.04.1) ...
Selecting previously unselected package libcgi-pm-perl.
Preparing to unpack .../1-libcgi-pm-perl_4.46-1_all.deb ...
Unpacking libcgi-pm-perl (4.46-1) ...
Selecting previously unselected package libfcgi-perl.
Preparing to unpack .../2-libfcgi-perl_0.79-1_amd64.deb ...
Unpacking libfcgi-perl (0.79-1) ...
Selecting previously unselected package libcgi-fast-perl.
Preparing to unpack .../3-libcgi-fast-perl_1%3a2.15-1_all.deb ...
Unpacking libcgi-fast-perl (1:2.15-1) ...
Selecting previously unselected package libdbd-mysql-perl:amd64.
Preparing to unpack .../4-libdbd-mysql-perl_4.050-3_amd64.deb ...
Unpacking libdbd-mysql-perl:amd64 (4.050-3) ...
Selecting previously unselected package libhtml-template-perl.
Preparing to unpack .../5-libhtml-template-perl_2.97-1_all.deb ...
Unpacking libhtml-template-perl (2.97-1) ...
Selecting previously unselected package libterm-readkey-perl.
Preparing to unpack .../6-libterm-readkey-perl_2.38-1build1_amd64.deb ...
Unpacking libterm-readkey-perl (2.38-1build1) ...
Selecting previously unselected package mariadb-server.
Preparing to unpack .../7-mariadb-server_1%3a10.3.32-0ubuntu0.20.04.1_all.deb ...
Unpacking mariadb-server (1:10.3.32-0ubuntu0.20.04.1) ...
Setting up libconfig-inifiles-perl (3.000002-1) ...
Setting up gawk (1:5.0.1+dfsg-1) ...
Setting up libcgi-pm-perl (4.46-1) ...
Setting up libhtml-template-perl (2.97-1) ...
Setting up libsnappy1v5:amd64 (1.1.8-1build1) ...
Setting up socat (1.7.3.3-2) ...
Setting up mariadb-server-core-10.3 (1:10.3.32-0ubuntu0.20.04.1) ...
Setting up galera-3 (25.3.29-1) ...
Setting up mariadb-client-core-10.3 (1:10.3.32-0ubuntu0.20.04.1) ...
Setting up libfcgi-perl (0.79-1) ...
Setting up libterm-readkey-perl (2.38-1build1) ...
Setting up libdbi-perl:amd64 (1.643-1ubuntu0.1) ...
Setting up libcgi-fast-perl (1:2.15-1) ...
Setting up mariadb-client-10.3 (1:10.3.32-0ubuntu0.20.04.1) ...
Setting up libdbd-mysql-perl:amd64 (4.050-3) ...
Setting up mariadb-server-10.3 (1:10.3.32-0ubuntu0.20.04.1) ...
Created symlink /etc/systemd/system/mysql.service → /lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /lib/systemd/system/mariadb.service.
Setting up mariadb-server (1:10.3.32-0ubuntu0.20.04.1) ...
Processing triggers for systemd (245.4-4ubuntu3.15) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
root@linux:/#
apt install mariadb-client -y
root@linux:/#
apt install mariadb-backup galera-3 libmariadb3 mariadb-common -y
root@linux:/#
mariadb -V
mariadb Ver 15.1 Distrib 10.3.32-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
root@server2:~#
apt install mysql-server-core-8.0 -y
root@server2:~#
apt install mariadb-server -y
root@linux:/#
systemctl status mysql
보안설정
root@linux:/#
mysql_secure_installation
enter
root@linux:/#
mysql -u root -p
위에서 설정한 비밀번호를 입력
PHP설치
root@linux:/# apt install php -y
설치과정에서 자동으로 아래 패키지들이 설치되니 참고
- libapache2-mod-php7.4
- php-common
- php7.4
- php7.4-cli php7.4-common
- php7.4-json
- php7.4-opcache
- php7.4-readline
2024-08-08 위에 명령어로하면 php 8이 자동으로 설치된다
때문에 아래 껄사용한다
root@linux:/#
add-apt-repository ppa:ondrej/php
실행후 엔터
root@linux:/#
apt install php7.4 php7.4-mysql php7.4-gd php7.4-curl php7.4-mbstring php7.4-gmp php7.4-soap php7.4-zip -y
root@linux:/#
apt install php7.4 php7.4-fpm php7.4-mysql php-common php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-readline php7.4-mbstring php7.4-xml php7.4-gd php7.4-curl -y
root@linux:/# systemctl enable php7.4-fpm
root@linux:/# systemctl start php7.4-fpm
root@linux:/# nano /etc/php/7.4/fpm/php.ini
위 명령어로 들어가면 엄청나게 많은 글의 내용이 나오는데요.
short_open_tag = On
memory_limit = 256M
cgi.fix_pathinfo = 0
upload_max_filesize = 100M
post_max_size = 101M
max_execution_time = 360
date.timezone = Asia/Seoul
root@linux:/# systemctl reload php7.4-fpm
libapache2-mod-php 는 Apache2와의 연동에 필요한 라이브러리 패키지
php-mysql은 MySQL 계열 DB와 연동할 때 필요한 패키지
설치해주자
root@linux:/# apt install php libapache2-mod-php php-mysql -y
요거 설치하면 php 8 어쩌고도 다 설치됨...안하는거 추천
root@linux:/# php -v
끝~!
'얕고넓은지식 > linux' 카테고리의 다른 글
php 정규 표현식 (0) | 2022.03.05 |
---|---|
php 정규식 태그제거 (0) | 2022.03.05 |
phpmyadmin mysql 그누보드 내용찾아 바꾸기 (0) | 2022.02.26 |
ubuntu 20.04 웹서버 한방에 따라하기 3 phpmyadmin 설치하기 및 root 접속하기 (4) | 2022.02.06 |
ubuntu 20.04 웹서버 한방에 따라하기 2 가상호스트 설정 (0) | 2022.02.05 |
ubuntu 20.04 ssh root 외부접속하기 (0) | 2022.02.05 |
ubuntu 버전확인 (1) | 2022.02.04 |
rocky linux php 7.4 설치하기 (0) | 2022.01.07 |
리눅스 mysql 복원시 ERROR 1046 (3D000) at line 22: No database selected (0) | 2021.12.28 |
connect error: access denied for user 'root'@localhost' (using password:yes) (0) | 2021.12.26 |