Ubuntu Apache service in LINUX: PHP configuration _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
PHP configuration of UbuntuApache in LINUX. LieHuo. Net (LieHuo. Net) file Ubuntu system updated to the latest status, do this step before doing any operation, to ensure the system stability, at the same time there will not be some inexplicable Document of Kangli website Construction Institute (Bkjia. Com)The Ubuntu system is updated to the latest status. This step is required before any operations are performed to ensure the stability of the system. at the same time, there will not be some inexplicable phenomena.

$ Sudo apt-get update

$ Sudo apt-get dist-upgrade

Install PHP support

$ Sudo apt-get install libapache2-mod-php5

$ Sudo apt-get install php5

If you want to support graphics add php5-gd, if you want to support Mysql add php5-mysql, here to list libapache2-mod-php5 separately, mainly because php5 dependency is not done well, it is possible to install the package on the libapache-mod-php4, so to avoid unnecessary trouble, it is better to simply specify it separately. If a friend still has a problem, find the libapache-mod-php4 package in the new, and delete it if installed.

Modify the PHP configuration file to limit the maximum size of memory and files to be uploaded.

We will edit the/etc/php5/apache2/php. ini file and make the general configuration first. before modifying the file, back up the configuration file. In this way, you can recover an error.

...

Memory_limit = 8 M ==> change to the memory size you need

Upload_max_filesize = 2 M => modify the maximum file upload size

...

Extension = mysql. so supports Mysql services

Extension = gd. so supports the gd function

...

In fact, in Ubuntu, if you install the php5-mysql and php5-gd, will automatically modify the above two lines, we just do is to confirm whether they are removed in front of the annotator.

A. currently, most open sources in php are written in php4. to be compatible with previous php versions, you sometimes need to open register_long_arrays. otherwise, variables such as $ HTTP_GET_VARS and $ HTTP_POST_VARS cannot be used, some inexplicable problems may occur. A. In addition, after installing php5, check whether there is a link under/etc/apache2/mod-enabled:

Php5.load->/etc/apache2/mod-available/php5.load

Reinforce PHP to enhance security. Note: The following security depends on the situation, so I have clearly written their functions. if there is a problem, check whether the following restrictions are caused, you can comment it out. Let's get started. we will edit the/etc/php5/apache2/php. ini file again. The reason why we didn't finish the change is mainly to give you a clear idea.

# Enable the security mode. the advantage of opening a php file is that the php file can only access all the same files as the php file. even in the chroot environment, it cannot access files with different masters in jail, A backdoor like php shell is useless. phpshell is a popular php Backdoor. it can execute system commands, just like his name. it is very similar to shell.

Safe_mode = On

# Note: opening a security mode will make the php of judge online unable to work by calling external programs.

# The following settings limit the directory range that can be operated by functions such as fopen () and file () to avoid illegal file reading by intruders, you must add "/" to/var/www; otherwise, files under/var/wwww can also be accessed. This option will disable any php files that are not in the/var/www/directory, including any programs that are linked to the/var/www/directory through soft links, such as The PhpMyAdmin package, it cannot run properly after this option is set.

Open_basedir =/var/www/

# Disable the phpinfo and get_cmd_var functions to avoid service information leakage. disable them after confirming that PHP works properly.

Disable_functions = phpinfo, get_assist_var

# Setting php program error logs

Error_reporting = E_ALL

Log_errors = On

Error_log =/var/log/php_err.log

# If the php program does not specify that register_globals is required, set register_globals to Off to avoid many security problems. Note: If your program requires register_globals, do not close it. Ubuntu is disabled by default.

Register_globals = Off

# Disable remote address access. do you remember the latest vulnerability in php include? If a variable is included in a php program, the attacker can use this control server to execute a remote php program, such as phpshell, locally, so we can close this.

Allow_url_fopen = Off

OK!

The Ubuntu (LieHuo. Net) file updates the Ubuntu system to the latest status. you must do this before you perform any operations to ensure the stability of the system. at the same time, there will not be some inexplicable problems...

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.