간편 웹서버 구축해보기
mkdir /apm
cd /apm
rpm -qa | egrep '(httpd|mysql|php)'
httpd-2.2.3-63.el5.centos.1 system-config-httpd-1.3.3.3-1.el5 php-cli-5.1.6-34.el5_8 mysql-5.0.95-1.el5_7.1 php-ldap-5.1.6-34.el5_8 php-common-5.1.6-34.el5_8 php-5.1.6-34.el5_8 httpd-manual-2.2.3-63.el5.centos.1 |
which httpd php mysql
/usr/sbin/httpd |
wget ftp://ftp.neowiz.co.kr/mysql/Downloads/MySQL-5.6/MySQL-5.6.2_m5-1.linux2.6.i386.tar
yum -y install gcc cpp gcc-c++ flex
yum -y install libjpeg-devel libpng-devel freetype-devel gd-devel
groupadd –r mysql
tail -1 /etc/group
mysql:x:103:
useradd -M -c "MySQL Server" -d /var/lib/mysql -g mysql -s /bin/false mysql
passwd mysql
tar xvf MySQL-5.6.2_m5-1.linux2.6.i386.tar
mv MySQL-5.6.2_m5-1.linux2.6.i386.tar mysql-5.6.2_m5-1.linux2.6.i386.tar
rpm –Uvh MySQL*
[root@localhost apm]# rpm -Uvh MySQL*
준비 중... ########################################### [100%] 1:MySQL-client ########################################### [ 17%] 2:MySQL-devel ########################################### [ 33%] 3:MySQL-embedded ########################################### [ 50%] 4:MySQL-server ########################################### [ 67%] 120622 10:40:21 [Note] Binlog end 120622 10:40:21 [Note] Shutting down plugin 'partition' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_SYS_FIELDS' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_SYS_INDEXES' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_SYS_TABLES' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_METRICS' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_CMPMEM' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_CMP_RESET' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_CMP' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_LOCK_WAITS' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_LOCKS' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_TRX' 120622 10:40:21 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA' 120622 10:40:21 [Note] Shutting down plugin 'ARCHIVE' 120622 10:40:21 [Note] Shutting down plugin 'BLACKHOLE' 120622 10:40:21 [Note] Shutting down plugin 'MyISAM' 120622 10:40:21 [Note] Shutting down plugin 'MRG_MYISAM' 120622 10:40:21 [Note] Shutting down plugin 'MEMORY' 120622 10:40:21 [Note] Shutting down plugin 'CSV' 120622 10:40:21 [Note] Shutting down plugin 'mysql_old_password' 120622 10:40:21 [Note] Shutting down plugin 'mysql_native_password' 120622 10:40:21 [Note] Shutting down plugin 'binlog' 120622 10:40:21 [Note] Binlog end 120622 10:40:21 [Note] Shutting down plugin 'partition' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_SYS_FIELDS' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_SYS_INDEXES' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_SYS_TABLES' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_METRICS' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_CMPMEM' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_CMP_RESET' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_CMP' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_LOCK_WAITS' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_LOCKS' 120622 10:40:21 [Note] Shutting down plugin 'INNODB_TRX' 120622 10:40:21 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA' 120622 10:40:21 [Note] Shutting down plugin 'ARCHIVE' 120622 10:40:21 [Note] Shutting down plugin 'BLACKHOLE' 120622 10:40:21 [Note] Shutting down plugin 'MyISAM' 120622 10:40:21 [Note] Shutting down plugin 'MRG_MYISAM' 120622 10:40:21 [Note] Shutting down plugin 'MEMORY' 120622 10:40:21 [Note] Shutting down plugin 'CSV' 120622 10:40:21 [Note] Shutting down plugin 'mysql_old_password' 120622 10:40:21 [Note] Shutting down plugin 'mysql_native_password' 120622 10:40:21 [Note] Shutting down plugin 'binlog' PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password' Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. Please report any problems with the /usr/bin/mysqlbug script! 5:MySQL-shared ########################################### [ 83%] 6:MySQL-test ########################################### [100%] |
service mysql start
Starting MySQL... [ OK ] |
/usr/bin/mysqladmin -u root password 'centos'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'centos'
mysql -u root -p mysql
Enter password: Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 Server version: 5.6.2-m5 MySQL Community Server (GPL) Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. |
mysql> show tables;
+---------------------------+ | Tables_in_mysql | +---------------------------+ | columns_priv | | db | | event | | func | | general_log | | help_category | | help_keyword | | help_relation | | help_topic | | host | | ndb_binlog_index | | plugin | | proc | | procs_priv | | proxies_priv | | servers | | slave_master_info | | slave_relay_log_info | | slow_log | | tables_priv | | time_zone | | time_zone_leap_second | | time_zone_name | | time_zone_transition | | time_zone_transition_type | | user | +---------------------------+ 26 rows in set (0.01 sec) mysql> create database itwithgod; Query OK, 1 row affected (0.07 sec) mysql> use itwithgod Database changed mysql> use itwithgod Database changed mysql> show tables; Empty set (0.00 sec) mysql> create table employees -> (employee_id varchar(20) -> ,last_name varchar(20) -> ,first_name varchar(20) -> ,address varchar(100) -> ,email varchar(100) -> ,phone varchar(20) -> ); Query OK, 0 rows affected (0.11 sec) mysql> show tables; +---------------------+ | Tables_in_itwithgod | +---------------------+ | employees | +---------------------+ 1 row in set (0.00 sec) |
vi /var/www/html/index.php
<?php echo "<body bgcolor=Gray>"; echo "<font color=#FFFFCC>"; echo "<h3><font color=#CCFF00>array사용예제</h3></font><p>"; $array[]=123; $array[]=345; $array[]=456; echo "array[0] = $array[0]<br>"; echo "array[1] = $array[1]<br>"; echo "array[2] = $array[2]<p>"; $array[5] = "itwithgod"; $array[4] = "Linux"; $array[3] = "Lecture"; $array[6] = "Chris"; echo "array[3] = $array[3]<br>"; echo "array[4] = $array[4]<br>"; echo "array[5] = $array[5]<br>"; echo "array[6] = $array[6]<p>"; for($x = 0; $x <= 6; $x++) echo "array[".$x."] = $array[$x]<br>"; echo "================================================<p>"; ?> |
vi /etc/httpd/conf/httpd.conf
251 ServerAdmin root@localhost 251 ServerAdmin root@itwithgod.lux 265 #ServerName www.example.com:80 265 ServerName www.itwithgod.lux:80 355 UserDir disable 355 # UserDir disable 362 #UserDir public_html 362 UserDir public_html (370~381 라인까지의 주석을 해제하세요.) 370 <Directory /home/*/public_html> 371 AllowOverride FileInfo AuthConfig Limit 372 Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec 373 <Limit GET POST OPTIONS> 374 Order allow,deny 375 Allow from all 376 </Limit> 377 <LimitExcept GET POST OPTIONS> 378 Order deny,allow 379 Deny from all 380 </LimitExcept> 381 </Directory> 391 DirectoryIndex index.html index.html.var 391 DirectoryIndex index.html index.php 769 AddType application/x-httpd-php .php |
[root@localhost apm]# useradd chris
[root@localhost apm]# passwd chris
Changing password for user chris. New UNIX password: BAD PASSWORD: it is too short Retype new UNIX password: passwd: all authentication tokens updated successfully. |
mkdir /home/chris/public_html
chown -R chris:chris /home/chris/
echo "Chirs's Home Page" > /home/chris/public_html/index.html
chmod -R 755 /home/chris/
setsebool -P httpd_enable_homedirs 1
chcon -R -t httpd_sys_content_t /home/chris/public_html
service httpd start
httpd (을)를 시작 중: [ OK ]
http://localhost
http://localhost/~chris
vi /etc/hosts
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 172.30.30.128 www.itwithgod.lux www 추가 http://www.itwithgod.lux http://www.itwithgod.lux/~chris |