본문 바로가기

프로그램개발/RaspberryPi3

라즈베리파이3(Raspberry Pi) Apache웹서버 & WordPress 설치하기





라즈베리파이에 무얼할까 고민하다가,,,


리콜박스나 레트로박스도 고민해봤죠..   (둘다 게임박스)


설치도 해봤습니다;;ㅎㅎ   물론 잘 안되서 다시 라즈비안을 깔았죠.




리콜박스는 SDCard를 하나 더 사서 재도전해보기로 생각중입니다.




그래서 여기에는 만만(?!)한 웹서버를 설치해서 간단하게 홈페이지를 서비스 해볼


생각입니다.




라즈비안에서 웹서버 구성은 아래와 같이 하시면 됩니다.


요렇게 --> LAMP (Linux, Apache, MySQL, PHP)



라즈비안도 리눅스이기 때문에... 리눅스OS+아파치웹서버+MySQL 데이터베이스+PHP언어


이렇게 구성하면 간편하게 서비스 할 수 있습니다.




고정IP가 있으면 완벽하겠지만... 비싸기 때문에 ㅎㅎ


저렴하게 웹호스팅업체에서 하나 구매해서 쓰시면 되겠죠??


저는 일단 그냥 로컬PC에서만..




1. Apache2 웹서버 설치하기



아파치2서버 설치 명령어는 다음과 같습니다.


터미널 실행 후


sudo apt-get install apache2 -y



설치가 완료되면 웹서버가 정상적으로 서비스 되는지 테스트 해봅니다.



http://localhost


혹은


http://127.0.0.1(본인 IP입력)






To find out the Pi's IP address, type hostname -I at the command line (or read more about finding your IP address) 라고 가이드문서에 설명되어 있네요.


https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/worksheet/




브라우저가 잘 열리면 설치가 잘 된 것입니다.!!  



서비스되는 웹페이지의 주소는 아래와 같습니다.


/var/www/html/index.html



이 경로에 서비스 하고싶은 페이지를 넣으면 되는거죠~~




2. PHP 설치하기


PHP is a preprocessor; it's code that runs when the server receives a request for a web page. It runs, works out what needs to be shown on the page, then sends that page to the browser.


Unlike static HTML, PHP can show different content under different circumstances. Other languages are capable of this, but since WordPress is written in PHP, that's what we need to use this time. PHP is a very popular language on the web; large projects like Facebook and Wikipedia are written in PHP.


라고 가이드에 나와있네요;;ㅎ



설치 명령어는 아래와 같습니다.



sudo apt-get install php5 libapache2-mod-php5 -y




설치가 완료되면 index.php 파일을 생성해서 테스트 해봅니다.



sudo leafpad index.php

(or use nano)



간단히 PHP 소스를 입력 후 저장하기


<?php echo "hello world"; ?>



sudo rm index.html


그리고 기존 파일은 삭제 해줌.



웹서버를 재기동 해줍니다.



sudo service apache2 restart







3. MySQL 설치하기


MySQL (pronounced My Sequel or My S-Q-L) is a popular database engine. Like PHP, its overwhelming presence on web servers enhanced its popularity. This is why projects like WordPress use it, and why those projects are so popular.


MySQL은 유명한 데이터베이스 엔진이죠.


개인이 사용하기에 좋은 무료 라이선스이기도 합니다.



설치명령어는 아래와 같습니다.


sudo apt-get install mysql-server php5-mysql -y



Now restart Apache : 아파치 웹서버를 재기동 합니다.


sudo service apache2 restart




4. WordPress 설치하기


wordpress.org  홈페이지에서 다운받을 수 있습니다.


wordpress.org/latest.tar.gz and wordpress.org/latest.zip 두가지를 제공하고 있는데요~




아래와 같이 파일을 다운받습니다.


cd /var/www/html/


sudo rm *


sudo wget http://wordpress.org/latest.tar.gz



웹서비스가 제공되는 폴더에 기존파일은 전부지우고,


압축파일을 받은 후


압축해제 합니다.




압축풀고


sudo tar xzf latest.tar.gz



최상위 경로로 파일을 옮기고


