Giunsa ang Pag-install sa Apache sa CentOS 7


Ang Apache usa ka libre, bukas nga tinubdan ug sikat nga HTTP Server nga nagdagan sa mga operating system nga sama sa Unix lakip ang Linux ug usab Windows OS. Sukad sa pagpagawas niini 20 ka tuig na ang milabay, kini ang labing inila nga web server nga nagpaandar sa daghang mga site sa Internet. Sayon ang pag-install ug pag-configure aron mag-host sa usa o daghang mga website sa parehas nga server sa Linux o Windows.

Niini nga artikulo, among ipasabut kung giunsa ang pag-install, pag-configure ug pagdumala sa Apache HTTP web server sa usa ka CentOS 7 o RHEL 7 server gamit ang command line.

  1. Usa ka CentOS 7 Server Minimal Install
  2. Usa ka RHEL 7 Server Minimal Install
  3. Usa ka CentOS/RHEL 7 nga sistema nga adunay static nga IP address

I-install ang Apache Web Server

1. I-update una ang mga pakete sa software sa sistema ngadto sa pinakabag-o nga bersyon.

# yum -y update

2. Sunod, i-install ang Apache HTTP server gikan sa default software repository gamit ang YUM package manager sama sa mosunod.

# yum install httpd

Pagdumala sa Apache HTTP Server sa CentOS 7

3. Sa higayon nga ma-install ang Apache web server, mahimo nimong sugdan kini sa unang higayon ug mahimo kini nga awtomatikong magsugod sa boot sa system.

# systemctl start httpd
# systemctl enable httpd
# systemctl status httpd

I-configure ang firewalld aron Tugoti ang Trapiko sa Apache

4. Sa kasagaran, ang CentOS 7 built-in nga firewall gitakda aron babagan ang trapiko sa Apache. Aron tugotan ang trapiko sa web sa Apache, i-update ang mga lagda sa firewall sa sistema aron tugutan ang mga pasulod nga packet sa HTTP ug HTTPS gamit ang mga sugo sa ubos.

# firewall-cmd --zone=public --permanent --add-service=http
# firewall-cmd --zone=public --permanent --add-service=https
# firewall-cmd --reload

Sulayi ang Apache HTTP Server sa CentOS 7

5. Karon mahimo nimong pamatud-an ang Apache server pinaagi sa pag-adto sa mosunod nga URL, usa ka default nga panid sa Apache ang ipakita.

http://SERVER_DOMAIN_NAME_OR_IP 

I-configure ang Name-based Virtual Hosts sa CentOS 7

Kini nga seksyon mapuslanon lamang, kung gusto nimo nga mag-host labaw sa usa ka domain (virtual host) sa parehas nga web server sa Apache. Adunay daghang mga paagi sa pag-setup sa usa ka virtual host, apan among ipasabut ang usa sa pinakasimple nga pamaagi dinhi.

6. Una paghimo ug vhost.conf nga payl ubos sa /etc/httpd/conf.d/ nga direktoryo aron tipigan ang daghang virtual host configurations.

# vi /etc/httpd/conf.d/vhost.conf

Idugang ang mosunod nga pananglitan sa virtual host directive template para sa website mylinux-console.net, siguroha nga usbon ang gikinahanglan nga mga bili para sa imong kaugalingong domain

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin [email 
    ServerName mylinux-console.net
    ServerAlias www.mylinux-console.net
    DocumentRoot /var/www/html/mylinux-console.net/
    ErrorLog /var/log/httpd/mylinux-console.net/error.log
    CustomLog /var/log/httpd/mylinux-console.net/access.log combined
</VirtualHost>

Importante: Mahimo nimong idugang ang kutob sa mga domain sa vhost.conf file, kopyaha lang ang VirtualHost block sa ibabaw ug usba ang mga bili sa matag domain nga imong idugang.

7. Karon paghimo og mga direktoryo alang sa mylinux-console.net website nga gi-refer sa VirtualHost block sa ibabaw.

# mkdir -p /var/www/html/mylinux-console.net    [Document Root - Add Files]
# mkdir -p /var/log/httpd/mylinux-console.net   [Log Directory]

8. Paghimo ug dummy index.html nga panid ubos sa /var/www/html/mylinux-console.net.

# echo "Welcome to My TecMint Website" > /var/www/html/mylinux-console.net/index.html

9. Sa katapusan, i-restart ang serbisyo sa Apache aron matuman ang mga pagbag-o sa ibabaw.

# systemctl restart httpd.service

10. Karon mahimo nimong bisitahan ang mylinux-console.net aron sulayan ang panid sa indeks nga gihimo sa ibabaw.

Apache Importante nga mga File ug Direktor

  • Ang default server root directory (top level directory nga adunay configuration files): /etc/httpd
  • Ang nag-unang Apache configuration file: /etc/httpd/conf/httpd.conf
  • Dugang nga mga configuration mahimong idugang sa: /etc/httpd/conf.d/
  • Apache virtual host configuration file: /etc/httpd/conf.d/vhost.conf
  • Mga configure para sa mga module: /etc/httpd/conf.modules.d/
  • Apache default server document root directory (nagtipig sa web files): /var/www/html

Mahimo usab nimo nga basahon kining mosunod nga mga artikulo nga may kalabutan sa Apache web server.

  1. 13 Apache Web Server Security ug Hardening Tips
  2. 5 Mga Tip aron Mapauswag ang Pagganap sa Imong Apache Web Server
  3. Unsaon Pag-install Let's Encrypt SSL Certificate aron Ma-secure ang Apache
  4. Panalipod sa Apache Batok sa Brute Force o DDoS Attacks Gamit ang Mod_Security ug Mod_evasive nga mga Module
  5. Sa Unsang Paagi Pagpanalipod sa mga Direktoryo sa Web sa Apache Gamit ang .htaccess File
  6. Unsaon Pagsusi Unsang Apache Module ang Gi-enable/Gikarga sa Linux
  7. Unsaon Pag-ilis sa Ngalan sa Apache Server ngadto sa Bisan Unsa sa Mga Header sa Server

Kana lang! Aron makapangutana o makapaambit sa bisan unsang dugang nga mga hunahuna, palihug gamita ang porma sa feedback sa ubos. Ug hinumdomi kanunay nga magpabilin nga konektado sa linux-console.net.