Install and configure Apache2 + CGI + SSL in Ubuntu
1. Install and uninstall apache2 in Ubuntu
Apache2 can be directly installed using commands
Sudo apt-get install apache2
It is troublesome to uninstall the server. You must uninstall the server. Otherwise, the installation of apache2 will be affected.
(1)
Sudo apt-get -- purge remove apache2
Sudo apt-get -- purge remove apache2.2-common
Sudo apt-get autoremove
(2) (key step) Find and delete the configuration file that has not been deleted.
Sudo find/etc-name "* apache *"-exec rm-rf {}\;
Sudo rm-rf/var/www
Enable/restart apache2
Service apache2 start/restart
Sudo/etc/init. d/apache2 start/restart
Ii. Configuration File
Strictly speaking, the configuration file of apache2 is/etc/apache2/apache2.conf. apache first loads apache2.conf, and then loads other configuration files according to the Include command in apache2.conf.
Dynamic module configuration
Include mod-enabled/*. load
Include mod-enabled/*. conf
User Configuration
Include httpd. conf
Port listening Configuration
Include ports. conf
General configuration statement snippets
Include conf. d/
VM configuration instructions
Include sites-enabled/
In ubuntu, the web root directory is in/var/www, And the setting is in/etc/apache2/sites-enabled/000-default.
DocumentRoot/var/www
<Directory/>
Options FollowSymLinks + ExecCGI
AllowOverride None
</Directory>
<Directory/var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow, deny
Allow from all
</Directory>
The default web homepage is in/etc/apache2/mod-enabled/dir. conf.
DirectoryIndex index.html index. cgi index. pl index. php index.xhtml index.htm
In the XXX-enabled and XXX-available directories, the symbolic link pointing to the corresponding file in XXX-available is put in the XXX-enabled directory. However, only the ln command can link the file in XXX-enabled to XXX-enabled.
Iii. CGI settings
Create a directory cgi-bin under/var/www as the location where the cgi program is stored, and then modify the configuration file/etc/apache2/sites-enabled/000-default.
Set
ScriptAlias/cgi-bin // usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin/">
AllowOverride None
Options + ExecCGI-MultiViews + SymLinksIfOwnerMatch
Order allow, deny
Allow from all
</Directory>
To:
ScriptAlias/cgi-bin // var/www/cgi-bin/
<Directory "/var/www/cgi-bin">
AllowOverride None
Options + ExecCGI-MultiViews + SymLinksIfOwnerMatch
Order allow, deny
Allow from all
AddHandler cgi-script cgi
</Directory>
Restart the apache service
Cgi program permissions must be 755 (runable ).
Iv. SSL settings
Create an SSL directory
Sudo mkdir/etc/apache2/ssl
Create a self-Signed credential. Enter the content as needed.
Sudo openssl req-x509-nodes-days 365-newkey rsa: 2048-keyout/etc/apache2/ssl/apache. key-out/etc/apache2/ssl/apache. crt
Enable the SSL module
A2enmod ssl
Edit/etc/apache2/sites-enabled/default-ssl.conf
ServerAdmin webmaster @ localhost
ServerName www.bkjia.com: 443
SSLEngine on SSLCertificateFile/etc/apache2/ssl/apache. crt
SSLCertificateKeyFile/etc/apache2/ssl/apache. key
Start a VM
A2ensite default-ssl
Restart apache
Sudo service apache2 restart
Install and configure the PHP environment in Linux (Apache2)
Install the LAMP \ Vsftpd \ Webmin \ phpMyAdmin service and settings in Ubuntu 13.04
Compile and install LAMP in CentOS 5.9 (Apache 2.2.44 + MySQL 5.6.10 + PHP 5.4.12)
Source code for Web server architecture in RedHat 5.4 build the LAMP environment and application PHPWind
Apache details: click here
Apache: click here
This article permanently updates the link address: