The twists and turns of LAMP installation on Linux

Source: Internet
Author: User
How to install LAMP on a Linux platform-Linux Enterprise Application-Linux server application information. I won't talk much about Linux installation. N was installed earlier. Recently, I started to learn php and naturally had to have a local test environment. However, the installation process is still difficult.

Editor's note: LAMP is short for Linux + apache + mysql + php.

First download the httpd-2.2.6 on the official site of apache, decompress the package and start to compile, pay attention to the use of dso

./Configure -- enable-so
Make
Make install

During the first installation, I forgot to make install, which is always unsuccessful. After installation, you can use the following command to start and stop apache.

/Usr/local/apache2/bin/apachectl start

/Usr/local/apache2/bin/apachectl stop

Normally, the words It works appear when accessing 127.0.0.1, which may vary with systems. Stop apache and start mysql installation. Because the mysql path needs to be specified during php compilation, install this first. Create an account first:

Useradd mysql

Groupadd-g mysql

Compilation process is similar

./Configure
Make
Make install

Then set

/Usr/local/mysql/scripts/mysql_install_db -- user = mysql

Chown-R root/usr/local/mysql
Chown-R root/usr/local/bin
Chown-R mysql/usr/local/mysql
Chgrp-R mysql/usr/local/mysql

Then you can start the database.

/Usr/local/mysql/bin/mysqld_safe -- user = mysql

An error may occur when you run mysql again.

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql. sock'

In this case, it may be caused by selinux, or mysql. sock may be elsewhere. After searching, make a connection under/tmp.

Finally install php

./Configure -- prefix =/usr/local/php \ -- with-apxs2 =/usr/local/apache2/bin/apxs \ -- with-mysql =/usr/local/mysql

Make
Make install

If you want to install zlib and other components, you can add them to the compilation options.

When apache is started after installation, an error is returned.

Document root must be a directory

After searching for gg for half a day, we learned that this was caused by selinux.

Check avc message, view the/var/log/messages file, and find a section similar to the following:

Hostname kernel: audit (1098222899.827: 0): avc :\
Denied {getattr} for pid = 19029 exe =/usr/sbin/httpd \
Path =/home/httpd/index. php dev = dm-0 ino = 373900 \
Scontext = root: system_r: httpd_t tcontext = user_ubject_r: user_home_t \
Tclass = file

It is really a ghost of SELinux's new features. I set the directory or file to the user_home_t type, so the apache process has no permissions and cannot be accessed. SELinux target policy for Apache processes specifies that apache processes can only access directories or files of the httpd_sys_content_t type.

Solution:

Simply change the policy type of the directory or file to httpd_sys_content_t.

Use root User

# Chcon-t httpd_sys_content_t directory name or file name

Then you can run the ls-laZ command to view the policy type of the file directory. Then configure httpd. conf. There are too many content on the Internet, and I am too lazy to do so. I will finish this. mysql will solve it later.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.