sudo mv wordpress/* /var/www/html



압축파일은 삭제하기


sudo rm -rf wordpress latest.tar.gz





여기 보이는 리눅스 기본명령어는 좀 알고있어야 이해가 됩니다.;;;


저도 부지런히...ㅎㅎ






tree 로 보면


├── index.php

├── license.txt

├── readme.html

├── wp-activate.php

├── wp-admin

├── wp-blog-header.php

├── wp-comments-post.php

├── wp-config-sample.php

├── wp-content

├── wp-cron.php

├── wp-includes

├── wp-links-opml.php

├── wp-load.php

├── wp-login.php

├── wp-mail.php

├── wp-settings.php

├── wp-signup.php

├── wp-trackback.php

└── xmlrpc.php



압축이 잘풀려있는걸 보실 수 있어요.




이제 데이터베이스에 접속 해볼께요.


mysql -uroot -ppassword



-u 옵션뒤에 붙여서 계정을 입력해야 합니다.


물론 패스워드도 -p뒤에 붙여서 넣기!




아니면


mysql -uroot -p



이렇게 먼저 계정넣고 그 후에 다시 물어보면 비빌번호를 입력해도 됩니다~~




WordPress 를 사용하기 전에 데이터베이스를 먼저 생성해줘야 합니다.


mysql> create database wordpress;



정상메시지 -> Query OK, 1 row affected (0.00 sec)


Exit out of the MySQL prompt with Ctrl + D.


이제 종료하고~




5. WordPress Configuration 하기



이제 브라우저를 열고



Navigate to http://YOUR-IP-ADDRESS e.g. http://127.0.0.1 in the web browser on your Pi.


You should see a WordPress weclome page.




웰컴페이지가 보이나요?? ㅎㅎ




해당항목을 기입 후 버튼을 누릅니다.




WordPress welcome screen


Click the Let's go! button.





Now fill out the basic site information as follows:


Database Name:      wordpress

User Name:          root

Password:           <YOUR PASSWORD>

Database Host:      localhost

Table Prefix:       wp_

and click Submit to proceed.



이렇게 Submit 하게 되면 설치가 진행됩니다.




여기까지 잘 진행됐다면 모든과정은 완료 됐어요~


            




Wordpress 설치중에 Config파일 생성 오류가 날 경우,


저는 그냥 그 내용을 복사해서 터미널에서 생성해줬습니다.





sudo nano wp-config.php



에디터 실행 후 카피한 내용 붙여넣기 후 저장





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the
 * installation. You don't have to use the web site, you can
 * copy this file to "wp-config.php" and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://codex.wordpress.org/Editing_wp-config.php
 *
 * @package WordPress
 */
 
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME''wordpress');
 
/** MySQL database username */
define('DB_USER''root');
 
/** MySQL database password */
define('DB_PASSWORD''비밀번호');
 
/** MySQL hostname */
define('DB_HOST''localhost');
 
/** Database Charset to use in creating database tables. */
define('DB_CHARSET''utf8mb4');
 
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE''');
 
/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define('AUTH_KEY',         '');
define('SECURE_AUTH_KEY',  '');
define('LOGGED_IN_KEY',    '');
define('NONCE_KEY',        '');
define('AUTH_SALT',        '');
define('SECURE_AUTH_SALT''');
define('LOGGED_IN_SALT',   '');
define('NONCE_SALT',       '');
 
/**#@-*/
 
/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'wp_';
 
/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the Codex.
 *
 * @link https://codex.wordpress.org/Debugging_in_WordPress
 */
define('WP_DEBUG'false);
 
/* That's all, stop editing! Happy blogging. */
 
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . '/');
 
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
 
cs





이렇게 해주니 돌아가긴 하네요. ㅎㅎ









저도 워드프레스는 써본적이 없어서 블로그 커스터마이징 하는 방법은


조금 더 배워보고 다음 편을 써야 할거 같습니다.



언어도 아직 한글화는 되어있지 않은 거 같습니다.


관리화면을 보니 카테고리는 간결해 보이기도 하고,, 세부 메뉴를 보니 복잡해 보이기도 하고;;


이것저것 건들어 봐야겠네요~








부지런히 글을 올려보자구요~