摘要:安裝更新源安裝服務啟動服務設置開機啟動服務安裝更新源安裝安裝成功后,將其加入開機啟動啟動服務進程配置具體設置項新安裝之后設置示例版本是,操作系統均可。需更改數據庫里的表里的項把改稱。設置最大可存入數據庫字段的值長度。
1. 安裝Apache 2.4
更新源:
rpm -Uvh https://dl.fedoraproject.org/...
rpm -Uvh https://mirror.webtatic.com/y...
安裝服務:
yum -y install httpd
CentOS7啟動服務:
systemctl start httpd.service
CentOS7設置開機啟動服務:
systemctl enable httpd.service
更新源:
rpm -Uvh http://dev.mysql.com/get/mysq...
安裝MySQL5.6:
yum -y install mysql-community-server
安裝成功后,將其加入開機啟動:
systemctl enable mysqld
啟動mysql服務進程:
systemctl start mysqld
配置MySQL:
mysql_secure_installation
具體設置項:新安裝MySQL之后設置
示例版本是MySQL5.6,操作系統CentOS6.5 - 7.3均可。
配置MySQL初始設置:
進行一些安全性配置
[root@localhost ~]# 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):
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 <--是否設置Root密碼?
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] y <--是否刪除匿名用戶?
... 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] n <--是否允許Root遠程登錄?一般選擇Y,不過我為了方便測試,先選N。
... skipping.
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...
ERROR 1008 (HY000) at line 1: Can"t drop database "test"; database doesn"t exist
... Failed! Not critical, keep moving...
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!
All done! If you"ve completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
配置遠程訪問
MySQL不允許遠程用戶訪問主機服務器 1130連接報錯:
ERROR 1130: Host ... is not allowed to connect to this MySQL server
說明所連接的用戶帳號沒有遠程連接的權限,只能在本機(localhost)登錄。 需更改 mysql 數據庫里的user表里的host項把localhost改稱%。
具體步驟:
登陸mysql :
[root@localhost ~]# mysql -uroot -p
mysql> use mysql
mysql> update user set host="%" where user = "root";
ERROR 1062 (23000): Duplicate entry "%-root" for key "PRIMARY"
有時候會報錯,但是不要緊,查看一下成功否。
mysql> select host from user where user = "root"; |
---|
host |
% |
127.0.0.1 |
::1 |
izm5edi5djftntq1oes7sfz |
4 rows in set (0.00 sec)
host已經有了%這個值,所以沒問題了。
mysql> flush privileges;
mysql> set global max_allowed_packet = 210241024*10;
設置最大可存入數據庫字段的值長度。
Query OK, 0 rows affected (0.00 sec)
可以遠程訪問了
安裝與設置
安裝最新版:
yum -y install mod_php71w php71w-bcmath php71w-cli php71w-common php71w-devel php71w-fpm php71w-gd php71w-mbstring php71w-mcrypt php71w-mysql php71w-snmp php71w-xml php71w-process php71w-ldap net-snmp net-snmp-devel net-snmp-utils rrdtool
查看版本:
php -v
基礎配置(保證一些基本使用):
vi /etc/php.ini
修改時區:把;date.timezone改為date.timezone =PRC; memory_limit = 2048M upload_max_filesize = 64M
測試
vim /var/www/html/index.php
phpinfo();
保存退出,瀏覽器訪問:
附加:安裝git、npm、composer(如果有需要)
yum install -y git
yum install -y npm
cd ~
curl -sS https://getcomposer.org/insta... | php --
mv composer.phar /usr/local/bin/composer
chmod -R 777 /usr/local/bin/composer
附加:配置PHP7-FPM與nginx(如果有需要)
vi /etc/php-fpm.d/www.conf
在第 8 行和第 10行,user 和 group 賦值為 nginx: user = nginx group = nginx 在第 22 行,確保 php-fpm 運行在指定端口: listen = 127.0.0.1:9000 取消第 366-370 行的注釋,啟用 php-fpm 的系統環境變量: env[HOSTNAME] = $HOSTNAME env[PATH] = /usr/local/bin:/usr/bin:/bin env[TMP] = /tmp env[TMPDIR] = /tmp env[TEMP] = /tmp 保存文件并退出。
在 /var/lib/ 目錄下創建一個新的文件夾 session,并將其擁有者變更為 nginx 用戶:
mkdir -p /var/lib/php/session
chown nginx:nginx -R /var/lib/php/session/
啟動 php-fpm 和 Nginx,并將它們設置開機啟動
systemctl start php-fpm.service
systemctl start nginx.service
systemctl enable php-fpm
systemctl enable nginx
文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。
轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/29411.html
摘要:在這篇文章中,我們將分享在最新系統鏡像中安裝常規的軟件環境。出于安全的考慮,以及我們后續安裝網站,需要禁止默認根目錄執行。這個其實與安裝后設置相似。這樣,在安裝完畢之后,我們可在中安裝完畢,且軟件都是比較新的。 在這篇文章中,我們將分享在最新Ubuntu18.04系統鏡像中安裝LAMP常規的軟件環境。其中軟件包括Apache2.4/MariaDB10.3/PHP7.2,這里我們看到不安...
摘要:如果想通過來安裝,則需要添加源。目前網上給出的大部分答案是這樣的這樣是找不到版本的。通過,找到了正確的安裝步驟這樣才能通過來安裝在安裝過程中,會要求輸入的密碼。排錯如果頁面空白,請嘗試強制刷新頁面。此時應該可以看見中的內容了。 Ubuntu 14.04 安裝并配置LAMP 標簽:Ubuntu Linux Apache2.4 Mysql5.7 php7.0 開始之前 系統版本 Ubu...
閱讀 731·2023-04-25 19:28
閱讀 1391·2021-09-10 10:51
閱讀 2390·2019-08-30 15:55
閱讀 3408·2019-08-26 13:55
閱讀 2996·2019-08-26 13:24
閱讀 3325·2019-08-26 11:46
閱讀 2751·2019-08-23 17:10
閱讀 1415·2019-08-23 16:57