CentOS and RHEL 7: Install Linux, Apache, MariaDB, PHP (LAMP) 설치하기
Step #1: Install Apache on a CentOS 7 / RHEL 7 server
install Apache web-server:
sudo yum install httpd
Sample outputs:
Loaded plugins: amazon-id, rhui-lbResolving Dependencies--> Running transaction check---> Package httpd.x86_64 0:2.4.6-17.el7 will be installed--> Processing Dependency: httpd-tools =2.4.6-17.el7 for package: httpd-2.4.6-17.el7.x86_64--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-17.el7.x86_64--> Running transaction check---> Package httpd-tools.x86_64 0:2.4.6-17.el7 will be installed---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed--> Finished Dependency Resolution Dependencies Resolved ====================================================================================================== Package Arch Version Repository Size======================================================================================================Installing: httpd x86_64 2.4.6-17.el7 rhui-REGION-rhel-server-releases 1.2 MInstalling for dependencies: httpd-tools x86_64 2.4.6-17.el7 rhui-REGION-rhel-server-releases 77 k mailcap noarch 2.1.41-2.el7 rhui-REGION-rhel-server-releases 31 k Transaction Summary======================================================================================================Install 1 Package (+2 Dependent packages) Total download size: 1.3 MInstalled size: 3.9 MIs this ok [y/d/N]: yDownloading packages:(1/3): httpd-tools-2.4.6-17.el7.x86_64.rpm | 77 kB 00:00:00(2/3): httpd-2.4.6-17.el7.x86_64.rpm | 1.2 MB 00:00:00(3/3): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:00------------------------------------------------------------------------------------------------------Total 2.0 MB/s | 1.3 MB 00:00:00Running transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : httpd-tools-2.4.6-17.el7.x86_64 1/3 Installing : mailcap-2.1.41-2.el7.noarch 2/3 Installing : httpd-2.4.6-17.el7.x86_64 3/3 Verifying : mailcap-2.1.41-2.el7.noarch 1/3 Verifying : httpd-tools-2.4.6-17.el7.x86_64 2/3 Verifying : httpd-2.4.6-17.el7.x86_64 3/3 Installed: httpd.x86_64 0:2.4.6-17.el7 Dependency Installed: httpd-tools.x86_64 0:2.4.6-17.el7 mailcap.noarch 0:2.1.41-2.el7 Complete!
Enable the httpd service at boot time
To make sure the httpd service start automatically at the boot time, enter:
sudo systemctl enable httpd.service
Sample outputs:
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
The following command will disable the httpd service at the boot time:
sudo systemctl disable httpd.service
Sample outputs:
rm '/etc/systemd/system/multi-user.target.wants/httpd.service'
Start the httpd service on a CentOS/RHEL v7.x
sudo systemctl start httpd.service
At this stage, you can point your web-browser to your server's IP address such as http://10.41.143.156). The following page should display on screen:
Fig.01: Check if Apache is Running on CentOS/RHEL 7 server
Stop the httpd service on a CentOS/RHEL v7.x
sudo systemctl stop httpd.service
Restart the httpd service on a CentOS/RHEL v7.x
sudo systemctl restart httpd.service
Finding the httpd service status on a CentOS/RHEL v7.x
To verify that the httpd service is running, enter:
systemctl is-active httpd.service
Sample outputs:
active
Gracefully restart the httpd service on a CentOS/RHEL v7.x
sudo apachectl graceful
Test httpd/Apache configuration file for errors on a CentOS/RHEL v7.x
sudo apachectl configtest
Sample outputs:
Syntax OK
httpd service default configuration
1. Default config file: /etc/httpd/conf/httpd.conf
1. Configuration files which load modules : /etc/httpd/conf.modules.d/ directory (e.g. PHP)
1. Select MPMs (Processing Model) as loadable modules [worker, prefork (default)] and event: /etc/httpd/conf.modules.d/00-mpm.conf
1. Default ports: 80 and 443 (SSL)
1. Default log files: /var/log/httpd/{access_log,error_log}
Step #2: Install MariaDB on a CentOS 7 / RHEL 7 server
MariaDB An enhanced, drop-in replacement for MySQL server. RHEL/CentOS v7.x shifts from MySQL to MariaDB for its database management system needs. Type the following yum command to install MariaDB server:
sudo yum install mariadb-server mariadb
To start mariadb, type:
sudo systemctl start mariadb.service
To make sure the mariadb service start automatically at the boot time, enter:
sudo systemctl enable mariadb.service
Sample outputs:
ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'
To stop/restart and disable mariadb service use the following commands:
sudo systemctl stop mariadb.service #<-- Stop mariadb serversudo systemctl restart mariadb.service #<-- Restart mariadb serversudo systemctl disable mariadb.service #<-- Disable mariadb serversudo systemctl is-active mariadb.service #<-- Is mariadb server running?
Securing MariaDB
Type the following command:
sudo /usr/bin/mysql_secure_installation
Sample outputs:
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the currentpassword for the root user. If you've just installed MariaDB, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.Enter current password for root (enter for none): PRESS-ENTER-KEYOK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation.Set root password? [Y/n] YNew password: YOUR-NEW-PASSWORD-HERERe-enter new password: YOUR-NEW-PASSWORD-HEREPassword updated successfully!Reloading privilege tables.. ... Success!By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] Y ... Success!Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] Y ... Success!By default, MariaDB comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] Y - Dropping test database... ... Success! - Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [Y/n] Y ... Success!Cleaning up...All done! If you've completed all of the above steps, your MariaDBinstallation should now be secure.Thanks for using MariaDB!
Test MariaDB installation
Type the following command
mysql -u root -p
Sample outputs:
Fig.02: Mariadb test connection on a CentOS / RHEL Linux v7.x
Step #3: Install PHP on a CentOS/RHEL v7.x
To install PHP and modules such as gd/msyql type the following yum command:
sudo yum install php php-mysql php-gd php-pear
You must restart the httpd (Apache) service, enter:
sudo systemctl restart httpd.service
To search all other php modules, type:
sudo yum search php-
Sample outputs:
php-cli.x86_64 : Command-line interface for PHPphp-common.x86_64 : Common files for PHPphp-gd.x86_64 : A module for PHP applications for using the gd graphics libraryphp-ldap.x86_64 : A module for PHP applications that use LDAPphp-mysql.x86_64 : A module for PHP applications that use MySQL databasesphp-odbc.x86_64 : A module for PHP applications that use ODBC databasesphp-pdo.x86_64 : A database access abstraction module for PHP applicationsphp-pear.noarch : PHP Extension and Application Repository frameworkphp-pecl-memcache.x86_64 : Extension to work with the Memcached caching daemonphp-pgsql.x86_64 : A PostgreSQL database module for PHPphp-process.x86_64 : Modules for PHP script using system process interfacesphp-recode.x86_64 : A module for PHP applications for using the recode libraryphp-soap.x86_64 : A module for PHP applications that use the SOAP protocolphp-xml.x86_64 : A module for PHP applications which use XMLphp-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
To find more info about a module type:
sudo yum info php-pgsql
To install php module called php-pgsql type:
sudo yum install php-pgsql
Test PHP on your server
Create a file called /var/www/html/test.php as follows:
sudo vi /var/www/html/test.php
Append the following code:
<?php phpinfo(INFO_GENERAL);?>
Save and close the file. Point your web-browser to your server's IP address such as http://10.41.143.156/info.php (feel free to replace the 10.41.143.156 with your actual IP address):
http://10.41.143.156/info.php
Sample outputs:
Fig.03: Test Apache+PHP with phpinfo() On a CentOS/RHEL v7.x server
In next part, I will cover the following topics (rss feed for RHEL7 or rss for CentOS7 tutorials):
1. Apache configuration
1. Virtual hosting
1. Apache security
1. mod_ssl
1. Perl
1. Firewall configuration
LAMP 설치 하는방법을 살펴 보았습니다.
참고가 되면 좋겠내요
출처 : http://www.cyberciti.biz
'기술자료 > 기술운영자료' 카테고리의 다른 글
CentOS / RHEL 7 Restart / Stop / Start Networking Command (0) | 2016.03.20 |
---|---|
RHEL 7.0에서 바뀌는 내용 알아보기 (0) | 2016.03.20 |
Apache 에서 최대 접속자 수 늘리는 방법 (0) | 2016.03.20 |
KeepAlive의 정의 및 설정 (0) | 2016.03.20 |
rsync 를 이용하여 동기화 할때 2개 이상 특정 폴더 제외하기 (0) | 2016.03.20 |