CentOS7 and Apache
Install
ติดตั้ง Package httpd
.
$ sudo yum install httpd [-y]
Dependencies Resolved ==================================================================================================== Package Arch Version Repository Size ==================================================================================================== Installing: httpd x86_64 2.4.6-67.el7.centos.6 updates 2.7 M Installing for dependencies: apr x86_64 1.4.8-3.el7_4.1 updates 103 k apr-util x86_64 1.5.2-6.el7 base 92 k httpd-tools x86_64 2.4.6-67.el7.centos.6 updates 88 k mailcap noarch 2.1.41-2.el7 base 31 k Transaction Summary ==================================================================================================== Install 1 Package (+4 Dependent packages)
สั่งให้ httpd
เริ่มทำงาน และเริ่มทำงานอัตโนมัติทุกครั้งที่เปิดเครื่อง
$ sudo systemctl start httpd
$ sudo systemctl enable httpd
สั่งเปิด Port เพื่อให้ภายนอกเชื่อมต่อได้ หรือเปิดผ่านชื่อ Service
$ sudo firewall-cmd --permanent --add-port=80/tcp
$ sudo firewall-cmd --permanent --add-port=443/tcp
$ sudo firewall-cmd --permanent --add-service=http
$ sudo firewall-cmd --permanent --add-service=https
สั่ง Restart Firewall เพื่อรับการตั้งค่าใหม่
$ sudo systemctl restart firewalld
ตรวจสอบการตั้งค่า Firewall
$ sudo firewall-cmd --zone=public --list-all
Configuration
Before changing any configuration file, we recommend that you make a backup of the file.
To make a backup.
$ cp /etc/httpd/conf/httpd.conf ~/httpd.conf.backup
Configuration file
$ vi /etc/httpd/conf/httpd.conf
Document web root
DocumentRoot "/var/www/html"
Controls what directives may be placed in .htaccess files.
<Directory "/var/www/html">
...
AllowOverride None
...
</Directory>
Custom Configuration File Folder
These settings can also be added to a separate file. The file must be located in the conf, conf.d, conf.module.d directories, and must end in .conf, since this is the format of files included in the resulting
/etc/httpd/conf/
/etc/httpd/conf.d/
/etc/httpd/conf.module.d/