天天看点

linux 系统快速安装lamp

#安装apache  

yum -y install httpd httpd-devel   

#安装mysql  

yum -y install mysql mysql-devel mysql-server mysql-libs 

phpmyadmin]# yum -y install httpd-man l mod_ssl mod_perl mod_auth_mysql

#安装php  

yum -y install php  

#安装php扩展  

yum -y install php-mysql php-gd php-imap php-ldap php-odbc php-mbstring php-devel php-soap php-cli php-pdo   

yum -y install php-mcrypt php-tidy php-xml php-xmlrpc php-pear    

#其它不常用php扩展, www.linuxidc.com 可不用安装  

yum -y install php-pecl-memcache php-eaccelerator  

#安装phpmyadmin  

yum -y install phpmyadmin   

#安装完成之后,启动  

service httpd start  

service mysqld start 

2、为root账户设置密码

mysql_secure_installation

回车,根据提示输入y

输入2次密码,回车

根据提示一路输入y

最后出现:thanks for using mysql!

linux 系统快速安装lamp

[root@iz25tti3rxdz ~]# service mysqld start  

initializing mysql database:  installing mysql system tables...  

ok  

filling help tables...  

to start mysqld at boot time you have to copy  

support-files/mysql.server to the right place for your system  

please remember to set a password for the mysql root user !  

to do so, start the server, then issue the following commands:  

/usr/bin/mysqladmin -u root password 'new-password'  

/usr/bin/mysqladmin -u root -h iz25tti3rxdz password 'new-password'  

alternatively you can run:  

/usr/bin/mysql_secure_installation  

which will also give you the option of removing the test  

databases and anonymous user created by default.  this is  

strongly recommended for production servers.  

see the manual for more instructions.  

you can start the mysql daemon with:  

cd /usr ; /usr/bin/mysqld_safe &  

you can test the mysql daemon with mysql-test-run.pl  

cd /usr/mysql-test ; perl mysql-test-run.pl  

please report any problems with the /usr/bin/mysqlbug script!  

                                                           [  ok  ]  

starting mysqld:                                           [  ok  ]  

[root@iz25tti3rxdz ~]# mysql_secure_installation  

note: running all parts of this script is recommended for all mysql  

      servers in production use!  please read each step carefully!  

in order to log into mysql to secure it, we'll need the current  

password for the root user.  if you've just installed mysql, and  

you haven't set the root password yet, the password will be blank,  

so you should just press enter here.  

enter current password for root (enter for none):  

error 1045 (28000): access denied for user 'root'@'localhost' (using password: yes)  

ok, successfully used password, moving on...  

setting the root password ensures that nobody can log into the mysql  

root user without the proper authorisation.  

set root password? [y/n] y  

new password:  

re-enter new password:  

password updated successfully!  

reloading privilege tables..  

 ... success!  

by default, a mysql installation has an anonymous user, allowing anyone  

to log into mysql without having to have a user account created for  

them.  this is intended only for testing, and to make the installation  

go a bit smoother.  you should remove them before moving into a  

production environment.  

remove anonymous users? [y/n] n  

 ... skipping.  

normally, root should only be allowed to connect from 'localhost'.  this  

ensures that someone cannot guess at the root password from the network.  

disallow root login remotely? [y/n] n  

by default, mysql comes with a database named 'test' that anyone can  

access.  this is also intended only for testing, and should be removed  

before moving into a production environment.  

remove test database and access to it? [y/n] y  

 - dropping test database...  

 - removing privileges on test database...  

reloading the privilege tables will ensure that all changes made so far  

will take effect immediately.  

reload privilege tables now? [y/n] y  

cleaning up...  

all done!  if you've completed all of the above steps, your mysql  

installation should now be secure.  

thanks for using mysql!  

mysql密码设置完成,重新启动 mysql:

/etc/init.d/mysqld restart #重启

/etc/init.d/mysqld stop #停止

/etc/init.d/mysqld start #启动

step 3.配置httpd、mysqld开机自启动

chkconfig mysqld on  

chkconfig httpd on  

step 4.配置phpmyadmin

修改/usr/share/phpmyadmin/config.inc.php或者 /usr/share/phpmyadmin/config.inc.php 

#将这里abcde文字修改为自己的字符,可任意 

$cfg['blowfish_secret'] = 'abcde'; 

常见问题

1. phpmyadmin提示未开启php-mcrypt,这是因为没有安装php-mrcrpt扩展。在官方源没有php-mrcrpt扩展,请安装epel源后再yum install php-mcrypt

2. phpmyadmin无法访问

phpmyadmin默认只能使用http://localhost/phpmyadmin来访问,可以修改/etc/httpd/conf.d/phpmyadmin.conf中对应部分为

<directory "/usr/share/phpmyadmin">  

  order deny,allow  

#  deny from all  

  allow from all  

</directory>  

不过强烈不支持这么做的,把phpmyadmin暴露了不安全

注意:

apache解析php,修改httpd.conf文件,添加

addtype application/x-httpd-php .php .phtml

addtype application/x-httpd-php-source .phps

myql可以远程登录

设置mysql密码

mysql>; use mysql;

mysql>; update user set password=password('newpassword') where user='root';

mysql>; flush privileges;

1.2.3 允许远程登录

mysql -u root -p

enter password: <your new password>

mysql>grant all privileges on *.* to '用户名'@'%' identified by '密码' with grant option;

完成后就能用mysql-front远程管理mysql了。

设为开机启动

chkconfig mysqld on

我执行过程:

[root@huangwei mysql]# mysql_secure_installation

/bin/mysql_secure_installation:行379: find_mysql_client: 未找到命令

note: running all parts of this script is recommended for all mariadb

      servers in production use!  please read each step carefully!

in order to log into mariadb to secure it, we'll need the current

password for the root user.  if you've just installed mariadb, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

enter current password for root (enter for none): 

error 1045 (28000): access denied for user 'root'@'localhost' (using password: yes)

ok, successfully used password, moving on...

setting the root password ensures that nobody can log into the mariadb

root user without the proper authorisation.

set root password? [y/n] y

new password: 

re-enter new password: 

password updated successfully!

reloading privilege tables..

 ... success!

by default, a mariadb installation has an anonymous user, allowing anyone

to log into mariadb without having to have a user account created for

them.  this is intended only for testing, and to make the installation

go a bit smoother.  you should remove them before moving into a

production environment.

remove anonymous users? [y/n] y

normally, root should only be allowed to connect from 'localhost'.  this

ensures that someone cannot guess at the root password from the network.

disallow root login remotely? [y/n] y

by default, mariadb comes with a database named 'test' that anyone can

access.  this is also intended only for testing, and should be removed

before moving into a production environment.

remove test database and access to it? [y/n] n

 ... skipping.

reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

reload privilege tables now? [y/n] y

cleaning up...

all done!  if you've completed all of the above steps, your mariadb

installation should now be secure.

thanks for using mariadb!

参考:

http://www.jb51.net/article/38601.htm