Home >Backend Development >PHP Tutorial >Compile and install apache2.2.26 using source code under ubuntu

Compile and install apache2.2.26 using source code under ubuntu

伊谢尔伦
伊谢尔伦Original
2016-11-25 16:00:19991browse

Download httpd-2.2.26.tar.gz (download address), execute

sudo tar xzfv httpd-2.2.26.tar.gz 
cd  httpd-2.2.26
sudo ./configure --prefix=/usr/local/apache2 --enable-module=most --enable-rewrite --enable-shared=max --enable-so

If the following error is prompted:

checking for C compiler default output file name... configure: error: C compiler cannot create executables

The reason is that libc6-dev is not installed, execute

sudo apt-get install build-essential

and it will be ok.

Then re-execute:

sudo  ./configure --prefix=/usr/local/apache2 --enable-module=most --enable-rewrite --enable-shared=max --enable-so

no error is reported, then execute

sudo make
sudo make install
sudo groupadd apache
sudo useradd -g apache apache
sudo passwd apache
sudo chown -R apache:apache /usr/local/apache2

to modify the apache configuration file, execute

sudo vi /usr/local/apache2/conf/httpd.conf

to find

User nobody
Group #-1

and change it to

User apache
Group apache

find

#ServerName www.example.com:80

and change it to

ServerName *:80

Save!

Execute the command

sudo /usr/local/apache2/bin/apachectl start

Start apache.

Open the browser and visit http://localhost

If everything goes well, you should be able to see the apache test page. Congratulations, apache is installed!

The commands to restart and shut down the apache service are:

sudo /usr/local/apache2/bin/apachectl restart
sudo /usr/local/apache2/bin/apachectl stop


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn