1. Preface
CentOS (Community ENTerprise Operating System) is one of the Linux distributions and is compiled from Red Hat ENTerprise Linux based on source code released under open source rules. CentOS is the ideal operating system for architecture lamp (LINUX+APACHE+PHP+MYSQL) with high stability. This article takes CentOS as an example to introduce the method of installing Apache+php+mysql for Yum under Linux system.
2. Preparatory work
2.1. Log in to the server
Log on to the remote server and if your server is on-premises and installed with a desktop environment, you can also open the server desktop directly and enter Terminal manager.
Under Windows Putty is an excellent liunx telnet tool that opens the interface as follows
650) this.width=650; "Width=" height= "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url (" /e/u261/themes/default/images/word.gif ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
In the yellow box in the picture, fill in the server IP, click Open, then prompt for a user name and password, verify the successful completion of the login server.
2.2. Configure source and update system software
2.2.1. Defining Unofficial Yum Libraries
The official software is the current stable version, but not the latest version, in order to better run dedecms, we need some unofficial Yum source.
RPM--import Http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
Vi/etc/yum.repos.d/utterramblings.repo
Add the following content
[Utterramblings]
Name=jason ' s utter ramblings Repo
baseurl=http://www.jasonlitka.com/media/el$releasever/$basearch/
Enabled=1
Gpgcheck=1
Gpgkey=http://www.jasonlitka.com/media/rpm-gpg-key-jlitka
[Note]vim Editor to modify the method of the file, please own Baidu
2.2.2. Updating the system
Yum Update
Yum Upgrade
2.2.3. Checking system software
Check if the current system has Apache and MySQL installed
Yum List Installed | grep httpd
Rpm-qa | grep httpd
Yum List Installed | grep MySQL
Rpm-qa | grep MySQL
If it already exists, please uninstall it first
2.3. Create a directory
Here we agree to the data storage directory as follows
Website Data/www/htdocs
Log directory/www/log
Database File/www/mysql
Run the following command to complete the directory creation
Mkdir/www/mysql
Mkdir/www/htdocs
mkdir/www/log/php
Mkdir/www/log/mysql
Add Apache and MySQL users
Useradd-s/sbin/nologin-m Apache
Useradd-s/sbin/nologin-m MySQL
The directory owner and user groups need to be changed after the directory is created, and Apache and MySQL can complete the read and write operations.
Chown-r Apache:apache/www/htdocs
Chown-r Mysql:mysql/www/mysql
Chown-r apache:apache/www/log/php
Chown-r Mysql:mysql/www/log/mysql
3. Installation and Configuration
3.1. Yum Install Apache + PHP + MySQL
Yum-y install gcc gcc-c++ autoconf make aclocal libtool expat-devel libxml2-devel httpd php php-devel MySQL mysql-server Mysql-devel libevent libevent-devel magemagick imagemagick-devel php-mysql mod_ssl mod_perl mod_auth_mysql php-mcrypt PHP-GD php-xml php-mcrypt php-mbstring php-ldap php-pear php-xmlrpc php-pecl-memcache mysql-connector-odbc Libdbi-dbd-mysql Php-eaccelerator
3.2. Configure PHP
Vi/etc/php.ini
Please change it according to your own situation, here are only some of the settings to note
Post_max_size = 32M
Memory_limit = 256M
Allow_url_fopen = On
Upload_max_filesize = 32M
Upload_tmp_dir =/var/tmp
Log_errors = On
error_reporting = e_all & ~e_notice | E_strict
Display_errors = Off
Error_log =/www/log/php/php_error.log
MAGIC_QUOTES_GPC = On
3.3. Configure Apache
Make a backup of the default configuration file first
Cp/etc/httpd/conf/httpd.conf/etc/httpd/conf/httpd.conf.bak
Edit Configuration
Vi/etc/httpd/conf/httpd.conf
Make changes according to your needs
DocumentRoot "/www/htdocs" # modified to Default Web site home directory
Namevirtualhost *:80
If you install GBK version dedecms garbled, you may need to comment out this parameter
#AddDefaultCharset UTF-8
Launch Apache Service
Service httpd Start
Check that Apache is normal, open the browser, enter http://Your IP, if you see the default Apache test page, that means the successful start.
3.4. Configure MySQL
The system has been automatically installed MySQL, but we need to do some simple modification and optimization, configuration database files and log storage location, to start.
In the/usr/share/mysql/directory there are multiple my-at the beginning of the CNF file, we can choose a use for our own situation, we choose here my-medium.cnf
Copy it into the/etc directory.
Cp/usr/share/mysql/my-medium.cnf/etc/my.cnf
Edit
Vi/etc/my.cnf
Modify the following configuration, modified on the original basis, without the option to add
[Client]
Port = 3306
Socket =/var/lib/mysql/mysql.sock
Default-character-set = UTF8
[Mysqld]
user = MySQL
DataDir =/www/mysql
Log-error =/www/log/mysql/mysql_error.log
Log-bin=/www/log/mysql/mysql-bin
Expire_logs_days=7
Character-set-server = UTF8
--skip-external-locking
Start MySQL
Service mysqld Start
The system will automatically install the initial database, and then start, if there is an error, please check the error message in/www/log/mysql/mysql_error.log
Set the MySQL root user password
Mysql
UPDATE mysql.user SET password = password (' Your password ') WHERE user = ' root ';
FLUSH privileges;
Exit
4. Optimize Settings
4.1. Security settings, disable the sensitive function of PHP
Vi/etc/php.ini
Cancel the # before disable_functions, instead
Disable_functions = exec,shell_exec,system,popen,escapeshellcmd,escapeshellarg,gzuncompress,proc_open,proc_get_ Status,show_source,gzinflate
4.2. Turn on gzip compression
Gzip compression can reduce server traffic, but also increase CPU resource consumption, whether to open you need to decide depending on the situation
Vi/etc/httpd/conf/httpd.conf
LoadModule Deflate_module modules/mod_deflate.so
<ifmodule mod_deflate.c>
Deflatecompressionlevel 6
Addoutputfilterbytype DEFLATE text/html text/plain text/xml application/x-httpd-php
Addoutputfilter DEFLATE js CSS
</IfModule>
5. Create a website
Create a Site Directory
Mkdir/www/htdocs/demo
Change the owners and groups of the following site directories
Chown-r Apache:apache/www/htdocs/demo
Configuring the Virtual Host Configuration
Vi/etc/httpd/conf/httpd.conf
At the end of the add
<virtualhost *:80>
ServerName domain name. com
Serveralias www. domain name. com
Documentroot/www/htdocs/demo
</VirtualHost>
Restart Apache
Service httpd Restart
Create a database
Mysql-u root-p
Create database demo; #demo为要创建的数据库名
Exit
Environmental construction has been completed, the following you just need to upload the DEDECMS program to/www/htdocs/demo, and your domain name resolution to your server IP, you can complete the installation of DEDECMS
Close SELinux
Close iptables
This article is from "Poker Face" blog, please make sure to keep this source http://lirenpgood.blog.51cto.com/9747573/1775285
Weaving Dream Lamp environment construction