按照 openSUSE SDB:LAMP setup 安裝好了LAMP。運行的大多數命令都是來自與openSUSE SDB:LAMP setup中。php
本頁面描述如何安裝LAMP,這是 Linux Apache MariaDB PHP. 爲了這個目的,你須要安裝:html
整個安裝須要的時間大概是20分鐘,但這可能依賴你的網絡鏈接狀況。java
第一,確保你有root權限和輸入如下代碼:mysql
zypper in apache2
啓動apache2linux
systemctl start apache2
若是你想重啓apache,使用:web
systemctl restart apache2
或者你想中止它,使用:sql
systemctl stop apache2
爲了系統重啓後自動啓動apache服務數據庫
systemctl enable apache2
爲了檢查你的apache2服務是否工做,使用你喜歡的文本編輯器在/srv/www/htdocs/文件夾中建立一個文件index.html文件寫入如下內容:apache
<html><body><h1>Welcome to my web site!</h1></body></html>
如今使用你喜歡的瀏覽器,輸入localhost,你應該能夠看到一個頁面中和大字標題 Welcome to my web site!瀏覽器
在目前的狀態,web服務只容許使用localhost訪問。若是你想容許它使用一個遠程主機名(host)訪問,你須要在防火牆中開啓http(80)端口。這樣作,編輯/etc/sysconfig/SuSEfirewall2文件和修改如下行
FW_CONFIGURATION_EXT=""
爲
FW_CONFIGURATION_EXT="apache2"
在編輯完以後,你須要重啓防火牆使用:
systemctl restart SuSEfirewall2
確保你有root權限 -- 看下面,安裝php7使用:
zypper in php7 php7-mysql apache2-mod_php7
別忘記啓用mod-php經過運行:
a2enmod php7
你已經完成了,php7如今已經安裝了。
若是使用安裝PHP5,步驟差很少和上面同樣,使用"php5"代替"php7"
zypper in php5 php5-mysql apache2-mod_php5
a2enmod php5
注意你須要選擇安裝php5仍是php7,你不能同時安裝它們。
如今你已經安裝好了php,你須要重啓你的apache2 web服務器:
systemctl restart apache2
爲了驗證php是已經在運行,在/srv/www/htdocs/文件夾中建立一個index.php文件並寫入如下內容:
<?php phpinfo(); ?>
如今,使用你的瀏覽器瀏覽localhost,你應該能夠看到一個頁面包含一個表格顯示全部的PHP設置
確保你有root權限 -- 同上。咱們須要安裝mariadb和mariadb-tools
zypper in mariadb mariadb-tools
啓動MariaDB服務,運行:
systemctl start mysql
若是你想在服務器上面看發佈消息,cat /var/log/messages.
cat /var/log/messages
確認這個服務可以在每次啓動時自動啓動:
systemctl enable mysql
若是你想重啓mysql,運行:
systemctl restart mysql
或者你想中止它,運行:
systemctl stop mysql
經過配置MariaDB 服務提升安全性,請使用openSUSE提供的腳本mysql_secure_installation.後面的描述全過程
root # mysql_secure_installation 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):
這裏儘管按回車(Enter)鍵.
root #
... (output sequel of previous command)
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
這裏儘管輸入y.
root #
... (output sequel of previous command)
New password:
如今輸入給root用戶的密碼
root # ... (output sequel of previous command) Re-enter new password:
輸入確認密碼
root # ... (output sequel of previous command) 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來移除匿名用戶。
root # ... (output sequel of previous command) ... Success! 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
root # ... (output sequel of previous command) ... Success! 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]
回覆y
root # ... (output sequel of previous command) - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n]
回覆 y
最後可能會輸出:
... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
替換<NEW PASSWORD>的值爲你想定義的一個新密碼,運行:
mysqladmin -u root password '<NEW PASSWORD>'
輸入目前的密碼或密碼從沒有定義只須要按回車(Enter)
如今你能夠在服務器客戶端中登陸經過運行:
root # mysql -u root -p
Enter password:
而後輸入你的密碼
root # ... (output sequel of previous command) Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 154 Server version: 10.0.22-MariaDB openSUSE package Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
能夠經過運行exit;回到終端.
phpMyAdmin -- a.k.a pma -- 是一個經過網站頁面來管理你數據庫的工具。
安裝phpMyAdmin,運行:
zypper in phpMyAdmin
這固然會安裝一些依賴的php5模塊和重啓apache2服務。
爲了登陸到phpMyAdmin:
如今你能夠經過你的瀏覽器瀏覽http://localhost/phpMyAdmin/或http://ip_address/phpMyAdmin/並輸入mysql root的用戶名和他的密碼。
就是這些!你如今能夠經過一個網站頁面來管理你的數據庫了。
你能夠閱讀phpMyAdmin的文檔在phpMyAdmin website
你如今應該有個在運行的LAMP服務了。
sudo zypper in php7-bcmath php7-opcache php7-bz2 php7-calendar php7-ctype php7-curl php7-dom php7-ftp php7-gd php7-gettext php7-gmp php7-iconv php7-imap php7-ldap php7-mbstring php7-mcrypt php7-odbc php7-openssl php7-pcntl php7-pgsql php7-posix php7-shmop php7-snmp php7-soap php7-sockets php7-sqlite php7-sysvsem php7-tokenizer php7-wddx php7-xmlrpc php7-xsl php7-zlib php7-exif php7-fastcgi php7-pear php7-sysvmsg php7-sysvshm php7-zip
若是你想安裝php5的擴張,運行的命令和上面同樣,把"php7"替換爲"php5",運行:
sudo zypper in php5-bcmath php5-opcache php5-bz2 php5-calendar php5-ctype php5-curl php5-dom php5-ftp php5-gd php5-gettext php5-gmp php5-iconv php5-imap php5-ldap php5-mbstring php5-mcrypt php5-odbc php5-openssl php5-pcntl php5-pgsql php5-posix php5-shmop php5-snmp php5-soap php5-sockets php5-sqlite php5-sysvsem php5-tokenizer php5-wddx php5-xmlrpc php5-xsl php5-zlib php5-exif php5-fastcgi php5-pear php5-sysvmsg php5-sysvshm php5-zip
安裝完以後,別忘記重啓apache2 web服務。
sudo systemctl restart apache2
安裝mysql
sudo zypper in mysql-community-server mysql-community-server-client mysql-community-server-tools mysql-connector-java mysql-workbench
SDB:LAMP setup本文的英文原文