Centos6 64bit is automatically installed by Linode. It is very clean and has nothing. It is inevitable to compile things, so first give some compilation environment to yum:
yum install gcc gcc-c++ make flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel openssl-devel libxml2-devel gettext-devel pcre-devel
Modify time zone:
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
Modify host:
echo 'HOSTNAME=webmaster' >> /etc/sysconfig/network hostname 'webmaster'
Then vim /etc/hosts:
127.0.0.1 localhost.localdomain localhost xx.xx.xx.xx webmaster.onepx.com webmaster
xx.xx.xx.xx is the IP assigned by the VPS on Linode Manager.
Install Apache:
yum install httpd
Apache's configuration file is in /etc/httpd/conf/httpd.conf. If you want to add something to it, it is best to add it to the /etc/httpd/conf.d/ folder and name it x.conf. When Apache starts, it will automatically load all the .conf files in this folder.
Add a domain name, taking onepx.com and the second-level domain name doc.onepx.com as an example. Due to the influence of the previous panel, I am still used to placing the website directory under /home, vim /etc/httpd/conf.d/vhost.conf, add:
NameVirtualHost *:80ServerAdmin silihai@gmail.com ServerName onepx.com ServerAlias www.onepx.com DocumentRoot /home/onepx/public_html/ ErrorLog /home/onepx/logs/error.log CustomLog /home/onepx/logs/access.log combined ServerAdmin silihai@gmail.com ServerName doc.onepx.com ServerAlias www.doc.onepx.com DocumentRoot /home/onepx/public_html/doc/ ErrorLog /home/onepx/logs/doc.error.log CustomLog /home/onepx/logs/doc.access.log combined
Before starting apache, you need to create a directory according to the above directory structure:
mkdir -p /home/onepx/public_html mkdir /home/onepx/public_html/doc mkdir /home/onepx/logs
Start apache:
/etc/init.d/httpd start
In the future, you need to restart apache after adding a domain name to vhost.con:
/etc/init.d/httpd restart
Let Centos6 automatically start apache when it boots:
/sbin/chkconfig --levels 235 httpd on
Install mysql:
yum install mysql-server
Load mysql when the system starts:
/sbin/chkconfig --levels 235 mysqld on
Start mysql server:
/etc/init.d/mysqld start
The Mysql configuration file is in /etc/my.cnf. The more important thing is to solve the encoding problem. Add the following to solve it once and for all:
[mysqld] character-set-server=utf8 collation-server=utf8_general_ci [client] default-character-set=utf8
Then restart mysql:
/etc/init.d/mysqld restart
run:
mysql_secure_installation
The function is to set the mysql password and delete some default stuff. Then log in:
mysql -u root -p
Create a mysql database and user. The database name is "blog", the user is "onepx", and the password is "password":
create database blog; grant all on blog.* to 'onepx' identified by 'password';
Import an existing database:
use blog; source /home/previous data.sql;
Quit after you're done. For future backups, there is no need to log in to mysql. Under bash:
mysqldump -u onepx -p blog > /home/backup_blog.sql
Start installing PHP below:
yum install php php-pear php-mysql
The PHP configuration file is in /etc/php.ini, and there is also the directory /etc/php.d/. The following .ini files are automatically loaded when starting apache. You can put the added things here and name them xxx.ini. For example, for the eacclerator I want to install below, you should yum it before installing it:
yum install php-gd httpd-devel php-mbstring php-xml php-xmlrpc php-devel
In the past two days, the source on the eaccelerator official website has actually been down... I had to download it elsewhere:
wget http://voxel.dl.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/ eaccelerator-0.9.6.1.zip unzip eaccelerator-0.9.6.1.zip cd eaccelerator-0.9.6.1 phpize ./configure -enable-eaccelerator=shared make make install
Configure eaccelerator, vim /etc/php.d/eaccelerator.ini, my configuration:
extension='eaccelerator.so' eaccelerator.cache_dir='/tmp/eaccelerator' eaccelerator.check_mtime='1' eaccelerator.compress='1' eaccelerator.compress_level='9' eaccelerator.debug='0' eaccelerator.enable='1' eaccelerator.filter='' eaccelerator.optimizer='1' eaccelerator.shm_max='0' eaccelerator.shm_only='0' eaccelerator.shm_prune_period='0' ; Setting the cache to exceed 32MB will cause apache to fail to start. For details, seeeaccelerator configuration. eaccelerator.shm_size='96' eaccelerator.shm_ttl='600'
Don’t forget:
mkdir /tmp/eaccelerator chmod 777 /tmp/eaccelerator
at last:
/etc/init.d/httpd restart
LAMP installation and configuration completed!
This siteOriginal articleAll follow "Attribution-NonCommercial-ShareAlike 4.0 License (CC BY-NC-SA 4.0)". Please keep the following tags for sharing and interpretation:
Original author:Jake Tao,source:"CENTOS 6.5 new host installation configuration LAMP"