LAMP one-click installation package complete list of operation commands

 




If you also encounter problems with LAMP, please refer to this article.

Frequently asked questions and answers have been listed, and I hope they will help you.

Why choose the LAMP one-click install script?
LAMP is a classic website building environment, especially for individual webmasters.
The software version of this script is updated in time and supports optional installation of PHP and database. Supports self-service upgrade of PHP and database programs.
It is easy to install and supports many PHP plug-ins. In fact, it is a LAMP environment tailored for the installation of Moodle.
Installation suggestion: According to the requirements of your own CMS website building system, you can select the appropriate software version to install.

Updated: April 29, 2019

Program directory:

  • MySQL installation directory: /usr/local/mysql
  • MySQL database directory: /usr/local/mysql/data (default path, can be changed during installation)
  • MariaDB installation directory: /usr/local/mariadb
  • MariaDB database directory: /usr/local/mariadb/data (default path, can be changed during installation)
  • Percona installation directory: /usr/local/percona
  • Percona database directory: /usr/local/percona/data (default path, can be changed during installation)
  • PHP installation directory: /usr/local/php
  • Apache installation directory: /usr/local/apache
  • phpMyAdmin installation directory: /data/www/default/phpmyadmin
  • KodExplorer installation directory: /data/www/default/kod

Site Directory:

  • Default website root directory: /data/www/default
  • Default page location: /data/www/default/index.html
  • New website default directory: /data/www/website domain name
  • phpmyadmin background address: http://domain name or IP/phpmyadmin/
  • phpmyadmin Default username: root Default password: root
    Note: This password is the root password of MySQL. It will be asked for input during installation, if not, it will be the default password root)
  • XCache background address: http://domain name or IP/xcache/
  • XCache default username: admin Default password: 123456
    Note: username and password are defined in the configuration file /usr/local/php/php.d/xcache.ini)

Configuration file:

  • Apache log directory: /usr/local/apache/logs
  • Create a new website log directory: /data/wwwlog/website domain name
  • Apache default SSL configuration file: /usr/local/apache/conf/extra/httpd-ssl.conf
  • Create a new website configuration file: /usr/local/apache/conf/vhost/website domain name.conf
  • PHP configuration file: /usr/local/php/etc/php.ini
  • PHP all extension configuration file directory: /usr/local/php/php.d/
  • MySQL configuration file: /etc/my.cnf

List of commands:

  • MySQL/MariaDB/Percona Server commands:

/etc/init.d/mysqld (start|stop|restart|status)

  • Apache command:

/etc/init.d/httpd (start|stop|restart|status)

  • Memcached command (optional installation)

/etc/init.d/memcached (start|stop|restart|status)

  • Redis commands (optional installation)

/etc/init.d/redis-server (start|stop|restart|status)

Simple process of installing LAMP and building a website:

  1. Install the LAMP environment
  2. Add virtual hosts. Run the command: lamp add
    (if you only build one station, you can directly upload the website program to the /data/www/default directory)
  3. Upload and unzip the website program to the website directory, the default location is: /data/www/website domain name/
  4. Change site directory permissions. Log in as root user and run: chown -R apache:apache /data/www/website domain name/
  5. Run the website installer to complete the website installation

Note: During the interaction of the installation process, when you find that the wrong input option needs to be corrected, you can press the Ctrl key and press the Backspace key at the same time to eliminate it. Or press Ctrl + u at the same time to clear all and re-enter.

Frequently Asked Questions
Q1: After installing the website program, upgrading or installing plug-ins and other errors, how to change the website directory permissions?
After logging in as root, run: chown -R apache:apache /data/www/website domain/

Q2: During installation, an error is reported due to insufficient memory, and the installation cannot be completed?
When the capacity of RAM + Swap is less than 480MB, exit the script directly; when it is 480-600MB, add the PHP compilation option –disable-fileinfo.
It also optimizes the memory usage during the installation process.
Note: Why is it written as 480 MB?
This is because the virtual VPS based on Xen or KVM generally has a lower memory capacity than the marked capacity. Generally speaking, it is 512MB, but in reality it is only about 480MB.
For VPS less than 512M, it is recommended to enable Swap. How to enable Swap, please refer to the article "How to Add Swap in CentOS".

Q3: The domain name and IP address both display the same webpage, how to set it?
This is because the domain name is not bound to the IP of your VPS public network.
Modify the configuration file /usr/local/apache/conf/extra/httpd-vhosts.conf
Beginning at line 1 of this file, append the following virtual host configuration:

