Apache is a cross-platform software that supports Linux, BSD, Mac OS, Microsoft Windows, Novell NetWare, and BeOS operating systems.
Installation Apache2:
To install Apache2 on VDS, you must register:
apt-get install apache2
Customization Apache2:
To configure Apache2, go to /etc/apache2/sites-available and create a file modeled on site.conf:
<VirtualHost *:80>
ServerName spacecore.pro # Specify the site domain
ServerAdmin admin@spacecore.pro # Your email address
DocumentRoot /var/www/html # The path to the site folder
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Turning on the site, the site.conf location should be the name of the config that you created:
a2ensite site.conf
If you need to disable the site, the name of the config should be instead of site.conf:
a2dissite site.conf
Rebooting apache2:
service apache2 reload
Connecting PHP to Apache2:
In order for Apache to display php files correctly, you need to install the package:
apt-get install libapache2-mod-php -y
Rebooting apache2:
service apache2 reload
Enabling rewrite:
Without this option, 70% of CMS for websites will not work.
Most sites contain a file.htaccess must be registered for its operation:
a2enmod rewrite
Rebooting apache2:
service apache2 reload
Enabling SSL:
You need to enable the module that is responsible for SSL:
a2enmod ssl
Creating another config in /etc/apache2/sites-available, it will be responsible for SSL, for example site-ssl.conf:
<VirtualHost *:443>
ServerName spacecore.pro # Specify the site domain
ServerAdmin admin@spacecore.pro # Your email address
DocumentRoot /var/www/html # The path to the site folder
SSLEngine on
SSLCertificateFile /path/to/your_domain_name.pem # The path to the public certificate
SSLCertificateKeyFile /path/to/your_private.key # The path to the private certificate
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Rebooting apache2:
service apache2 reload
Check на nginx:
If apache2 is installed with nginx, then they will conflict due to port - 80. So you need to delete one of the web servers. Check if nginx is installed:
service nginx status
If nginx is installed, you need to delete it:
apt-get remove --purge nginx* -y
Removal Apache2
To remove Apache2, use:
apt-get remove --purge apache2* -y
Last updated