CentOS Installation Apache+php+mysql Guide

Source: Internet
Author: User
Tags anonymous flush install php mkdir ssh centos vps create database vps

The first step, CentOS System selection settings will not be said, all in the Linode background operation on it.

First, login VPS Modify host Name
1, login to the server

Using terminal tools to log on to the server, Linux, Mac system can use terminal tools for SSH connection login, Windows platform can use Putty to log in.

Take Putty as an example, simply enter the IP address, select SSH Connection, click Open, the first login may pop-up security warning, confirm, in the Terminal interface input Administrator account name and password can be.

2, modify the host name

The default hostname is localhost, recommended for modification, not just for security, but also for easy memory and recognition:

echo "Hostname=myhostname" >>/etc/sysconfig/network
Hostname "Myhostname"

3, run the update (including the kernel and package)

Yum Update

If the kernel is not updated and only the package is updated, use the command:

Yum--exclude=kernel* Update

Note:

The following assumptions are based on the root user login and, if other users, after the final installation may be completed, the contents of the directory (such as the site directory, database directory) specific settings are different.
For example, install Lamp server below.
Two, for CentOS VPS install Apache
1. Install Apache

Yum Install httpd

2, Backup httpd.conf configuration file

Cp/etc/httpd/conf/httpd.conf ~/httpd.conf.backup

3. Create a virtual machine configuration file

File path is:/etc/httpd/conf.d/

File name: vhost.conf

The contents are as follows:

Namevirtualhost 12.34.56.78:80

<virtualhost 12.34.56.78:80>
ServerAdmin abc@gmail.com
ServerName metsky.com
Serveralias www.metsky.com
documentroot/srv/www/metsky.com/public_html/
Errorlog/srv/www/metsky.com/logs/error.log
Customlog/srv/www/metsky.com/logs/access.log combined
</VirtualHost>

If you have more than one virtual host, simply add <virtualhost 12.34.56.78:80> ....</virtualhost> in turn (assuming that the site is placed in the directory as/srv/www/metsky.com/ public_html/).

After the creation is completed, the copy is uploaded to/etc/httpd/conf.d/, and the system is automatically linked after the Apache is started.

4, create the Site directory (upload file)

Mkdir-p/srv/www/metsky.com/public_html

Mkdir/srv/www/metsky.com/logs

If you already have a directory or Web site file such as metsky.com/public_html and metsky.com/logs, upload it directly, and later notice that you need to modify the access rights.

5, start Apache

/ETC/INIT.D/HTTPD start

As long as the following vhost.conf modifications are involved, it is necessary to:

/ETC/INIT.D/HTTPD Reload

6. Set boot up Apache

/sbin/chkconfig--levels 235 httpd on

Third, install MySQL for CentOS VPS
1, install MySQL (password distribution in accordance with the original MySQL distribution)

Yum Install Mysql-server

2. Set Boot up

/sbin/chkconfig--levels 235 mysqld on

3. Start MySQL

/etc/init.d/mysqld start

4. Install MySQL security update

Mysql_secure_installation

At this point to enter the root password, hit enter, and then ask whether to set the root password, select Y, enter a new root password, repeat input.

Next prompts if you want to delete the anonymous account and select Y.

Whether to open root telnet, select N. (This depends on the individual, the fate of the proposal is best to choose N, if you want to remotely to create a separate user for remote logins.) )

Delete the test database and select Y.

Reload the permission table and select Y.

5, Login MSYQL

Mysql-u root-p

If it is the first time to log in, the password is empty, direct return can

Modify the root password command as follows:

Mysql>use MySQL;

Mysql>update user SET Password=password (' MyPassword ') WHERE user= ' root ';

Mysql>flush privileges;

Suppose the password is: mypassword

6. Create a database and authorize

Create Database Mydbname;

7. Create user and authorize

Grant all on mydbname.* to ' mydbusr ' identified by ' mydbpwd ';

The MYDBUSR is the database access account, MYDBPWD access the password for the database.

If there are other databases, create and authorize them in the references 6 and 7.

Attention:

If you are uploading database files, make sure that you have 700 directory permissions (data table 660 permissions), specific permissions related to the MySQL running user.
When modifying permissions, please note that MySQL is closed first.
When accessing MySQL, if there is a read-only error, you may have just modified the database permissions are not correct, in making adjustments, if there appears _query_error_can ' t find file: './mydbname/mysometable.frm ' (errno:13) This error, first shut down MySQL, then delete ib_logfile0 and Ib_logfile1, and then restart the database.
8. Delete Anonymous account or add access password

Mysql>delete from user where user= "";

or set a password for him:

Mysql>update user Set Password=password (' New passwd ') where user= ';

Mysql>flush privileges;

9, Refresh Permissions

Flush privileges;

10. Exit from the Flash

Quit

Note: The default database is in the/var/lib/mysql directory, note that you need to change the database folder and file to 660 permissions

Iv. Installing PHP for CentOS VPS
1. Install PHP

Yum Install PHP php-pear

2, adjust the PHP configuration

Vi/etc/php.ini

error_reporting = e_compile_error| e_recoverable_error| e_error| E_core_error

Display_errors = Off

Log_errors = On

Error_log =/var/log/php.log

Max_execution_time = 300

Memory_limit = 64M

Register_globals = Off

3, restart Apache

/ETC/INIT.D/HTTPD restart

4, let PHP support MySQL

Yum Install Php-mysql

5. Install GD Library

Yum Install PHP-GD

6, restart Apache

/ETC/INIT.D/HTTPD restart

The installation has been completed here, and then:

Upload Web site programs, adjust individual directory permissions
Set domain name resolution and wait for effective

Related Article

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.