December 1 2018

Linux Web Server

Open HTTP/HTTPS Port in Redhat/Fedora/CentOS

  1. firewall-cmd –add-service=http –permanent
  2. firewall-cmd –add-service=https –permanent
  3. systemctl rstart firewalld

Ubuntu LAMP Setup

# apt-get install lamp-server^
' Manual single step
# apt-get install apache2 mariadb-server libapache2-mod-php7.0 php7.0 \
php7.0-gd php7.0-json php7.0-mysql php7.0-curl php7.0-mbstring php7.0-intl php7.0-mcrypt \
php-imagick php7.0-xml php7.0-zip

Enable Apache UserDir

# nano /etc/httpd/conf.d/userdir.conf
<IfModule mod_userdir.c>
  # UserDir is disabled by default since it can confirm the presence
  # of a username on the system (depending on home directory
  # permissions).
  UserDir enabled <username>
  # To enable requests to /~user/ to serve the user's public_html
  # directory, remove the "UserDir disabled" line above, and uncomment
  # the following line instead:
  UserDir public_html
</IfModule>
<Directory /home/*/public_html>
   Options Indexes Includes FollowSymLinks
   ## For apache 2.2, Please use:
   AllowOverride All
   Allow from all
   Order deny,allow
  ## For apache >= 2.4, Please use:
  Require all granted
</Directory>
' Restart Apache
# systemctl restart httpd.service
' Assign permission to user dir
# mkdir /home/<username>/public_html
# chmod 711 /home/<username>
# chown <username>:<username> /home/<username>/public_html
# chmod 755 /home/<username>/public_html
' Apply SELinux policy
# setsebool -P httpd_enable_homedirs true
# chcon -R -t httpd_sys_content_t /home/<username>/public_html
 
Uncategorized