# yum install httpd php mariadb mariadb-server php php-mysql wget links
# systemctl start mariadb # systemctl enable mariadb # mysql_secure_installation (設定 root 的密碼時,請特別留意!不要忘記了!) # systemctl restart mariadb # mysql -u root -p (然後輸入剛剛設定好的密碼) Mariadb > show databases; Mariadb > exit
# vim /etc/httpd/conf/httpd.conf AddDefaultCharset UTF-8 (這一行務必註解!) # vim /etc/httpd/conf.d/userdir.conf <IfModule mod_userdir.c> UserDir www </IfModule> <Directory "/home/*/www"> AllowOverride FileInfo AuthConfig Limit Indexes Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec Require method GET POST OPTIONS </Directory> # systemctl start httpd # systemctl enable httpd
$ chmod 711 ~yourname $ mkdir ~/www $ echo "My home page" > index.php $ links http://localhost/~yourname (最終 q 可以離開 links 瀏覽器)
# mysql -u root -p Mariadb> create database userdb; Mariadb> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | userdb | <==這就是重點!要注意看有沒有出現! +--------------------+ Mariadb> grant all privileges on userdb.* to username@localhost identified by 'userpw' ; Mariadb> use mysql; Mariadb [mysql]> select * from user where user = 'username'; Mariadb [mysql]> exit
# mysql -u username -p Mariadb > show databases; Mariadb > use userdb; Mariadb [userdb]> create table test1 ( name character(10)); Mariadb [userdb]> show tables; +------------------+ | Tables_in_userdb | +------------------+ | test1 | +------------------+ 1 row in set (0.01 sec) Mariadb [userdb]> describe test1; +-------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+----------+------+-----+---------+-------+ | name | char(10) | YES | | NULL | | +-------+----------+------+-----+---------+-------+ Mariadb [userdb]> drop table test1; Mariadb [userdb]> show tables; Mariadb [userdb]> exit