<virtualhost *:80>
ServerName Public IP address
Redirect 301 / full URL (eg: https://teddysun.com)
</virtualhost>

Note that the format is 301+space+slash+space+full URL.
Then save and restart Apache.

Q4: What should I do to replace MySQL with MariaDB?

  1. Back up all databases, execute the command: /usr/local/mysql/bin/mysqldump -uroot -p the root password you set –all-databases > /root/mysql.dump
  2. Uninstall LAMP, command: lamp uninstall
  3. Reinstall LAMP, select MariaDB
  4. After the installation is complete, restore the database, the command: /usr/local/mariadb/bin/mysql -u root -p the root password you set < /root/mysql.dump

When LAMP is uninstalled, /data/www/default will not be deleted, which means that the website data will not be deleted. But the database will be deleted, so a backup is required.
Note that considering the program compatibility issue, this is not recommended (it is not appropriate to change the database program in the production environment, you should plan which database to use in advance) unless you know how to backup and restore your database.

Q5: How to change the default directory of the website?
Modify the DocmentRoot directory in the configuration file /usr/local/apache/conf/vhost/default.conf and the following Directory, and then restart Apache.

Q6: After a fresh installation, the directory other than /data/www/ cannot be referenced, such as /home/data/, how to solve it?
This is because of the open_basedir restriction of directory permissions for security reasons.
How to add eg /home/data directory? Modify the value after php_admin_value open_basedir in /usr/local/apache/conf/extra/httpd-vhosts.conf, add /home/data to the end, and be careful to separate it with a colon. Then restart Apache.

Q7: If the website is www.ccc.com, how can I make ccc.com jump to www.ccc.com?
You can set the domain name jump during domain name resolution (such as Dnspod), or you can use Apache's ServerAlias Set up multiple domain names.
For example, the configuration file of www.ccc.com is /usr/local/apache/conf/vhost/www.ccc.com.conf, add a new line ServerAlias ​​ccc.com after ServerName.
Modified example:
ServerName www.ccc.com
ServerAlias ​​ccc.com

Q8: If the path of MySQL or MariaDB is customized during installation, an error occurs when the system automatically initializes the database. Then it will prompt that the startup failed?
When customizing the database path of MySQL, if the directory does not exist, MySQL or MariaDB will try to create the directory, but the creation will generally fail due to insufficient permissions.
After MySQL is compiled and installed, the user:group in the /usr/local/mysql directory will be set to mysql:mysql, so the default directory /usr/local/mysql/data is no problem.
Therefore, when customizing the path, it is best to create the directory in advance, and change the directory user:group to mysql:mysql, for example, change the directory to /home/mysql/data
Of course, before LAMP is installed, the system does not necessarily have mysql users and user groups. Execute the following command to create:

/usr/sbin/groupadd mysql
/usr/sbin/useradd -s /sbin/nologin -M -g mysql mysql

Then, as root user execute:

chown -R mysql:mysql /home/mysql/data

Update (August 28, 2015):  This update optimizes the installation process of MySQL. The script will detect whether the custom path exists. If it does not exist, it will create the directory and change its owner and group. There is no need to manually create it before. .

Q9: What web panel management can LAMP cooperate with?

Webmin free panel. Refer to the article "Use webmin to manage PPTP VPN Server", there is a tutorial on how to quickly install webmin under CentOS.

Q10: How can I get into the background of XCache?

http://domain name or IP/xcache/
username: adminPassword
: 123456
The premise is that you can enter the background only after installing XCache.

Q11: How to modify the background user name and password of XCache?

Modify the corresponding values ​​of xcache.admin.user and xcache.admin.pass in /usr/local/php/php.d/xcache.ini.
Note that the value of xcache.admin.pass is the value after the password md5.
Then restart Apache.

Q12: The program can only support PHP 5.3, not PHP 5.4. How to downgrade to PHP 5.3? Is it possible to uninstall PHP directly and then reinstall PHP 5.3 separately?

Yes, but it is more troublesome, you have to recompile PHP 5.3.29 yourself.
Remove existing PHP steps:
rm -rf /etc/php.ini /usr/bin/php* /usr/local/php
Compile PHP 5.3.29 There are a few things to note. You need to configure the Apache, MySQL or MariaDB configuration in the environment together.
Of course, there is another way is to back up the data, uninstall LAMP and then install it again and select the PHP 5.3 version.

Q13: How to turn off the log function after installation?

Modify the Apache configuration file /usr/local/apache/conf/httpd.conf,
search for the keyword CustomLog (line 300), add a "#" to comment it out and restart Apache, then the access log will no longer be generated.

Q14: What is the usage of FTP installation?

Note: Updated on April 9, 2016, installing pureftp is no longer supported, please use SFTP instead. Recommend a client software: WinScp

Q15: How to set up Apache's SSL?

Generally setting /usr/local/apache/conf/extra/httpd-ssl.conf is enough.
You also need to enable Include conf/extra/httpd-ssl.conf in /usr/local/apache/conf/httpd.conf, that is, remove the preceding "#".
You can refer to the article "Deploying SSL under Apache Tutorial".

Q16: The following error occurs when installing PHP, what should I do?

cc: Internal error: Killed (program cc1)
Please submit a full bug report.
See for instructions.
make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1
Installing PHP failed, Please visit http://teddysun .com/lamp and contact.

Insufficient memory, the installation process was killed.
This will be the case if the memory is less than 512MB and there is no Swap. How to enable Swap, please refer to the article "How to Add Swap in CentOS".
For more error information query, refer to the article "Summary of Common Errors in PHP Compilation and Installation".

Q17: How to uninstall components, such as XCache, Memcached?

Delete the corresponding .so files and configuration files and restart Apache.
For example, if PHP 5.4 is installed:
/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/xcache.so
/usr/local/php/php.d/xcache.ini

The installation directory of each PHP extension can generally be queried using the following command:

/usr/ local /php/bin/php - config  --extension-dir 

Q18: How to uninstall phpMyAdmin?

phpMyAdmin If you don't need it, just delete its directory and it's OK.
The default installation location is /data/www/default/phpmyadmin/

Q19: How to set up a VPS with multiple IPs to correspond to a domain name?

Follow these steps:

  1. Create a virtual host, named after the domain name;
  2. Modify the configuration file /usr/local/apache/conf/vhost/domain name.conf
    and change virtualhost *:80 in the first line to virtualhost IP:80;
  3. Resolve the corresponding domain name to the IP set in the second step, and restart Apache.

Q20: Failed to install optional components under PHP 7?

This is because many components currently do not support PHP 7, such as XCache, gmagick, ZendGuardLoader, etc.
When the authors of these components update support, this script will follow up with updates in time.

Q21: Why can't I open the website after installation under CentOS 7?

After the installation of LAMP is complete, the website cannot be accessed by IP. Viewing the process also found that httpd and mysqld were also started, and ping was no problem, but it was inaccessible.
After some investigation, this is the problem caused by the latest firewalld firewall of CentOS 7.
It is time to replace firewalld with the classic iptables-services.
The command is as follows:

yum -y install iptables-services
systemctl mask firewalld
systemctl enable iptables
systemctl stop firewalld
systemctl start iptables

Then modify the firewall rules of iptables. Modify the file /etc/sysconfig/iptables to allow ports 80 and 443.
The full content is as follows:

# sample configuration for iptables service  # you can edit this manually or use system-config-firewall  # please do not ask us to add additional ports/services to this default configuration *filter
:INPUT ACCEPT [ 0 : 0 ]
:FORWARD ACCEPT [ 0 : 0 ]
:OUTPUT ACCEPT [ 0 : 0 ]
-A INPUT -m  state --state RELATED ,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m  state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m  state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m  state --state NEW -m tcp --dport 443 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

Note : The script has set firewalld firewall rules for CentOS 7 by default. This problem will no longer exist.

Q22: What should I do when I run the lamp add command to create a virtual host under Amazon Linux, and the following error message appears when issuing the SSL certificate?

FATAL: Amazon Linux support is very experimental at present... if you
would like to work on improving it, please ensure you have backups and
then run this script again with the --debug flag!, you
can install OS dependencies yourself and run this script again with
--no-bootstrap.

This is because certbot's support for Amazon Linux is still in the experimental stage, so it cannot automatically install dependent packages. At this point, you need to manually install the dependencies.
Run the command:

certbot --debug _ 

At this time, you will see that certbot is installing the dependency package, enter y and press Enter to install it.
Then run the lamp add command again to create a virtual host.

Post a Comment

Previous Post Next Post